diff --git a/src/libcore/cmp.rs b/src/libcore/cmp.rs index 06e7e45c7014e..3ea4baa57b49e 100644 --- a/src/libcore/cmp.rs +++ b/src/libcore/cmp.rs @@ -821,10 +821,7 @@ pub trait PartialOrd: PartialEq { #[must_use] #[stable(feature = "rust1", since = "1.0.0")] fn lt(&self, other: &Rhs) -> bool { - match self.partial_cmp(other) { - Some(Less) => true, - _ => false, - } + matches!(self.partial_cmp(other), Some(Less)) } /// This method tests less than or equal to (for `self` and `other`) and is used by the `<=` @@ -843,10 +840,7 @@ pub trait PartialOrd: PartialEq { #[must_use] #[stable(feature = "rust1", since = "1.0.0")] fn le(&self, other: &Rhs) -> bool { - match self.partial_cmp(other) { - Some(Less) | Some(Equal) => true, - _ => false, - } + matches!(self.partial_cmp(other), Some(Less) | Some(Equal)) } /// This method tests greater than (for `self` and `other`) and is used by the `>` operator. @@ -864,10 +858,7 @@ pub trait PartialOrd: PartialEq { #[must_use] #[stable(feature = "rust1", since = "1.0.0")] fn gt(&self, other: &Rhs) -> bool { - match self.partial_cmp(other) { - Some(Greater) => true, - _ => false, - } + matches!(self.partial_cmp(other), Some(Greater)) } /// This method tests greater than or equal to (for `self` and `other`) and is used by the `>=` @@ -886,10 +877,7 @@ pub trait PartialOrd: PartialEq { #[must_use] #[stable(feature = "rust1", since = "1.0.0")] fn ge(&self, other: &Rhs) -> bool { - match self.partial_cmp(other) { - Some(Greater) | Some(Equal) => true, - _ => false, - } + matches!(self.partial_cmp(other), Some(Greater) | Some(Equal)) } } diff --git a/src/libcore/iter/traits/iterator.rs b/src/libcore/iter/traits/iterator.rs index c958289b2c935..21a569867b178 100644 --- a/src/libcore/iter/traits/iterator.rs +++ b/src/libcore/iter/traits/iterator.rs @@ -2968,10 +2968,7 @@ pub trait Iterator { Self::Item: PartialOrd, Self: Sized, { - match self.partial_cmp(other) { - Some(Ordering::Less) | Some(Ordering::Equal) => true, - _ => false, - } + matches!(self.partial_cmp(other), Some(Ordering::Less) | Some(Ordering::Equal)) } /// Determines if the elements of this `Iterator` are lexicographically @@ -3011,10 +3008,7 @@ pub trait Iterator { Self::Item: PartialOrd, Self: Sized, { - match self.partial_cmp(other) { - Some(Ordering::Greater) | Some(Ordering::Equal) => true, - _ => false, - } + matches!(self.partial_cmp(other), Some(Ordering::Greater) | Some(Ordering::Equal)) } /// Checks if the elements of this iterator are sorted. diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs index b6b4a46e0b812..072966abf2c40 100644 --- a/src/libcore/num/mod.rs +++ b/src/libcore/num/mod.rs @@ -1416,6 +1416,7 @@ $EndFeature, " ```"), #[stable(feature = "no_panic_abs", since = "1.13.0")] #[rustc_const_stable(feature = "const_int_methods", since = "1.32.0")] + #[allow(unused_attributes)] #[allow_internal_unstable(const_if_match)] #[inline] pub const fn wrapping_abs(self) -> Self { @@ -1709,6 +1710,7 @@ assert_eq!(", stringify!($SelfT), "::MIN.overflowing_neg(), (", stringify!($Self #[inline] #[stable(feature = "wrapping", since = "1.7.0")] #[rustc_const_stable(feature = "const_int_methods", since = "1.32.0")] + #[allow(unused_attributes)] #[allow_internal_unstable(const_if_match)] pub const fn overflowing_neg(self) -> (Self, bool) { if self == Self::min_value() { @@ -1997,6 +1999,7 @@ $EndFeature, " ```"), #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_stable(feature = "const_int_methods", since = "1.32.0")] + #[allow(unused_attributes)] #[allow_internal_unstable(const_if_match)] #[inline] #[rustc_inherit_overflow_checks] @@ -4283,10 +4286,7 @@ impl u8 { #[stable(feature = "ascii_ctype_on_intrinsics", since = "1.24.0")] #[inline] pub fn is_ascii_alphabetic(&self) -> bool { - match *self { - b'A'..=b'Z' | b'a'..=b'z' => true, - _ => false, - } + matches!(*self, b'A'..=b'Z' | b'a'..=b'z') } /// Checks if the value is an ASCII uppercase character: @@ -4318,10 +4318,7 @@ impl u8 { #[stable(feature = "ascii_ctype_on_intrinsics", since = "1.24.0")] #[inline] pub fn is_ascii_uppercase(&self) -> bool { - match *self { - b'A'..=b'Z' => true, - _ => false, - } + matches!(*self, b'A'..=b'Z') } /// Checks if the value is an ASCII lowercase character: @@ -4353,10 +4350,7 @@ impl u8 { #[stable(feature = "ascii_ctype_on_intrinsics", since = "1.24.0")] #[inline] pub fn is_ascii_lowercase(&self) -> bool { - match *self { - b'a'..=b'z' => true, - _ => false, - } + matches!(*self, b'a'..=b'z') } /// Checks if the value is an ASCII alphanumeric character: @@ -4391,10 +4385,7 @@ impl u8 { #[stable(feature = "ascii_ctype_on_intrinsics", since = "1.24.0")] #[inline] pub fn is_ascii_alphanumeric(&self) -> bool { - match *self { - b'0'..=b'9' | b'A'..=b'Z' | b'a'..=b'z' => true, - _ => false, - } + matches!(*self, b'0'..=b'9' | b'A'..=b'Z' | b'a'..=b'z') } /// Checks if the value is an ASCII decimal digit: @@ -4426,10 +4417,7 @@ impl u8 { #[stable(feature = "ascii_ctype_on_intrinsics", since = "1.24.0")] #[inline] pub fn is_ascii_digit(&self) -> bool { - match *self { - b'0'..=b'9' => true, - _ => false, - } + matches!(*self, b'0'..=b'9') } /// Checks if the value is an ASCII hexadecimal digit: @@ -4464,10 +4452,7 @@ impl u8 { #[stable(feature = "ascii_ctype_on_intrinsics", since = "1.24.0")] #[inline] pub fn is_ascii_hexdigit(&self) -> bool { - match *self { - b'0'..=b'9' | b'A'..=b'F' | b'a'..=b'f' => true, - _ => false, - } + matches!(*self, b'0'..=b'9' | b'A'..=b'F' | b'a'..=b'f') } /// Checks if the value is an ASCII punctuation character: @@ -4503,10 +4488,7 @@ impl u8 { #[stable(feature = "ascii_ctype_on_intrinsics", since = "1.24.0")] #[inline] pub fn is_ascii_punctuation(&self) -> bool { - match *self { - b'!'..=b'/' | b':'..=b'@' | b'['..=b'`' | b'{'..=b'~' => true, - _ => false, - } + matches!(*self, b'!'..=b'/' | b':'..=b'@' | b'['..=b'`' | b'{'..=b'~') } /// Checks if the value is an ASCII graphic character: @@ -4538,10 +4520,7 @@ impl u8 { #[stable(feature = "ascii_ctype_on_intrinsics", since = "1.24.0")] #[inline] pub fn is_ascii_graphic(&self) -> bool { - match *self { - b'!'..=b'~' => true, - _ => false, - } + matches!(*self, b'!'..=b'~') } /// Checks if the value is an ASCII whitespace character: @@ -4590,10 +4569,7 @@ impl u8 { #[stable(feature = "ascii_ctype_on_intrinsics", since = "1.24.0")] #[inline] pub fn is_ascii_whitespace(&self) -> bool { - match *self { - b'\t' | b'\n' | b'\x0C' | b'\r' | b' ' => true, - _ => false, - } + matches!(*self, b'\t' | b'\n' | b'\x0C' | b'\r' | b' ') } /// Checks if the value is an ASCII control character: @@ -4627,10 +4603,7 @@ impl u8 { #[stable(feature = "ascii_ctype_on_intrinsics", since = "1.24.0")] #[inline] pub fn is_ascii_control(&self) -> bool { - match *self { - b'\0'..=b'\x1F' | b'\x7F' => true, - _ => false, - } + matches!(*self, b'\0'..=b'\x1F' | b'\x7F') } } diff --git a/src/libcore/option.rs b/src/libcore/option.rs index fb534586fc615..a471b174534aa 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -187,10 +187,7 @@ impl Option { #[inline] #[stable(feature = "rust1", since = "1.0.0")] pub fn is_some(&self) -> bool { - match *self { - Some(_) => true, - None => false, - } + matches!(*self, Some(_)) } /// Returns `true` if the option is a [`None`] value. diff --git a/src/libcore/result.rs b/src/libcore/result.rs index b39abf917850d..c6062493b8608 100644 --- a/src/libcore/result.rs +++ b/src/libcore/result.rs @@ -282,10 +282,7 @@ impl Result { #[inline] #[stable(feature = "rust1", since = "1.0.0")] pub const fn is_ok(&self) -> bool { - match *self { - Ok(_) => true, - Err(_) => false, - } + matches!(*self, Ok(_)) } /// Returns `true` if the result is [`Err`]. diff --git a/src/libcore/str/pattern.rs b/src/libcore/str/pattern.rs index 2cbdeb2e4eed8..46d9499394a38 100644 --- a/src/libcore/str/pattern.rs +++ b/src/libcore/str/pattern.rs @@ -46,10 +46,7 @@ pub trait Pattern<'a>: Sized { /// Checks whether the pattern matches at the front of the haystack #[inline] fn is_prefix_of(self, haystack: &'a str) -> bool { - match self.into_searcher(haystack).next() { - SearchStep::Match(0, _) => true, - _ => false, - } + matches!(self.into_searcher(haystack).next(), SearchStep::Match(0, _)) } /// Checks whether the pattern matches at the back of the haystack @@ -58,10 +55,7 @@ pub trait Pattern<'a>: Sized { where Self::Searcher: ReverseSearcher<'a>, { - match self.into_searcher(haystack).next_back() { - SearchStep::Match(_, j) if haystack.len() == j => true, - _ => false, - } + matches!(self.into_searcher(haystack).next_back(), SearchStep::Match(_, j) if haystack.len() == j) } } diff --git a/src/libcore/task/poll.rs b/src/libcore/task/poll.rs index d567ae545774e..b3a4bd20b8f04 100644 --- a/src/libcore/task/poll.rs +++ b/src/libcore/task/poll.rs @@ -39,10 +39,7 @@ impl Poll { #[inline] #[stable(feature = "futures_api", since = "1.36.0")] pub fn is_ready(&self) -> bool { - match *self { - Poll::Ready(_) => true, - Poll::Pending => false, - } + matches!(*self, Poll::Ready(_)) } /// Returns `true` if this is `Poll::Pending` diff --git a/src/librustc/hir/check_attr.rs b/src/librustc/hir/check_attr.rs index d525f36459336..06b7b3194defd 100644 --- a/src/librustc/hir/check_attr.rs +++ b/src/librustc/hir/check_attr.rs @@ -4,7 +4,7 @@ //! conflicts between multiple such attributes attached to the same //! item. -use crate::hir::intravisit::{self, NestedVisitorMap, Visitor}; +use crate::hir::map::Map; use crate::lint::builtin::UNUSED_ATTRIBUTES; use crate::ty::query::Providers; use crate::ty::TyCtxt; @@ -13,6 +13,7 @@ use errors::struct_span_err; use rustc_error_codes::*; use rustc_hir as hir; use rustc_hir::def_id::DefId; +use rustc_hir::intravisit::{self, NestedVisitorMap, Visitor}; use rustc_hir::DUMMY_HIR_ID; use rustc_hir::{self, HirId, Item, ItemKind, TraitItem, TraitItemKind}; use rustc_span::symbol::sym; @@ -519,7 +520,9 @@ impl CheckAttrVisitor<'tcx> { } impl Visitor<'tcx> for CheckAttrVisitor<'tcx> { - fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> { + type Map = Map<'tcx>; + + fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, Self::Map> { NestedVisitorMap::OnlyBodies(&self.tcx.hir()) } diff --git a/src/librustc/hir/map/blocks.rs b/src/librustc/hir/map/blocks.rs index 2cd44770b02cb..016fc939a7a17 100644 --- a/src/librustc/hir/map/blocks.rs +++ b/src/librustc/hir/map/blocks.rs @@ -11,9 +11,9 @@ //! nested within a uniquely determined `FnLike`), and users can ask //! for the `Code` associated with a particular NodeId. -use crate::hir::intravisit::FnKind; -use crate::hir::map; -use rustc_hir as ast; +use crate::hir::map::Map; +use rustc_hir as hir; +use rustc_hir::intravisit::FnKind; use rustc_hir::{Expr, FnDecl, Node}; use rustc_span::Span; use syntax::ast::{Attribute, Ident}; @@ -39,37 +39,37 @@ trait MaybeFnLike { fn is_fn_like(&self) -> bool; } -impl MaybeFnLike for ast::Item<'_> { +impl MaybeFnLike for hir::Item<'_> { fn is_fn_like(&self) -> bool { match self.kind { - ast::ItemKind::Fn(..) => true, + hir::ItemKind::Fn(..) => true, _ => false, } } } -impl MaybeFnLike for ast::ImplItem<'_> { +impl MaybeFnLike for hir::ImplItem<'_> { fn is_fn_like(&self) -> bool { match self.kind { - ast::ImplItemKind::Method(..) => true, + hir::ImplItemKind::Method(..) => true, _ => false, } } } -impl MaybeFnLike for ast::TraitItem<'_> { +impl MaybeFnLike for hir::TraitItem<'_> { fn is_fn_like(&self) -> bool { match self.kind { - ast::TraitItemKind::Method(_, ast::TraitMethod::Provided(_)) => true, + hir::TraitItemKind::Method(_, hir::TraitMethod::Provided(_)) => true, _ => false, } } } -impl MaybeFnLike for ast::Expr<'_> { +impl MaybeFnLike for hir::Expr<'_> { fn is_fn_like(&self) -> bool { match self.kind { - ast::ExprKind::Closure(..) => true, + hir::ExprKind::Closure(..) => true, _ => false, } } @@ -85,7 +85,7 @@ pub enum Code<'a> { } impl<'a> Code<'a> { - pub fn id(&self) -> ast::HirId { + pub fn id(&self) -> hir::HirId { match *self { Code::FnLike(node) => node.id(), Code::Expr(block) => block.hir_id, @@ -93,13 +93,13 @@ impl<'a> Code<'a> { } /// Attempts to construct a Code from presumed FnLike or Expr node input. - pub fn from_node(map: &map::Map<'a>, id: ast::HirId) -> Option> { + pub fn from_node(map: &Map<'a>, id: hir::HirId) -> Option> { match map.get(id) { - map::Node::Block(_) => { + Node::Block(_) => { // Use the parent, hopefully an expression node. Code::from_node(map, map.get_parent_node(id)) } - map::Node::Expr(expr) => Some(Code::Expr(expr)), + Node::Expr(expr) => Some(Code::Expr(expr)), node => FnLikeNode::from_node(node).map(Code::FnLike), } } @@ -109,12 +109,12 @@ impl<'a> Code<'a> { /// use when implementing FnLikeNode operations. struct ItemFnParts<'a> { ident: Ident, - decl: &'a ast::FnDecl<'a>, - header: ast::FnHeader, - vis: &'a ast::Visibility<'a>, - generics: &'a ast::Generics<'a>, - body: ast::BodyId, - id: ast::HirId, + decl: &'a hir::FnDecl<'a>, + header: hir::FnHeader, + vis: &'a hir::Visibility<'a>, + generics: &'a hir::Generics<'a>, + body: hir::BodyId, + id: hir::HirId, span: Span, attrs: &'a [Attribute], } @@ -123,8 +123,8 @@ struct ItemFnParts<'a> { /// for use when implementing FnLikeNode operations. struct ClosureParts<'a> { decl: &'a FnDecl<'a>, - body: ast::BodyId, - id: ast::HirId, + body: hir::BodyId, + id: hir::HirId, span: Span, attrs: &'a [Attribute], } @@ -132,8 +132,8 @@ struct ClosureParts<'a> { impl<'a> ClosureParts<'a> { fn new( d: &'a FnDecl<'a>, - b: ast::BodyId, - id: ast::HirId, + b: hir::BodyId, + id: hir::HirId, s: Span, attrs: &'a [Attribute], ) -> Self { @@ -145,19 +145,19 @@ impl<'a> FnLikeNode<'a> { /// Attempts to construct a FnLikeNode from presumed FnLike node input. pub fn from_node(node: Node<'_>) -> Option> { let fn_like = match node { - map::Node::Item(item) => item.is_fn_like(), - map::Node::TraitItem(tm) => tm.is_fn_like(), - map::Node::ImplItem(it) => it.is_fn_like(), - map::Node::Expr(e) => e.is_fn_like(), + Node::Item(item) => item.is_fn_like(), + Node::TraitItem(tm) => tm.is_fn_like(), + Node::ImplItem(it) => it.is_fn_like(), + Node::Expr(e) => e.is_fn_like(), _ => false, }; fn_like.then_some(FnLikeNode { node }) } - pub fn body(self) -> ast::BodyId { + pub fn body(self) -> hir::BodyId { self.handle( |i: ItemFnParts<'a>| i.body, - |_, _, _: &'a ast::FnSig<'a>, _, body: ast::BodyId, _, _| body, + |_, _, _: &'a hir::FnSig<'a>, _, body: hir::BodyId, _, _| body, |c: ClosureParts<'a>| c.body, ) } @@ -165,7 +165,7 @@ impl<'a> FnLikeNode<'a> { pub fn decl(self) -> &'a FnDecl<'a> { self.handle( |i: ItemFnParts<'a>| &*i.decl, - |_, _, sig: &'a ast::FnSig<'a>, _, _, _, _| &sig.decl, + |_, _, sig: &'a hir::FnSig<'a>, _, _, _, _| &sig.decl, |c: ClosureParts<'a>| c.decl, ) } @@ -173,29 +173,29 @@ impl<'a> FnLikeNode<'a> { pub fn span(self) -> Span { self.handle( |i: ItemFnParts<'_>| i.span, - |_, _, _: &'a ast::FnSig<'a>, _, _, span, _| span, + |_, _, _: &'a hir::FnSig<'a>, _, _, span, _| span, |c: ClosureParts<'_>| c.span, ) } - pub fn id(self) -> ast::HirId { + pub fn id(self) -> hir::HirId { self.handle( |i: ItemFnParts<'_>| i.id, - |id, _, _: &'a ast::FnSig<'a>, _, _, _, _| id, + |id, _, _: &'a hir::FnSig<'a>, _, _, _, _| id, |c: ClosureParts<'_>| c.id, ) } - pub fn constness(self) -> ast::Constness { - self.kind().header().map_or(ast::Constness::NotConst, |header| header.constness) + pub fn constness(self) -> hir::Constness { + self.kind().header().map_or(hir::Constness::NotConst, |header| header.constness) } - pub fn asyncness(self) -> ast::IsAsync { - self.kind().header().map_or(ast::IsAsync::NotAsync, |header| header.asyncness) + pub fn asyncness(self) -> hir::IsAsync { + self.kind().header().map_or(hir::IsAsync::NotAsync, |header| header.asyncness) } - pub fn unsafety(self) -> ast::Unsafety { - self.kind().header().map_or(ast::Unsafety::Normal, |header| header.unsafety) + pub fn unsafety(self) -> hir::Unsafety { + self.kind().header().map_or(hir::Unsafety::Normal, |header| header.unsafety) } pub fn kind(self) -> FnKind<'a> { @@ -203,7 +203,7 @@ impl<'a> FnLikeNode<'a> { FnKind::ItemFn(p.ident, p.generics, p.header, p.vis, p.attrs) }; let closure = |c: ClosureParts<'a>| FnKind::Closure(c.attrs); - let method = |_, ident: Ident, sig: &'a ast::FnSig<'a>, vis, _, _, attrs| { + let method = |_, ident: Ident, sig: &'a hir::FnSig<'a>, vis, _, _, attrs| { FnKind::Method(ident, sig, vis, attrs) }; self.handle(item, method, closure) @@ -213,19 +213,19 @@ impl<'a> FnLikeNode<'a> { where I: FnOnce(ItemFnParts<'a>) -> A, M: FnOnce( - ast::HirId, + hir::HirId, Ident, - &'a ast::FnSig<'a>, - Option<&'a ast::Visibility<'a>>, - ast::BodyId, + &'a hir::FnSig<'a>, + Option<&'a hir::Visibility<'a>>, + hir::BodyId, Span, &'a [Attribute], ) -> A, C: FnOnce(ClosureParts<'a>) -> A, { match self.node { - map::Node::Item(i) => match i.kind { - ast::ItemKind::Fn(ref sig, ref generics, block) => item_fn(ItemFnParts { + Node::Item(i) => match i.kind { + hir::ItemKind::Fn(ref sig, ref generics, block) => item_fn(ItemFnParts { id: i.hir_id, ident: i.ident, decl: &sig.decl, @@ -238,20 +238,20 @@ impl<'a> FnLikeNode<'a> { }), _ => bug!("item FnLikeNode that is not fn-like"), }, - map::Node::TraitItem(ti) => match ti.kind { - ast::TraitItemKind::Method(ref sig, ast::TraitMethod::Provided(body)) => { + Node::TraitItem(ti) => match ti.kind { + hir::TraitItemKind::Method(ref sig, hir::TraitMethod::Provided(body)) => { method(ti.hir_id, ti.ident, sig, None, body, ti.span, &ti.attrs) } _ => bug!("trait method FnLikeNode that is not fn-like"), }, - map::Node::ImplItem(ii) => match ii.kind { - ast::ImplItemKind::Method(ref sig, body) => { + Node::ImplItem(ii) => match ii.kind { + hir::ImplItemKind::Method(ref sig, body) => { method(ii.hir_id, ii.ident, sig, Some(&ii.vis), body, ii.span, &ii.attrs) } _ => bug!("impl method FnLikeNode that is not fn-like"), }, - map::Node::Expr(e) => match e.kind { - ast::ExprKind::Closure(_, ref decl, block, _fn_decl_span, _gen) => { + Node::Expr(e) => match e.kind { + hir::ExprKind::Closure(_, ref decl, block, _fn_decl_span, _gen) => { closure(ClosureParts::new(&decl, block, e.hir_id, e.span, &e.attrs)) } _ => bug!("expr FnLikeNode that is not fn-like"), diff --git a/src/librustc/hir/map/collector.rs b/src/librustc/hir/map/collector.rs index 6879e8fd76348..b6be4bb001996 100644 --- a/src/librustc/hir/map/collector.rs +++ b/src/librustc/hir/map/collector.rs @@ -1,22 +1,24 @@ -use super::*; -use crate::dep_graph::{DepGraph, DepKind, DepNodeIndex}; -use crate::hir::intravisit::{NestedVisitorMap, Visitor}; -use crate::hir::map::HirEntryMap; -use crate::ich::Fingerprint; +use crate::dep_graph::{DepGraph, DepKind, DepNode, DepNodeIndex}; +use crate::hir::map::definitions::{self, DefPathHash}; +use crate::hir::map::{Entry, HirEntryMap, Map}; +use crate::ich::StableHashingContext; use crate::middle::cstore::CrateStore; +use rustc_data_structures::fingerprint::Fingerprint; use rustc_data_structures::fx::FxHashMap; +use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; use rustc_data_structures::svh::Svh; use rustc_hir as hir; +use rustc_hir::def_id::CRATE_DEF_INDEX; use rustc_hir::def_id::{CrateNum, DefIndex, LOCAL_CRATE}; +use rustc_hir::intravisit::{self, NestedVisitorMap, Visitor}; +use rustc_hir::*; use rustc_index::vec::IndexVec; use rustc_session::{CrateDisambiguator, Session}; use rustc_span::source_map::SourceMap; -use rustc_span::Span; -use std::iter::repeat; +use rustc_span::{Span, Symbol, DUMMY_SP}; use syntax::ast::NodeId; -use crate::ich::StableHashingContext; -use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; +use std::iter::repeat; /// A visitor that walks over the HIR and collects `Node`s into a HIR map. pub(super) struct NodeCollector<'a, 'hir> { @@ -49,15 +51,12 @@ pub(super) struct NodeCollector<'a, 'hir> { hir_body_nodes: Vec<(DefPathHash, Fingerprint)>, } -fn input_dep_node_and_hash( +fn input_dep_node_and_hash( dep_graph: &DepGraph, hcx: &mut StableHashingContext<'_>, dep_node: DepNode, - input: I, -) -> (DepNodeIndex, Fingerprint) -where - I: for<'a> HashStable>, -{ + input: impl for<'a> HashStable>, +) -> (DepNodeIndex, Fingerprint) { let dep_node_index = dep_graph.input_task(dep_node, &mut *hcx, &input).1; let hash = if dep_graph.is_fully_enabled() { @@ -71,16 +70,13 @@ where (dep_node_index, hash) } -fn alloc_hir_dep_nodes( +fn alloc_hir_dep_nodes( dep_graph: &DepGraph, hcx: &mut StableHashingContext<'_>, def_path_hash: DefPathHash, - item_like: I, + item_like: impl for<'a> HashStable>, hir_body_nodes: &mut Vec<(DefPathHash, Fingerprint)>, -) -> (DepNodeIndex, DepNodeIndex) -where - I: for<'a> HashStable>, -{ +) -> (DepNodeIndex, DepNodeIndex) { let sig = dep_graph .input_task( def_path_hash.to_dep_node(DepKind::Hir), @@ -98,6 +94,21 @@ where (sig, full) } +fn upstream_crates(cstore: &dyn CrateStore) -> Vec<(Symbol, Fingerprint, Svh)> { + let mut upstream_crates: Vec<_> = cstore + .crates_untracked() + .iter() + .map(|&cnum| { + let name = cstore.crate_name_untracked(cnum); + let disambiguator = cstore.crate_disambiguator_untracked(cnum).to_fingerprint(); + let hash = cstore.crate_hash_untracked(cnum); + (name, disambiguator, hash) + }) + .collect(); + upstream_crates.sort_unstable_by_key(|&(name, dis, _)| (name.as_str(), dis)); + upstream_crates +} + impl<'a, 'hir> NodeCollector<'a, 'hir> { pub(super) fn root( sess: &'a Session, @@ -190,18 +201,7 @@ impl<'a, 'hir> NodeCollector<'a, 'hir> { }, ); - let mut upstream_crates: Vec<_> = cstore - .crates_untracked() - .iter() - .map(|&cnum| { - let name = cstore.crate_name_untracked(cnum); - let disambiguator = cstore.crate_disambiguator_untracked(cnum).to_fingerprint(); - let hash = cstore.crate_hash_untracked(cnum); - (name, disambiguator, hash) - }) - .collect(); - - upstream_crates.sort_unstable_by_key(|&(name, dis, _)| (name.as_str(), dis)); + let upstream_crates = upstream_crates(cstore); // We hash the final, remapped names of all local source files so we // don't have to include the path prefix remapping commandline args. @@ -336,11 +336,13 @@ impl<'a, 'hir> NodeCollector<'a, 'hir> { } impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> { + type Map = Map<'hir>; + /// Because we want to track parent items and so forth, enable /// deep walking so that we walk nested items in the context of /// their outer items. - fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'hir> { + fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, Self::Map> { panic!("`visit_nested_xxx` must be manually implemented in this visitor"); } diff --git a/src/librustc/hir/map/definitions.rs b/src/librustc/hir/map/definitions.rs index 67d29b38db2a5..ac2d7a9a8dc2a 100644 --- a/src/librustc/hir/map/definitions.rs +++ b/src/librustc/hir/map/definitions.rs @@ -4,7 +4,7 @@ //! There are also some rather random cases (like const initializer //! expressions) that are mostly just leftovers. -use crate::ich::Fingerprint; +use rustc_data_structures::fingerprint::Fingerprint; use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::stable_hasher::StableHasher; use rustc_hir as hir; @@ -15,10 +15,11 @@ use rustc_session::CrateDisambiguator; use rustc_span::hygiene::ExpnId; use rustc_span::symbol::{sym, Symbol}; use rustc_span::Span; +use syntax::ast; + use std::borrow::Borrow; use std::fmt::Write; use std::hash::Hash; -use syntax::ast; /// The `DefPathTable` maps `DefIndex`es to `DefKey`s and vice versa. /// Internally the `DefPathTable` holds a tree of `DefKey`s, where each `DefKey` diff --git a/src/librustc/hir/map/hir_id_validator.rs b/src/librustc/hir/map/hir_id_validator.rs index 6329970759203..76e42b8af2874 100644 --- a/src/librustc/hir/map/hir_id_validator.rs +++ b/src/librustc/hir/map/hir_id_validator.rs @@ -1,9 +1,9 @@ -use crate::hir::intravisit; use crate::hir::map::Map; use rustc_data_structures::fx::FxHashSet; use rustc_data_structures::sync::{par_iter, Lock, ParallelIterator}; use rustc_hir as hir; use rustc_hir::def_id::{DefId, DefIndex, CRATE_DEF_INDEX}; +use rustc_hir::intravisit; use rustc_hir::itemlikevisit::ItemLikeVisitor; use rustc_hir::{HirId, ItemLocalId}; @@ -133,7 +133,9 @@ impl<'a, 'hir> HirIdValidator<'a, 'hir> { } impl<'a, 'hir> intravisit::Visitor<'hir> for HirIdValidator<'a, 'hir> { - fn nested_visit_map<'this>(&'this mut self) -> intravisit::NestedVisitorMap<'this, 'hir> { + type Map = Map<'hir>; + + fn nested_visit_map<'this>(&'this mut self) -> intravisit::NestedVisitorMap<'this, Self::Map> { intravisit::NestedVisitorMap::OnlyBodies(self.hir_map) } diff --git a/src/librustc/hir/map/mod.rs b/src/librustc/hir/map/mod.rs index 0a165accb7d52..e18ab7848feaa 100644 --- a/src/librustc/hir/map/mod.rs +++ b/src/librustc/hir/map/mod.rs @@ -4,13 +4,13 @@ pub use self::definitions::{ }; use crate::dep_graph::{DepGraph, DepKind, DepNode, DepNodeIndex}; -use crate::hir::intravisit; use crate::middle::cstore::CrateStoreDyn; use crate::ty::query::Providers; use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::svh::Svh; use rustc_hir::def::{DefKind, Res}; use rustc_hir::def_id::{DefId, DefIndex, LocalDefId, CRATE_DEF_INDEX}; +use rustc_hir::intravisit; use rustc_hir::itemlikevisit::ItemLikeVisitor; use rustc_hir::print::Nested; use rustc_hir::*; @@ -18,7 +18,7 @@ use rustc_index::vec::IndexVec; use rustc_span::hygiene::MacroKind; use rustc_span::source_map::Spanned; use rustc_span::symbol::kw; -use rustc_span::{Span, DUMMY_SP}; +use rustc_span::Span; use rustc_target::spec::abi::Abi; use syntax::ast::{self, Name, NodeId}; @@ -186,12 +186,12 @@ struct ParentHirIterator<'map, 'hir> { } impl<'map, 'hir> ParentHirIterator<'map, 'hir> { - fn new(current_id: HirId, map: &'map Map<'hir>) -> ParentHirIterator<'map, 'hir> { - ParentHirIterator { current_id, map } + fn new(current_id: HirId, map: &'map Map<'hir>) -> Self { + Self { current_id, map } } } -impl<'map, 'hir> Iterator for ParentHirIterator<'map, 'hir> { +impl<'hir> Iterator for ParentHirIterator<'_, 'hir> { type Item = (HirId, Node<'hir>); fn next(&mut self) -> Option { @@ -405,6 +405,14 @@ impl<'hir> Map<'hir> { self.forest.krate() } + pub fn item(&self, id: HirId) -> &'hir Item<'hir> { + self.read(id); + + // N.B., intentionally bypass `self.forest.krate()` so that we + // do not trigger a read of the whole krate here + self.forest.krate.item(id) + } + pub fn trait_item(&self, id: TraitItemId) -> &'hir TraitItem<'hir> { self.read(id.hir_id); @@ -1085,6 +1093,24 @@ impl<'hir> Map<'hir> { } } +impl<'hir> intravisit::Map<'hir> for Map<'hir> { + fn body(&self, id: BodyId) -> &'hir Body<'hir> { + self.body(id) + } + + fn item(&self, id: HirId) -> &'hir Item<'hir> { + self.item(id) + } + + fn trait_item(&self, id: TraitItemId) -> &'hir TraitItem<'hir> { + self.trait_item(id) + } + + fn impl_item(&self, id: ImplItemId) -> &'hir ImplItem<'hir> { + self.impl_item(id) + } +} + pub struct NodesMatchingSuffix<'a> { map: &'a Map<'a>, item_name: &'a String, diff --git a/src/librustc/hir/mod.rs b/src/librustc/hir/mod.rs index 3087fc3c1f2e6..97c14dd7e0054 100644 --- a/src/librustc/hir/mod.rs +++ b/src/librustc/hir/mod.rs @@ -4,7 +4,6 @@ pub mod check_attr; pub mod exports; -pub mod intravisit; pub mod map; pub mod upvars; diff --git a/src/librustc/hir/upvars.rs b/src/librustc/hir/upvars.rs index df02a79ef4cc2..4ca294f486155 100644 --- a/src/librustc/hir/upvars.rs +++ b/src/librustc/hir/upvars.rs @@ -1,11 +1,12 @@ //! Upvar (closure capture) collection from cross-body HIR uses of `Res::Local`s. -use crate::hir::intravisit::{self, NestedVisitorMap, Visitor}; +use crate::hir::map::Map; use crate::ty::query::Providers; use crate::ty::TyCtxt; use rustc_data_structures::fx::{FxHashSet, FxIndexMap}; use rustc_hir as hir; use rustc_hir::def::Res; +use rustc_hir::intravisit::{self, NestedVisitorMap, Visitor}; use rustc_hir::{self, HirId}; use rustc_span::Span; @@ -43,7 +44,9 @@ struct LocalCollector { } impl Visitor<'tcx> for LocalCollector { - fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> { + type Map = Map<'tcx>; + + fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, Self::Map> { NestedVisitorMap::None } @@ -70,7 +73,9 @@ impl CaptureCollector<'_, '_> { } impl Visitor<'tcx> for CaptureCollector<'a, 'tcx> { - fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> { + type Map = Map<'tcx>; + + fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, Self::Map> { NestedVisitorMap::None } diff --git a/src/librustc/infer/error_reporting/need_type_info.rs b/src/librustc/infer/error_reporting/need_type_info.rs index 4dedf0a23e827..16cfaec5ee91b 100644 --- a/src/librustc/infer/error_reporting/need_type_info.rs +++ b/src/librustc/infer/error_reporting/need_type_info.rs @@ -1,4 +1,3 @@ -use crate::hir::intravisit::{self, NestedVisitorMap, Visitor}; use crate::hir::map::Map; use crate::infer::type_variable::TypeVariableOriginKind; use crate::infer::InferCtxt; @@ -7,6 +6,7 @@ use crate::ty::{self, DefIdTree, Infer, Ty, TyVar}; use errors::{struct_span_err, Applicability, DiagnosticBuilder}; use rustc_hir as hir; use rustc_hir::def::{DefKind, Namespace}; +use rustc_hir::intravisit::{self, NestedVisitorMap, Visitor}; use rustc_hir::{Body, Expr, ExprKind, FunctionRetTy, HirId, Local, Pat}; use rustc_span::source_map::DesugaringKind; use rustc_span::symbol::kw; @@ -66,7 +66,9 @@ impl<'a, 'tcx> FindLocalByTypeVisitor<'a, 'tcx> { } impl<'a, 'tcx> Visitor<'tcx> for FindLocalByTypeVisitor<'a, 'tcx> { - fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> { + type Map = Map<'tcx>; + + fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, Self::Map> { NestedVisitorMap::OnlyBodies(&self.hir_map) } diff --git a/src/librustc/infer/error_reporting/nice_region_error/find_anon_type.rs b/src/librustc/infer/error_reporting/nice_region_error/find_anon_type.rs index 6edf8f1e78755..8e2592b531885 100644 --- a/src/librustc/infer/error_reporting/nice_region_error/find_anon_type.rs +++ b/src/librustc/infer/error_reporting/nice_region_error/find_anon_type.rs @@ -1,8 +1,9 @@ -use crate::hir::intravisit::{self, NestedVisitorMap, Visitor}; +use crate::hir::map::Map; use crate::infer::error_reporting::nice_region_error::NiceRegionError; use crate::middle::resolve_lifetime as rl; use crate::ty::{self, Region, TyCtxt}; use rustc_hir as hir; +use rustc_hir::intravisit::{self, NestedVisitorMap, Visitor}; use rustc_hir::Node; impl<'a, 'tcx> NiceRegionError<'a, 'tcx> { @@ -90,7 +91,9 @@ struct FindNestedTypeVisitor<'tcx> { } impl Visitor<'tcx> for FindNestedTypeVisitor<'tcx> { - fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> { + type Map = Map<'tcx>; + + fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, Self::Map> { NestedVisitorMap::OnlyBodies(&self.tcx.hir()) } @@ -207,7 +210,9 @@ struct TyPathVisitor<'tcx> { } impl Visitor<'tcx> for TyPathVisitor<'tcx> { - fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> { + type Map = Map<'tcx>; + + fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, Map<'tcx>> { NestedVisitorMap::OnlyBodies(&self.tcx.hir()) } diff --git a/src/librustc/infer/lexical_region_resolve/mod.rs b/src/librustc/infer/lexical_region_resolve/mod.rs index e78382c0a3234..0bc49a2901505 100644 --- a/src/librustc/infer/lexical_region_resolve/mod.rs +++ b/src/librustc/infer/lexical_region_resolve/mod.rs @@ -204,9 +204,7 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> { // want to stop at the first constraint that makes a change. let mut any_changed = false; for member_constraint in &self.data.member_constraints { - if self.enforce_member_constraint(graph, member_constraint, var_values) { - any_changed = true; - } + any_changed |= self.enforce_member_constraint(graph, member_constraint, var_values); } any_changed } @@ -337,9 +335,7 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> { for index in live_indices.iter() { let constraint = constraints[index]; let (edge_changed, retain) = process_constraint(constraint); - if edge_changed { - changed = true; - } + changed |= edge_changed; if !retain { let changed = killed_indices.insert(index); debug_assert!(changed); diff --git a/src/librustc/lint/mod.rs b/src/librustc/lint/mod.rs index 2147ff1a24592..3f43800590353 100644 --- a/src/librustc/lint/mod.rs +++ b/src/librustc/lint/mod.rs @@ -21,11 +21,10 @@ pub use self::Level::*; pub use self::LintSource::*; -use rustc_data_structures::sync; - use crate::lint::builtin::BuiltinLintDiagnostics; use crate::ty::TyCtxt; use errors::{DiagnosticBuilder, DiagnosticId}; +use rustc_data_structures::sync; use rustc_hir as hir; use rustc_session::node_id::NodeMap; use rustc_session::{DiagnosticMessageId, Session}; @@ -109,13 +108,13 @@ macro_rules! late_lint_methods { fn check_where_predicate(a: &$hir hir::WherePredicate<$hir>); fn check_poly_trait_ref(a: &$hir hir::PolyTraitRef<$hir>, b: hir::TraitBoundModifier); fn check_fn( - a: $crate::hir::intravisit::FnKind<$hir>, + a: rustc_hir::intravisit::FnKind<$hir>, b: &$hir hir::FnDecl<$hir>, c: &$hir hir::Body<$hir>, d: Span, e: hir::HirId); fn check_fn_post( - a: $crate::hir::intravisit::FnKind<$hir>, + a: rustc_hir::intravisit::FnKind<$hir>, b: &$hir hir::FnDecl<$hir>, c: &$hir hir::Body<$hir>, d: Span, diff --git a/src/librustc/middle/weak_lang_items.rs b/src/librustc/middle/weak_lang_items.rs index e9e35b7617c89..89f385a51bc6a 100644 --- a/src/librustc/middle/weak_lang_items.rs +++ b/src/librustc/middle/weak_lang_items.rs @@ -3,13 +3,13 @@ use crate::middle::lang_items; use crate::session::config; -use crate::hir::intravisit; -use crate::hir::intravisit::{NestedVisitorMap, Visitor}; +use crate::hir::map::Map; use crate::ty::TyCtxt; use errors::struct_span_err; use rustc_data_structures::fx::FxHashSet; use rustc_hir as hir; use rustc_hir::def_id::DefId; +use rustc_hir::intravisit::{self, NestedVisitorMap, Visitor}; use rustc_span::symbol::{sym, Symbol}; use rustc_span::Span; use rustc_target::spec::PanicStrategy; @@ -136,7 +136,9 @@ impl<'a, 'tcx> Context<'a, 'tcx> { } impl<'a, 'tcx, 'v> Visitor<'v> for Context<'a, 'tcx> { - fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'v> { + type Map = Map<'v>; + + fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, Map<'v>> { NestedVisitorMap::None } diff --git a/src/librustc/traits/error_reporting.rs b/src/librustc/traits/error_reporting.rs index 00251d55706d7..5b8eb34ead1b3 100644 --- a/src/librustc/traits/error_reporting.rs +++ b/src/librustc/traits/error_reporting.rs @@ -2075,7 +2075,12 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { } let mut err = self.need_type_info_err(body_id, span, self_ty, ErrorCode::E0283); err.note(&format!("cannot resolve `{}`", predicate)); - if let (Ok(ref snippet), ObligationCauseCode::BindingObligation(ref def_id, _)) = + if let ObligationCauseCode::ItemObligation(def_id) = obligation.cause.code { + self.suggest_fully_qualified_path(&mut err, def_id, span, trait_ref.def_id()); + } else if let ( + Ok(ref snippet), + ObligationCauseCode::BindingObligation(ref def_id, _), + ) = (self.tcx.sess.source_map().span_to_snippet(span), &obligation.cause.code) { let generics = self.tcx.generics_of(*def_id); @@ -2173,6 +2178,30 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { err.emit(); } + fn suggest_fully_qualified_path( + &self, + err: &mut DiagnosticBuilder<'_>, + def_id: DefId, + span: Span, + trait_ref: DefId, + ) { + if let Some(assoc_item) = self.tcx.opt_associated_item(def_id) { + if let ty::AssocKind::Const | ty::AssocKind::Type = assoc_item.kind { + err.note(&format!( + "{}s cannot be accessed directly on a `trait`, they can only be \ + accessed through a specific `impl`", + assoc_item.kind.suggestion_descr(), + )); + err.span_suggestion( + span, + "use the fully qualified path to an implementation", + format!("::{}", self.tcx.def_path_str(trait_ref), assoc_item.ident), + Applicability::HasPlaceholders, + ); + } + } + } + /// Returns `true` if the trait predicate may apply for *some* assignment /// to the type parameters. fn predicate_can_apply( diff --git a/src/librustc/ty/layout.rs b/src/librustc/ty/layout.rs index 4b7304e7c1e8d..acaa4eec9410d 100644 --- a/src/librustc/ty/layout.rs +++ b/src/librustc/ty/layout.rs @@ -2507,17 +2507,21 @@ where let extra_args = if sig.abi == RustCall { assert!(!sig.c_variadic && extra_args.is_empty()); - match sig.inputs().last().unwrap().kind { - ty::Tuple(tupled_arguments) => { + if let Some(input) = sig.inputs().last() { + if let ty::Tuple(tupled_arguments) = input.kind { inputs = &sig.inputs()[0..sig.inputs().len() - 1]; tupled_arguments.iter().map(|k| k.expect_ty()).collect() - } - _ => { + } else { bug!( "argument to function with \"rust-call\" ABI \ - is not a tuple" + is not a tuple" ); } + } else { + bug!( + "argument to function with \"rust-call\" ABI \ + is not a tuple" + ); } } else { assert!(sig.c_variadic || extra_args.is_empty()); diff --git a/src/librustc/ty/util.rs b/src/librustc/ty/util.rs index aa93f35661a28..ddff8258c6d8f 100644 --- a/src/librustc/ty/util.rs +++ b/src/librustc/ty/util.rs @@ -533,8 +533,6 @@ impl<'tcx> TyCtxt<'tcx> { if self.is_mutable_static(def_id) { self.mk_mut_ptr(static_ty) - } else if self.is_foreign_item(def_id) { - self.mk_imm_ptr(static_ty) } else { self.mk_imm_ref(self.lifetimes.re_erased, static_ty) } diff --git a/src/librustc_ast_lowering/lib.rs b/src/librustc_ast_lowering/lib.rs index 8b79d9b4f478e..385153b62ce82 100644 --- a/src/librustc_ast_lowering/lib.rs +++ b/src/librustc_ast_lowering/lib.rs @@ -36,8 +36,8 @@ use rustc::arena::Arena; use rustc::dep_graph::DepGraph; -use rustc::hir::intravisit; -use rustc::hir::map::{DefKey, DefPathData, Definitions}; +use rustc::hir::map::definitions::{DefKey, DefPathData, Definitions}; +use rustc::hir::map::Map; use rustc::lint; use rustc::lint::builtin::{self, ELIDED_LIFETIMES_IN_PATHS}; use rustc::middle::cstore::CrateStore; @@ -51,6 +51,7 @@ use rustc_errors::{struct_span_err, Applicability}; use rustc_hir as hir; use rustc_hir::def::{DefKind, Namespace, PartialRes, PerNS, Res}; use rustc_hir::def_id::{DefId, DefIdMap, DefIndex, CRATE_DEF_INDEX}; +use rustc_hir::intravisit; use rustc_hir::{ConstArg, GenericArg, ParamName}; use rustc_index::vec::IndexVec; use rustc_session::config::nightly_options; @@ -1484,7 +1485,9 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { } impl<'r, 'a, 'v, 'hir> intravisit::Visitor<'v> for ImplTraitLifetimeCollector<'r, 'a, 'hir> { - fn nested_visit_map<'this>(&'this mut self) -> intravisit::NestedVisitorMap<'this, 'v> { + type Map = Map<'v>; + + fn nested_visit_map(&mut self) -> intravisit::NestedVisitorMap<'_, Self::Map> { intravisit::NestedVisitorMap::None } diff --git a/src/librustc_codegen_ssa/back/write.rs b/src/librustc_codegen_ssa/back/write.rs index 075374fd8a951..32ba2dd65a3fa 100644 --- a/src/librustc_codegen_ssa/back/write.rs +++ b/src/librustc_codegen_ssa/back/write.rs @@ -1679,7 +1679,6 @@ impl SharedEmitterMain { d.code(code); } handler.emit_diagnostic(&d); - handler.abort_if_errors_and_should_abort(); } Ok(SharedEmitterMessage::InlineAsmError(cookie, msg)) => { sess.span_err(ExpnId::from_u32(cookie).expn_data().call_site, &msg) diff --git a/src/librustc_driver/lib.rs b/src/librustc_driver/lib.rs index dece0a55edd18..8fbdf44de048d 100644 --- a/src/librustc_driver/lib.rs +++ b/src/librustc_driver/lib.rs @@ -1178,7 +1178,6 @@ pub fn report_ice(info: &panic::PanicInfo<'_>, bug_report_url: &str) { if !info.payload().is::() { let d = errors::Diagnostic::new(errors::Level::Bug, "unexpected panic"); handler.emit_diagnostic(&d); - handler.abort_if_errors_and_should_abort(); } let mut xs: Vec> = vec![ diff --git a/src/librustc_error_codes/error_codes/E0038.md b/src/librustc_error_codes/error_codes/E0038.md index 25e380b02e647..b2cc2a2273af2 100644 --- a/src/librustc_error_codes/error_codes/E0038.md +++ b/src/librustc_error_codes/error_codes/E0038.md @@ -136,7 +136,7 @@ type parameters, the number of monomorphized implementations the compiler generates does not grow drastically, since the compiler will only generate an implementation if the function is called with unparametrized substitutions (i.e., substitutions where none of the substituted types are themselves -parametrized). +parameterized). However, with trait objects we have to make a table containing _every_ object that implements the trait. Now, if it has type parameters, we need to add diff --git a/src/librustc_error_codes/error_codes/E0084.md b/src/librustc_error_codes/error_codes/E0084.md index 2388bc635d9f5..38ce9b43d0a2a 100644 --- a/src/librustc_error_codes/error_codes/E0084.md +++ b/src/librustc_error_codes/error_codes/E0084.md @@ -20,7 +20,7 @@ enum NightsWatch { } ``` -or you remove the integer represention of your enum: +or you remove the integer representation of your enum: ``` enum NightsWatch {} diff --git a/src/librustc_error_codes/error_codes/E0184.md b/src/librustc_error_codes/error_codes/E0184.md index e7fa8dfd8313e..4624f9e5b8531 100644 --- a/src/librustc_error_codes/error_codes/E0184.md +++ b/src/librustc_error_codes/error_codes/E0184.md @@ -1,6 +1,20 @@ -Explicitly implementing both Drop and Copy for a type is currently disallowed. -This feature can make some sense in theory, but the current implementation is -incorrect and can lead to memory unsafety (see [issue #20126][iss20126]), so -it has been disabled for now. +The `Copy` trait was implemented on a type with a `Drop` implementation. + +Erroneous code example: + +```compile_fail,E0184 +#[derive(Copy)] +struct Foo; // error! + +impl Drop for Foo { + fn drop(&mut self) { + } +} +``` + +Explicitly implementing both `Drop` and `Copy` trait on a type is currently +disallowed. This feature can make some sense in theory, but the current +implementation is incorrect and can lead to memory unsafety (see +[issue #20126][iss20126]), so it has been disabled for now. [iss20126]: https://github.com/rust-lang/rust/issues/20126 diff --git a/src/librustc_error_codes/error_codes/E0307.md b/src/librustc_error_codes/error_codes/E0307.md index 1779e5dbb30e7..c628d176836f9 100644 --- a/src/librustc_error_codes/error_codes/E0307.md +++ b/src/librustc_error_codes/error_codes/E0307.md @@ -36,7 +36,7 @@ impl Trait for Foo { } ``` -E0307 will be emitted by the compiler when using an invalid reciver type, +E0307 will be emitted by the compiler when using an invalid receiver type, like in the following example: ```compile_fail,E0307 diff --git a/src/librustc_error_codes/error_codes/E0373.md b/src/librustc_error_codes/error_codes/E0373.md index 47e3a48f03172..808363e6eb041 100644 --- a/src/librustc_error_codes/error_codes/E0373.md +++ b/src/librustc_error_codes/error_codes/E0373.md @@ -31,7 +31,7 @@ Since our new thread runs in parallel, the stack frame containing `x` and `y` may well have disappeared by the time we try to use them. Even if we call `thr.join()` within foo (which blocks until `thr` has completed, ensuring the stack frame won't disappear), we will not succeed: the compiler cannot prove -that this behaviour is safe, and so won't let us do it. +that this behavior is safe, and so won't let us do it. The solution to this problem is usually to switch to using a `move` closure. This approach moves (or copies, where possible) data into the closure, rather diff --git a/src/librustc_error_codes/error_codes/E0426.md b/src/librustc_error_codes/error_codes/E0426.md index 15e7fb0473835..275a83e606e40 100644 --- a/src/librustc_error_codes/error_codes/E0426.md +++ b/src/librustc_error_codes/error_codes/E0426.md @@ -8,7 +8,7 @@ loop { } ``` -Please verify you spelt or declare the label correctly. Example: +Please verify you spelled or declared the label correctly. Example: ``` 'a: loop { diff --git a/src/librustc_errors/lib.rs b/src/librustc_errors/lib.rs index 2279ed8595408..99a6d6f8ec2d4 100644 --- a/src/librustc_errors/lib.rs +++ b/src/librustc_errors/lib.rs @@ -278,7 +278,6 @@ struct HandlerInner { err_count: usize, deduplicated_err_count: usize, emitter: Box, - continue_after_error: bool, delayed_span_bugs: Vec, /// This set contains the `DiagnosticId` of all emitted diagnostics to avoid @@ -402,7 +401,6 @@ impl Handler { err_count: 0, deduplicated_err_count: 0, emitter, - continue_after_error: true, delayed_span_bugs: Vec::new(), taught_diagnostics: Default::default(), emitted_diagnostic_codes: Default::default(), @@ -412,10 +410,6 @@ impl Handler { } } - pub fn set_continue_after_error(&self, continue_after_error: bool) { - self.inner.borrow_mut().continue_after_error = continue_after_error; - } - // This is here to not allow mutation of flags; // as of this writing it's only used in tests in librustc. pub fn can_emit_warnings(&self) -> bool { @@ -672,10 +666,6 @@ impl Handler { self.inner.borrow_mut().abort_if_errors() } - pub fn abort_if_errors_and_should_abort(&self) { - self.inner.borrow_mut().abort_if_errors_and_should_abort() - } - /// `true` if we haven't taught a diagnostic with this code already. /// The caller must then teach the user about such a diagnostic. /// @@ -696,7 +686,6 @@ impl Handler { fn emit_diag_at_span(&self, mut diag: Diagnostic, sp: impl Into) { let mut inner = self.inner.borrow_mut(); inner.emit_diagnostic(diag.set_span(sp)); - inner.abort_if_errors_and_should_abort(); } pub fn emit_artifact_notification(&self, path: &Path, artifact_type: &str) { @@ -830,14 +819,6 @@ impl HandlerInner { self.has_errors() || !self.delayed_span_bugs.is_empty() } - fn abort_if_errors_and_should_abort(&mut self) { - self.emit_stashed_diagnostics(); - - if self.has_errors() && !self.continue_after_error { - FatalError.raise(); - } - } - fn abort_if_errors(&mut self) { self.emit_stashed_diagnostics(); @@ -853,7 +834,6 @@ impl HandlerInner { fn emit_diag_at_span(&mut self, mut diag: Diagnostic, sp: impl Into) { self.emit_diagnostic(diag.set_span(sp)); - self.abort_if_errors_and_should_abort(); } fn delay_span_bug(&mut self, sp: impl Into, msg: &str) { diff --git a/src/librustc/hir/intravisit.rs b/src/librustc_hir/intravisit.rs similarity index 96% rename from src/librustc/hir/intravisit.rs rename to src/librustc_hir/intravisit.rs index edecfd335fbb7..4664340b15fb7 100644 --- a/src/librustc/hir/intravisit.rs +++ b/src/librustc_hir/intravisit.rs @@ -31,21 +31,18 @@ //! This order consistency is required in a few places in rustc, for //! example generator inference, and possibly also HIR borrowck. -use crate::hir::map::Map; - -use rustc_hir::itemlikevisit::{ItemLikeVisitor, ParItemLikeVisitor}; -use rustc_hir::*; +use crate::hir::*; +use crate::hir_id::CRATE_HIR_ID; +use crate::itemlikevisit::{ItemLikeVisitor, ParItemLikeVisitor}; use rustc_span::Span; use syntax::ast::{Attribute, Ident, Label, Name}; +use syntax::walk_list; pub struct DeepVisitor<'v, V> { visitor: &'v mut V, } -impl<'v, 'hir, V> DeepVisitor<'v, V> -where - V: Visitor<'hir> + 'v, -{ +impl<'v, V> DeepVisitor<'v, V> { pub fn new(base: &'v mut V) -> Self { DeepVisitor { visitor: base } } @@ -122,6 +119,14 @@ impl<'a> FnKind<'a> { } } +/// An abstract representation of the HIR `rustc::hir::map::Map`. +pub trait Map<'hir> { + fn body(&self, id: BodyId) -> &'hir Body<'hir>; + fn item(&self, id: HirId) -> &'hir Item<'hir>; + fn trait_item(&self, id: TraitItemId) -> &'hir TraitItem<'hir>; + fn impl_item(&self, id: ImplItemId) -> &'hir ImplItem<'hir>; +} + /// Specifies what nested things a visitor wants to visit. The most /// common choice is `OnlyBodies`, which will cause the visitor to /// visit fn bodies for fns that it encounters, but skip over nested @@ -129,7 +134,7 @@ impl<'a> FnKind<'a> { /// /// See the comments on `ItemLikeVisitor` for more details on the overall /// visit strategy. -pub enum NestedVisitorMap<'this, 'tcx> { +pub enum NestedVisitorMap<'this, M> { /// Do not visit any nested things. When you add a new /// "non-nested" thing, you will want to audit such uses to see if /// they remain valid. @@ -146,20 +151,20 @@ pub enum NestedVisitorMap<'this, 'tcx> { /// to use `visit_all_item_likes()` as an outer loop, /// and to have the visitor that visits the contents of each item /// using this setting. - OnlyBodies(&'this Map<'tcx>), + OnlyBodies(&'this M), /// Visits all nested things, including item-likes. /// /// **This is an unusual choice.** It is used when you want to /// process everything within their lexical context. Typically you /// kick off the visit by doing `walk_krate()`. - All(&'this Map<'tcx>), + All(&'this M), } -impl<'this, 'tcx> NestedVisitorMap<'this, 'tcx> { +impl<'this, M> NestedVisitorMap<'this, M> { /// Returns the map to use for an "intra item-like" thing (if any). /// E.g., function body. - pub fn intra(self) -> Option<&'this Map<'tcx>> { + fn intra(self) -> Option<&'this M> { match self { NestedVisitorMap::None => None, NestedVisitorMap::OnlyBodies(map) => Some(map), @@ -169,7 +174,7 @@ impl<'this, 'tcx> NestedVisitorMap<'this, 'tcx> { /// Returns the map to use for an "item-like" thing (if any). /// E.g., item, impl-item. - pub fn inter(self) -> Option<&'this Map<'tcx>> { + fn inter(self) -> Option<&'this M> { match self { NestedVisitorMap::None => None, NestedVisitorMap::OnlyBodies(_) => None, @@ -195,6 +200,8 @@ impl<'this, 'tcx> NestedVisitorMap<'this, 'tcx> { /// to monitor future changes to `Visitor` in case a new method with a /// new default implementation gets introduced.) pub trait Visitor<'v>: Sized { + type Map: Map<'v>; + /////////////////////////////////////////////////////////////////////////// // Nested items. @@ -214,7 +221,7 @@ pub trait Visitor<'v>: Sized { /// `panic!()`. This way, if a new `visit_nested_XXX` variant is /// added in the future, we will see the panic in your code and /// fix it appropriately. - fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'v>; + fn nested_visit_map(&mut self) -> NestedVisitorMap<'_, Self::Map>; /// Invoked when a nested item is encountered. By default does /// nothing unless you override `nested_visit_map` to return other than @@ -226,10 +233,8 @@ pub trait Visitor<'v>: Sized { /// but cannot supply a `Map`; see `nested_visit_map` for advice. #[allow(unused_variables)] fn visit_nested_item(&mut self, id: ItemId) { - let opt_item = self.nested_visit_map().inter().map(|map| map.expect_item(id.id)); - if let Some(item) = opt_item { - self.visit_item(item); - } + let opt_item = self.nested_visit_map().inter().map(|map| map.item(id.id)); + walk_list!(self, visit_item, opt_item); } /// Like `visit_nested_item()`, but for trait items. See @@ -238,9 +243,7 @@ pub trait Visitor<'v>: Sized { #[allow(unused_variables)] fn visit_nested_trait_item(&mut self, id: TraitItemId) { let opt_item = self.nested_visit_map().inter().map(|map| map.trait_item(id)); - if let Some(item) = opt_item { - self.visit_trait_item(item); - } + walk_list!(self, visit_trait_item, opt_item); } /// Like `visit_nested_item()`, but for impl items. See @@ -249,9 +252,7 @@ pub trait Visitor<'v>: Sized { #[allow(unused_variables)] fn visit_nested_impl_item(&mut self, id: ImplItemId) { let opt_item = self.nested_visit_map().inter().map(|map| map.impl_item(id)); - if let Some(item) = opt_item { - self.visit_impl_item(item); - } + walk_list!(self, visit_impl_item, opt_item); } /// Invoked to visit the body of a function, method or closure. Like @@ -260,9 +261,7 @@ pub trait Visitor<'v>: Sized { /// the body. fn visit_nested_body(&mut self, id: BodyId) { let opt_body = self.nested_visit_map().intra().map(|map| map.body(id)); - if let Some(body) = opt_body { - self.visit_body(body); - } + walk_list!(self, visit_body, opt_body); } fn visit_param(&mut self, param: &'v Param<'v>) { @@ -496,21 +495,16 @@ pub fn walk_lifetime<'v, V: Visitor<'v>>(visitor: &mut V, lifetime: &'v Lifetime } } -pub fn walk_poly_trait_ref<'v, V>( +pub fn walk_poly_trait_ref<'v, V: Visitor<'v>>( visitor: &mut V, trait_ref: &'v PolyTraitRef<'v>, _modifier: TraitBoundModifier, -) where - V: Visitor<'v>, -{ +) { walk_list!(visitor, visit_generic_param, trait_ref.bound_generic_params); visitor.visit_trait_ref(&trait_ref.trait_ref); } -pub fn walk_trait_ref<'v, V>(visitor: &mut V, trait_ref: &'v TraitRef<'v>) -where - V: Visitor<'v>, -{ +pub fn walk_trait_ref<'v, V: Visitor<'v>>(visitor: &mut V, trait_ref: &'v TraitRef<'v>) { visitor.visit_id(trait_ref.hir_ref_id); visitor.visit_path(&trait_ref.path, trait_ref.hir_ref_id) } @@ -688,9 +682,7 @@ pub fn walk_qpath<'v, V: Visitor<'v>>( ) { match *qpath { QPath::Resolved(ref maybe_qself, ref path) => { - if let Some(ref qself) = *maybe_qself { - visitor.visit_ty(qself); - } + walk_list!(visitor, visit_ty, maybe_qself); visitor.visit_path(path, id) } QPath::TypeRelative(ref qself, ref segment) => { @@ -712,9 +704,7 @@ pub fn walk_path_segment<'v, V: Visitor<'v>>( segment: &'v PathSegment<'v>, ) { visitor.visit_ident(segment.ident); - if let Some(id) = segment.hir_id { - visitor.visit_id(id); - } + walk_list!(visitor, visit_id, segment.hir_id); if let Some(ref args) = segment.args { visitor.visit_generic_args(path_span, args); } @@ -1003,9 +993,7 @@ pub fn walk_struct_def<'v, V: Visitor<'v>>( visitor: &mut V, struct_definition: &'v VariantData<'v>, ) { - if let Some(ctor_hir_id) = struct_definition.ctor_hir_id() { - visitor.visit_id(ctor_hir_id); - } + walk_list!(visitor, visit_id, struct_definition.ctor_hir_id()); walk_list!(visitor, visit_struct_field, struct_definition.fields()); } @@ -1125,15 +1113,11 @@ pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr<'v>) visitor.visit_qpath(qpath, expression.hir_id, expression.span); } ExprKind::Break(ref destination, ref opt_expr) => { - if let Some(ref label) = destination.label { - visitor.visit_label(label); - } + walk_list!(visitor, visit_label, &destination.label); walk_list!(visitor, visit_expr, opt_expr); } ExprKind::Continue(ref destination) => { - if let Some(ref label) = destination.label { - visitor.visit_label(label); - } + walk_list!(visitor, visit_label, &destination.label); } ExprKind::Ret(ref optional_expression) => { walk_list!(visitor, visit_expr, optional_expression); diff --git a/src/librustc_hir/lib.rs b/src/librustc_hir/lib.rs index 8bf2e6299a9d3..66494d0fa736c 100644 --- a/src/librustc_hir/lib.rs +++ b/src/librustc_hir/lib.rs @@ -15,6 +15,7 @@ pub mod def; pub mod def_id; mod hir; pub mod hir_id; +pub mod intravisit; pub mod itemlikevisit; pub mod pat_util; pub mod print; diff --git a/src/librustc_incremental/assert_dep_graph.rs b/src/librustc_incremental/assert_dep_graph.rs index 64547845e74f1..9490128e32d6a 100644 --- a/src/librustc_incremental/assert_dep_graph.rs +++ b/src/librustc_incremental/assert_dep_graph.rs @@ -36,12 +36,13 @@ use graphviz as dot; use rustc::dep_graph::debug::{DepNodeFilter, EdgeFilter}; use rustc::dep_graph::{DepGraphQuery, DepKind, DepNode}; -use rustc::hir::intravisit::{self, NestedVisitorMap, Visitor}; +use rustc::hir::map::Map; use rustc::ty::TyCtxt; use rustc_data_structures::fx::FxHashSet; use rustc_data_structures::graph::implementation::{Direction, NodeIndex, INCOMING, OUTGOING}; use rustc_hir as hir; use rustc_hir::def_id::DefId; +use rustc_hir::intravisit::{self, NestedVisitorMap, Visitor}; use rustc_span::symbol::sym; use rustc_span::Span; use syntax::ast; @@ -159,7 +160,9 @@ impl IfThisChanged<'tcx> { } impl Visitor<'tcx> for IfThisChanged<'tcx> { - fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> { + type Map = Map<'tcx>; + + fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, Self::Map> { NestedVisitorMap::OnlyBodies(&self.tcx.hir()) } diff --git a/src/librustc_incremental/persist/dirty_clean.rs b/src/librustc_incremental/persist/dirty_clean.rs index 40dd4c88a02b2..ddfed53fa3349 100644 --- a/src/librustc_incremental/persist/dirty_clean.rs +++ b/src/librustc_incremental/persist/dirty_clean.rs @@ -14,12 +14,13 @@ //! the required condition is not met. use rustc::dep_graph::{label_strs, DepNode}; -use rustc::hir::intravisit; +use rustc::hir::map::Map; use rustc::ty::TyCtxt; use rustc_data_structures::fingerprint::Fingerprint; use rustc_data_structures::fx::FxHashSet; use rustc_hir as hir; use rustc_hir::def_id::DefId; +use rustc_hir::intravisit; use rustc_hir::itemlikevisit::ItemLikeVisitor; use rustc_hir::Node as HirNode; use rustc_hir::{ImplItemKind, ItemKind as HirItem, TraitItemKind}; @@ -547,7 +548,9 @@ impl FindAllAttrs<'tcx> { } impl intravisit::Visitor<'tcx> for FindAllAttrs<'tcx> { - fn nested_visit_map<'this>(&'this mut self) -> intravisit::NestedVisitorMap<'this, 'tcx> { + type Map = Map<'tcx>; + + fn nested_visit_map<'this>(&'this mut self) -> intravisit::NestedVisitorMap<'this, Self::Map> { intravisit::NestedVisitorMap::All(&self.tcx.hir()) } diff --git a/src/librustc_interface/passes.rs b/src/librustc_interface/passes.rs index 432f79bba030a..6e776e7d55424 100644 --- a/src/librustc_interface/passes.rs +++ b/src/librustc_interface/passes.rs @@ -54,7 +54,6 @@ use std::rc::Rc; use std::{env, fs, iter, mem}; pub fn parse<'a>(sess: &'a Session, input: &Input) -> PResult<'a, ast::Crate> { - sess.diagnostic().set_continue_after_error(sess.opts.debugging_opts.continue_parse_after_error); let krate = sess.time("parsing", || match input { Input::File(file) => parse_crate_from_file(file, &sess.parse_sess), Input::Str { input, name } => { @@ -62,8 +61,6 @@ pub fn parse<'a>(sess: &'a Session, input: &Input) -> PResult<'a, ast::Crate> { } })?; - sess.diagnostic().set_continue_after_error(true); - if sess.opts.debugging_opts.ast_json_noexpand { println!("{}", json::as_json(&krate)); } diff --git a/src/librustc_interface/tests.rs b/src/librustc_interface/tests.rs index 25ab7650b0ec2..c2e9c35fcd4a7 100644 --- a/src/librustc_interface/tests.rs +++ b/src/librustc_interface/tests.rs @@ -601,10 +601,6 @@ fn test_debugging_options_tracking_hash() { opts.debugging_opts.report_delayed_bugs = true; assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash()); - opts = reference.clone(); - opts.debugging_opts.continue_parse_after_error = true; - assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash()); - opts = reference.clone(); opts.debugging_opts.force_overflow_checks = Some(true); assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash()); diff --git a/src/librustc_lint/builtin.rs b/src/librustc_lint/builtin.rs index c2e20d5cf758e..23740af525971 100644 --- a/src/librustc_lint/builtin.rs +++ b/src/librustc_lint/builtin.rs @@ -25,6 +25,7 @@ use std::fmt::Write; use lint::{EarlyContext, EarlyLintPass, LateLintPass, LintPass}; use lint::{LateContext, LintArray, LintContext}; +use rustc::hir::map::Map; use rustc::lint; use rustc::lint::FutureIncompatibleInfo; use rustc::traits::misc::can_type_implement_copy; @@ -1088,12 +1089,14 @@ impl TypeAliasBounds { // bound. Let's see if this type does that. // We use a HIR visitor to walk the type. - use rustc::hir::intravisit::{self, Visitor}; + use rustc_hir::intravisit::{self, Visitor}; struct WalkAssocTypes<'a, 'db> { err: &'a mut DiagnosticBuilder<'db>, } impl<'a, 'db, 'v> Visitor<'v> for WalkAssocTypes<'a, 'db> { - fn nested_visit_map<'this>(&'this mut self) -> intravisit::NestedVisitorMap<'this, 'v> { + type Map = Map<'v>; + + fn nested_visit_map(&mut self) -> intravisit::NestedVisitorMap<'_, Self::Map> { intravisit::NestedVisitorMap::None } diff --git a/src/librustc_lint/late.rs b/src/librustc_lint/late.rs index 2e0a201fa98e9..a37e3be9ced92 100644 --- a/src/librustc_lint/late.rs +++ b/src/librustc_lint/late.rs @@ -14,8 +14,7 @@ //! upon. As the ast is traversed, this keeps track of the current lint level //! for all lint attributes. -use rustc::hir::intravisit as hir_visit; -use rustc::hir::intravisit::Visitor; +use rustc::hir::map::Map; use rustc::lint::LateContext; use rustc::lint::LintPass; use rustc::lint::{LateLintPass, LateLintPassObject}; @@ -23,6 +22,8 @@ use rustc::ty::{self, TyCtxt}; use rustc_data_structures::sync::{join, par_iter, ParallelIterator}; use rustc_hir as hir; use rustc_hir::def_id::{DefId, LOCAL_CRATE}; +use rustc_hir::intravisit as hir_visit; +use rustc_hir::intravisit::Visitor; use rustc_span::Span; use std::slice; use syntax::ast; @@ -86,10 +87,12 @@ impl<'a, 'tcx, T: LateLintPass<'a, 'tcx>> LateContextAndPass<'a, 'tcx, T> { impl<'a, 'tcx, T: LateLintPass<'a, 'tcx>> hir_visit::Visitor<'tcx> for LateContextAndPass<'a, 'tcx, T> { + type Map = Map<'tcx>; + /// Because lints are scoped lexically, we want to walk nested /// items in the context of the outer item, so enable /// deep-walking. - fn nested_visit_map<'this>(&'this mut self) -> hir_visit::NestedVisitorMap<'this, 'tcx> { + fn nested_visit_map<'this>(&'this mut self) -> hir_visit::NestedVisitorMap<'this, Self::Map> { hir_visit::NestedVisitorMap::All(&self.context.tcx.hir()) } diff --git a/src/librustc_lint/levels.rs b/src/librustc_lint/levels.rs index e060d6b551ca7..3d3e57fe2bae3 100644 --- a/src/librustc_lint/levels.rs +++ b/src/librustc_lint/levels.rs @@ -1,9 +1,10 @@ -use rustc::hir::intravisit; +use rustc::hir::map::Map; use rustc::lint::{LintLevelMap, LintLevelSets, LintLevelsBuilder, LintStore}; use rustc::ty::query::Providers; use rustc::ty::TyCtxt; use rustc_hir as hir; use rustc_hir::def_id::{CrateNum, LOCAL_CRATE}; +use rustc_hir::intravisit; use syntax::ast; pub use rustc_session::lint::{FutureIncompatibleInfo, Level, Lint, LintId}; @@ -50,7 +51,9 @@ impl LintLevelMapBuilder<'_, '_> { } impl<'tcx> intravisit::Visitor<'tcx> for LintLevelMapBuilder<'_, 'tcx> { - fn nested_visit_map<'this>(&'this mut self) -> intravisit::NestedVisitorMap<'this, 'tcx> { + type Map = Map<'tcx>; + + fn nested_visit_map<'this>(&'this mut self) -> intravisit::NestedVisitorMap<'this, Self::Map> { intravisit::NestedVisitorMap::All(&self.tcx.hir()) } diff --git a/src/librustc_lint/nonstandard_style.rs b/src/librustc_lint/nonstandard_style.rs index d50c048301042..13e57ecf1469c 100644 --- a/src/librustc_lint/nonstandard_style.rs +++ b/src/librustc_lint/nonstandard_style.rs @@ -1,10 +1,10 @@ use lint::{EarlyContext, LateContext, LintArray, LintContext}; use lint::{EarlyLintPass, LateLintPass, LintPass}; -use rustc::hir::intravisit::FnKind; use rustc::lint; use rustc::ty; use rustc_hir as hir; use rustc_hir::def::{DefKind, Res}; +use rustc_hir::intravisit::FnKind; use rustc_hir::{GenericParamKind, PatKind}; use rustc_span::symbol::sym; use rustc_span::{symbol::Ident, BytePos, Span}; diff --git a/src/librustc_metadata/rmeta/encoder.rs b/src/librustc_metadata/rmeta/encoder.rs index 92bfc51d9d5f0..952d3bb858276 100644 --- a/src/librustc_metadata/rmeta/encoder.rs +++ b/src/librustc_metadata/rmeta/encoder.rs @@ -2,6 +2,7 @@ use crate::rmeta::table::FixedSizeEncoding; use crate::rmeta::*; use rustc::hir::map::definitions::DefPathTable; +use rustc::hir::map::Map; use rustc::middle::cstore::{EncodedMetadata, ForeignModule, LinkagePreference, NativeLibrary}; use rustc::middle::dependency_format::Linkage; use rustc::middle::exported_symbols::{metadata_symbol_name, ExportedSymbol, SymbolExportLevel}; @@ -35,9 +36,8 @@ use syntax::ast; use syntax::attr; use syntax::expand::is_proc_macro_attr; -use rustc::hir::intravisit; -use rustc::hir::intravisit::{NestedVisitorMap, Visitor}; use rustc_hir as hir; +use rustc_hir::intravisit::{self, NestedVisitorMap, Visitor}; use rustc_hir::itemlikevisit::ItemLikeVisitor; struct EncodeContext<'tcx> { @@ -1520,7 +1520,9 @@ impl EncodeContext<'tcx> { // FIXME(eddyb) make metadata encoding walk over all definitions, instead of HIR. impl Visitor<'tcx> for EncodeContext<'tcx> { - fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> { + type Map = Map<'tcx>; + + fn nested_visit_map(&mut self) -> NestedVisitorMap<'_, Self::Map> { NestedVisitorMap::OnlyBodies(&self.tcx.hir()) } fn visit_expr(&mut self, ex: &'tcx hir::Expr<'tcx>) { diff --git a/src/librustc_mir/hair/pattern/check_match.rs b/src/librustc_mir/hair/pattern/check_match.rs index 07bb87f7b543f..ce0c081bc1608 100644 --- a/src/librustc_mir/hair/pattern/check_match.rs +++ b/src/librustc_mir/hair/pattern/check_match.rs @@ -4,7 +4,7 @@ use super::_match::{expand_pattern, is_useful, MatchCheckCtxt, Matrix, PatStack} use super::{PatCtxt, PatKind, PatternError}; -use rustc::hir::intravisit::{self, NestedVisitorMap, Visitor}; +use rustc::hir::map::Map; use rustc::lint; use rustc::session::Session; use rustc::ty::subst::{InternalSubsts, SubstsRef}; @@ -14,6 +14,7 @@ use rustc_errors::{error_code, struct_span_err, Applicability, DiagnosticBuilder use rustc_hir as hir; use rustc_hir::def::*; use rustc_hir::def_id::DefId; +use rustc_hir::intravisit::{self, NestedVisitorMap, Visitor}; use rustc_hir::{HirId, Pat}; use rustc_span::symbol::sym; use rustc_span::{MultiSpan, Span}; @@ -49,7 +50,9 @@ struct MatchVisitor<'a, 'tcx> { } impl<'tcx> Visitor<'tcx> for MatchVisitor<'_, 'tcx> { - fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> { + type Map = Map<'tcx>; + + fn nested_visit_map(&mut self) -> NestedVisitorMap<'_, Self::Map> { NestedVisitorMap::None } @@ -730,7 +733,9 @@ fn check_legality_of_bindings_in_at_patterns(cx: &MatchVisitor<'_, '_>, pat: &Pa } impl<'v> Visitor<'v> for AtBindingPatternVisitor<'_, '_, '_> { - fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'v> { + type Map = Map<'v>; + + fn nested_visit_map(&mut self) -> NestedVisitorMap<'_, Self::Map> { NestedVisitorMap::None } diff --git a/src/librustc_mir/lints.rs b/src/librustc_mir/lints.rs index fc7f2eb18b23a..a58d17569ef71 100644 --- a/src/librustc_mir/lints.rs +++ b/src/librustc_mir/lints.rs @@ -1,10 +1,10 @@ -use rustc::hir::intravisit::FnKind; use rustc::hir::map::blocks::FnLikeNode; use rustc::lint::builtin::UNCONDITIONAL_RECURSION; use rustc::mir::{self, Body, TerminatorKind}; use rustc::ty::subst::InternalSubsts; use rustc::ty::{self, AssocItem, AssocItemContainer, Instance, TyCtxt}; use rustc_hir::def_id::DefId; +use rustc_hir::intravisit::FnKind; use rustc_index::bit_set::BitSet; pub fn check(tcx: TyCtxt<'tcx>, body: &Body<'tcx>, def_id: DefId) { diff --git a/src/librustc_mir/transform/check_unsafety.rs b/src/librustc_mir/transform/check_unsafety.rs index d07e58b744771..02c54803842f0 100644 --- a/src/librustc_mir/transform/check_unsafety.rs +++ b/src/librustc_mir/transform/check_unsafety.rs @@ -1,4 +1,4 @@ -use rustc::hir::intravisit; +use rustc::hir::map::Map; use rustc::lint::builtin::{SAFE_PACKED_BORROWS, UNUSED_UNSAFE}; use rustc::mir::visit::{MutatingUseContext, PlaceContext, Visitor}; use rustc::mir::*; @@ -9,6 +9,7 @@ use rustc_data_structures::fx::FxHashSet; use rustc_errors::struct_span_err; use rustc_hir as hir; use rustc_hir::def_id::DefId; +use rustc_hir::intravisit; use rustc_hir::Node; use rustc_span::symbol::{sym, Symbol}; @@ -476,7 +477,9 @@ struct UnusedUnsafeVisitor<'a> { } impl<'a, 'tcx> intravisit::Visitor<'tcx> for UnusedUnsafeVisitor<'a> { - fn nested_visit_map<'this>(&'this mut self) -> intravisit::NestedVisitorMap<'this, 'tcx> { + type Map = Map<'tcx>; + + fn nested_visit_map<'this>(&'this mut self) -> intravisit::NestedVisitorMap<'this, Self::Map> { intravisit::NestedVisitorMap::None } diff --git a/src/librustc_mir/transform/mod.rs b/src/librustc_mir/transform/mod.rs index 82c31a09ce377..a2f76042ea72b 100644 --- a/src/librustc_mir/transform/mod.rs +++ b/src/librustc_mir/transform/mod.rs @@ -1,11 +1,12 @@ use crate::{build, shim}; -use rustc::hir::intravisit::{self, NestedVisitorMap, Visitor}; +use rustc::hir::map::Map; use rustc::mir::{BodyAndCache, ConstQualifs, MirPhase, Promoted}; use rustc::ty::query::Providers; use rustc::ty::steal::Steal; use rustc::ty::{InstanceDef, TyCtxt, TypeFoldable}; use rustc_hir as hir; use rustc_hir::def_id::{CrateNum, DefId, DefIdSet, LOCAL_CRATE}; +use rustc_hir::intravisit::{self, NestedVisitorMap, Visitor}; use rustc_index::vec::IndexVec; use rustc_span::Span; use std::borrow::Cow; @@ -85,7 +86,8 @@ fn mir_keys(tcx: TyCtxt<'_>, krate: CrateNum) -> &DefIdSet { } intravisit::walk_struct_def(self, v) } - fn nested_visit_map<'b>(&'b mut self) -> NestedVisitorMap<'b, 'tcx> { + type Map = Map<'tcx>; + fn nested_visit_map<'b>(&'b mut self) -> NestedVisitorMap<'b, Self::Map> { NestedVisitorMap::None } } diff --git a/src/librustc_passes/check_const.rs b/src/librustc_passes/check_const.rs index f6a9d1cace15f..47e6e5ccc24fe 100644 --- a/src/librustc_passes/check_const.rs +++ b/src/librustc_passes/check_const.rs @@ -8,7 +8,6 @@ //! through, but errors for structured control flow in a `const` should be emitted here. use errors::struct_span_err; -use rustc::hir::intravisit::{self, NestedVisitorMap, Visitor}; use rustc::hir::map::Map; use rustc::session::config::nightly_options; use rustc::ty::query::Providers; @@ -16,6 +15,7 @@ use rustc::ty::TyCtxt; use rustc_error_codes::*; use rustc_hir as hir; use rustc_hir::def_id::DefId; +use rustc_hir::intravisit::{self, NestedVisitorMap, Visitor}; use rustc_span::{sym, Span, Symbol}; use syntax::ast::Mutability; use syntax::feature_gate::feature_err; @@ -200,7 +200,9 @@ impl<'tcx> CheckConstVisitor<'tcx> { } impl<'tcx> Visitor<'tcx> for CheckConstVisitor<'tcx> { - fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> { + type Map = Map<'tcx>; + + fn nested_visit_map(&mut self) -> intravisit::NestedVisitorMap<'_, Self::Map> { NestedVisitorMap::OnlyBodies(&self.tcx.hir()) } diff --git a/src/librustc_passes/dead.rs b/src/librustc_passes/dead.rs index 0c435a1666363..f626a5f8cb0d1 100644 --- a/src/librustc_passes/dead.rs +++ b/src/librustc_passes/dead.rs @@ -2,7 +2,7 @@ // closely. The idea is that all reachable symbols are live, codes called // from live codes are live, and everything else is dead. -use rustc::hir::intravisit::{self, NestedVisitorMap, Visitor}; +use rustc::hir::map::Map; use rustc::lint; use rustc::middle::codegen_fn_attrs::CodegenFnAttrFlags; use rustc::middle::privacy; @@ -11,6 +11,7 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_hir as hir; use rustc_hir::def::{CtorOf, DefKind, Res}; use rustc_hir::def_id::{DefId, LOCAL_CRATE}; +use rustc_hir::intravisit::{self, NestedVisitorMap, Visitor}; use rustc_hir::itemlikevisit::ItemLikeVisitor; use rustc_hir::{Node, PatKind, TyKind}; @@ -210,7 +211,9 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> { } impl<'a, 'tcx> Visitor<'tcx> for MarkSymbolVisitor<'a, 'tcx> { - fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> { + type Map = Map<'tcx>; + + fn nested_visit_map(&mut self) -> intravisit::NestedVisitorMap<'_, Self::Map> { NestedVisitorMap::None } @@ -563,11 +566,13 @@ impl DeadVisitor<'tcx> { } impl Visitor<'tcx> for DeadVisitor<'tcx> { + type Map = Map<'tcx>; + /// Walk nested items in place so that we don't report dead-code /// on inner functions when the outer function is already getting /// an error. We could do this also by checking the parents, but /// this is how the code is setup and it seems harmless enough. - fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> { + fn nested_visit_map(&mut self) -> NestedVisitorMap<'_, Self::Map> { NestedVisitorMap::All(&self.tcx.hir()) } diff --git a/src/librustc_passes/hir_stats.rs b/src/librustc_passes/hir_stats.rs index 3eca602cf8603..b6ca2b3a595db 100644 --- a/src/librustc_passes/hir_stats.rs +++ b/src/librustc_passes/hir_stats.rs @@ -2,10 +2,11 @@ // pieces of AST and HIR. The resulting numbers are good approximations but not // completely accurate (some things might be counted twice, others missed). -use rustc::hir::intravisit as hir_visit; +use rustc::hir::map::Map; use rustc::util::common::to_readable_str; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_hir as hir; +use rustc_hir::intravisit as hir_visit; use rustc_hir::HirId; use rustc_span::Span; use syntax::ast::{self, AttrId, NodeId}; @@ -92,7 +93,9 @@ impl<'v> hir_visit::Visitor<'v> for StatCollector<'v> { hir_visit::walk_param(self, param) } - fn nested_visit_map<'this>(&'this mut self) -> hir_visit::NestedVisitorMap<'this, 'v> { + type Map = Map<'v>; + + fn nested_visit_map(&mut self) -> hir_visit::NestedVisitorMap<'_, Self::Map> { panic!("visit_nested_xxx must be manually implemented in this visitor") } diff --git a/src/librustc_passes/intrinsicck.rs b/src/librustc_passes/intrinsicck.rs index 2b9a692117cc7..ae8ac2e2c2e35 100644 --- a/src/librustc_passes/intrinsicck.rs +++ b/src/librustc_passes/intrinsicck.rs @@ -1,12 +1,12 @@ use errors::struct_span_err; +use rustc::hir::map::Map; use rustc::ty::layout::{LayoutError, Pointer, SizeSkeleton, VariantIdx}; use rustc::ty::query::Providers; use rustc::ty::{self, Ty, TyCtxt}; +use rustc_hir as hir; use rustc_hir::def::{DefKind, Res}; use rustc_hir::def_id::DefId; - -use rustc::hir::intravisit::{self, NestedVisitorMap, Visitor}; -use rustc_hir as hir; +use rustc_hir::intravisit::{self, NestedVisitorMap, Visitor}; use rustc_index::vec::Idx; use rustc_span::{sym, Span}; use rustc_target::spec::abi::Abi::RustIntrinsic; @@ -124,7 +124,9 @@ impl ExprVisitor<'tcx> { } impl Visitor<'tcx> for ItemVisitor<'tcx> { - fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> { + type Map = Map<'tcx>; + + fn nested_visit_map(&mut self) -> NestedVisitorMap<'_, Self::Map> { NestedVisitorMap::None } @@ -139,7 +141,9 @@ impl Visitor<'tcx> for ItemVisitor<'tcx> { } impl Visitor<'tcx> for ExprVisitor<'tcx> { - fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> { + type Map = Map<'tcx>; + + fn nested_visit_map(&mut self) -> NestedVisitorMap<'_, Self::Map> { NestedVisitorMap::None } diff --git a/src/librustc_passes/lib_features.rs b/src/librustc_passes/lib_features.rs index df56bcff81f6f..e7d490d6d8ddb 100644 --- a/src/librustc_passes/lib_features.rs +++ b/src/librustc_passes/lib_features.rs @@ -5,11 +5,12 @@ // (unlike lang features), which means we need to collect them instead. use errors::struct_span_err; -use rustc::hir::intravisit::{self, NestedVisitorMap, Visitor}; +use rustc::hir::map::Map; use rustc::middle::lib_features::LibFeatures; use rustc::ty::query::Providers; use rustc::ty::TyCtxt; use rustc_hir::def_id::LOCAL_CRATE; +use rustc_hir::intravisit::{self, NestedVisitorMap, Visitor}; use rustc_span::symbol::Symbol; use rustc_span::{sym, Span}; use syntax::ast::{Attribute, MetaItem, MetaItemKind}; @@ -113,7 +114,9 @@ impl LibFeatureCollector<'tcx> { } impl Visitor<'tcx> for LibFeatureCollector<'tcx> { - fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> { + type Map = Map<'tcx>; + + fn nested_visit_map(&mut self) -> NestedVisitorMap<'_, Self::Map> { NestedVisitorMap::All(&self.tcx.hir()) } diff --git a/src/librustc_passes/liveness.rs b/src/librustc_passes/liveness.rs index 3ae5e4f72b744..5c1bc4d1eaa87 100644 --- a/src/librustc_passes/liveness.rs +++ b/src/librustc_passes/liveness.rs @@ -97,7 +97,7 @@ use self::LiveNodeKind::*; use self::VarKind::*; use errors::Applicability; -use rustc::hir::intravisit::{self, FnKind, NestedVisitorMap, Visitor}; +use rustc::hir::map::Map; use rustc::lint; use rustc::ty::query::Providers; use rustc::ty::{self, TyCtxt}; @@ -105,6 +105,7 @@ use rustc_data_structures::fx::FxIndexMap; use rustc_hir as hir; use rustc_hir::def::*; use rustc_hir::def_id::DefId; +use rustc_hir::intravisit::{self, FnKind, NestedVisitorMap, Visitor}; use rustc_hir::{Expr, HirId, HirIdMap, HirIdSet, Node}; use rustc_span::symbol::sym; use rustc_span::Span; @@ -153,7 +154,9 @@ fn live_node_kind_to_string(lnk: LiveNodeKind, tcx: TyCtxt<'_>) -> String { } impl<'tcx> Visitor<'tcx> for IrMaps<'tcx> { - fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> { + type Map = Map<'tcx>; + + fn nested_visit_map(&mut self) -> NestedVisitorMap<'_, Self::Map> { NestedVisitorMap::OnlyBodies(&self.tcx.hir()) } @@ -1348,7 +1351,9 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> { // Checking for error conditions impl<'a, 'tcx> Visitor<'tcx> for Liveness<'a, 'tcx> { - fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> { + type Map = Map<'tcx>; + + fn nested_visit_map(&mut self) -> NestedVisitorMap<'_, Self::Map> { NestedVisitorMap::None } diff --git a/src/librustc_passes/loops.rs b/src/librustc_passes/loops.rs index 262f2382da3a4..333b39c3bb302 100644 --- a/src/librustc_passes/loops.rs +++ b/src/librustc_passes/loops.rs @@ -3,12 +3,12 @@ use Context::*; use rustc::session::Session; use errors::{struct_span_err, Applicability}; -use rustc::hir::intravisit::{self, NestedVisitorMap, Visitor}; use rustc::hir::map::Map; use rustc::ty::query::Providers; use rustc::ty::TyCtxt; use rustc_hir as hir; use rustc_hir::def_id::DefId; +use rustc_hir::intravisit::{self, NestedVisitorMap, Visitor}; use rustc_hir::{Destination, Movability, Node}; use rustc_span::Span; @@ -44,7 +44,9 @@ pub(crate) fn provide(providers: &mut Providers<'_>) { } impl<'a, 'hir> Visitor<'hir> for CheckLoopVisitor<'a, 'hir> { - fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'hir> { + type Map = Map<'hir>; + + fn nested_visit_map(&mut self) -> NestedVisitorMap<'_, Self::Map> { NestedVisitorMap::OnlyBodies(&self.hir_map) } diff --git a/src/librustc_passes/reachable.rs b/src/librustc_passes/reachable.rs index 9b529401049b0..5ce677f52cea6 100644 --- a/src/librustc_passes/reachable.rs +++ b/src/librustc_passes/reachable.rs @@ -5,8 +5,7 @@ // makes all other generics or inline functions that it references // reachable as well. -use rustc::hir::intravisit; -use rustc::hir::intravisit::{NestedVisitorMap, Visitor}; +use rustc::hir::map::Map; use rustc::middle::codegen_fn_attrs::{CodegenFnAttrFlags, CodegenFnAttrs}; use rustc::middle::privacy; use rustc::session::config; @@ -18,6 +17,8 @@ use rustc_hir as hir; use rustc_hir::def::{DefKind, Res}; use rustc_hir::def_id::LOCAL_CRATE; use rustc_hir::def_id::{CrateNum, DefId}; +use rustc_hir::intravisit; +use rustc_hir::intravisit::{NestedVisitorMap, Visitor}; use rustc_hir::itemlikevisit::ItemLikeVisitor; use rustc_hir::{HirIdSet, Node}; use rustc_target::spec::abi::Abi; @@ -82,7 +83,9 @@ struct ReachableContext<'a, 'tcx> { } impl<'a, 'tcx> Visitor<'tcx> for ReachableContext<'a, 'tcx> { - fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> { + type Map = Map<'tcx>; + + fn nested_visit_map(&mut self) -> NestedVisitorMap<'_, Self::Map> { NestedVisitorMap::None } diff --git a/src/librustc_passes/region.rs b/src/librustc_passes/region.rs index 75c74c4f923c2..e79ca5c78d6d6 100644 --- a/src/librustc_passes/region.rs +++ b/src/librustc_passes/region.rs @@ -6,13 +6,14 @@ //! //! [rustc guide]: https://rust-lang.github.io/rustc-guide/mir/borrowck.html -use rustc::hir::intravisit::{self, NestedVisitorMap, Visitor}; +use rustc::hir::map::Map; use rustc::middle::region::*; use rustc::ty::query::Providers; use rustc::ty::TyCtxt; use rustc_data_structures::fx::FxHashSet; use rustc_hir as hir; use rustc_hir::def_id::DefId; +use rustc_hir::intravisit::{self, NestedVisitorMap, Visitor}; use rustc_hir::{Arm, Block, Expr, Local, Node, Pat, PatKind, Stmt}; use rustc_index::vec::Idx; use rustc_span::source_map; @@ -695,7 +696,9 @@ impl<'tcx> RegionResolutionVisitor<'tcx> { } impl<'tcx> Visitor<'tcx> for RegionResolutionVisitor<'tcx> { - fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> { + type Map = Map<'tcx>; + + fn nested_visit_map(&mut self) -> NestedVisitorMap<'_, Self::Map> { NestedVisitorMap::None } diff --git a/src/librustc_passes/stability.rs b/src/librustc_passes/stability.rs index 33c985bd66b18..be098543a2ff2 100644 --- a/src/librustc_passes/stability.rs +++ b/src/librustc_passes/stability.rs @@ -2,7 +2,7 @@ //! propagating default levels lexically from parent to children ast nodes. use errors::struct_span_err; -use rustc::hir::intravisit::{self, NestedVisitorMap, Visitor}; +use rustc::hir::map::Map; use rustc::lint; use rustc::middle::privacy::AccessLevels; use rustc::middle::stability::{DeprecationEntry, Index}; @@ -14,6 +14,7 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_hir as hir; use rustc_hir::def::{DefKind, Res}; use rustc_hir::def_id::{DefId, CRATE_DEF_INDEX, LOCAL_CRATE}; +use rustc_hir::intravisit::{self, NestedVisitorMap, Visitor}; use rustc_hir::{Generics, HirId, Item, StructField, Variant}; use rustc_span::symbol::{sym, Symbol}; use rustc_span::Span; @@ -204,7 +205,9 @@ impl<'a, 'tcx> Visitor<'tcx> for Annotator<'a, 'tcx> { /// Because stability levels are scoped lexically, we want to walk /// nested items in the context of the outer item, so enable /// deep-walking. - fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> { + type Map = Map<'tcx>; + + fn nested_visit_map(&mut self) -> NestedVisitorMap<'_, Self::Map> { NestedVisitorMap::All(&self.tcx.hir()) } @@ -293,7 +296,9 @@ impl<'a, 'tcx> MissingStabilityAnnotations<'a, 'tcx> { } impl<'a, 'tcx> Visitor<'tcx> for MissingStabilityAnnotations<'a, 'tcx> { - fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> { + type Map = Map<'tcx>; + + fn nested_visit_map(&mut self) -> NestedVisitorMap<'_, Self::Map> { NestedVisitorMap::OnlyBodies(&self.tcx.hir()) } @@ -429,10 +434,12 @@ struct Checker<'tcx> { } impl Visitor<'tcx> for Checker<'tcx> { + type Map = Map<'tcx>; + /// Because stability levels are scoped lexically, we want to walk /// nested items in the context of the outer item, so enable /// deep-walking. - fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> { + fn nested_visit_map(&mut self) -> NestedVisitorMap<'_, Self::Map> { NestedVisitorMap::OnlyBodies(&self.tcx.hir()) } diff --git a/src/librustc_privacy/lib.rs b/src/librustc_privacy/lib.rs index 17e56129247f3..a96d59340237d 100644 --- a/src/librustc_privacy/lib.rs +++ b/src/librustc_privacy/lib.rs @@ -4,7 +4,7 @@ #![recursion_limit = "256"] use rustc::bug; -use rustc::hir::intravisit::{self, DeepVisitor, NestedVisitorMap, Visitor}; +use rustc::hir::map::Map; use rustc::lint; use rustc::middle::privacy::{AccessLevel, AccessLevels}; use rustc::ty::fold::TypeVisitor; @@ -16,6 +16,7 @@ use rustc_errors::struct_span_err; use rustc_hir as hir; use rustc_hir::def::{DefKind, Res}; use rustc_hir::def_id::{CrateNum, DefId, CRATE_DEF_INDEX, LOCAL_CRATE}; +use rustc_hir::intravisit::{self, DeepVisitor, NestedVisitorMap, Visitor}; use rustc_hir::{AssocItemKind, HirIdSet, Node, PatKind}; use rustc_span::hygiene::Transparency; use rustc_span::symbol::{kw, sym}; @@ -372,7 +373,9 @@ struct PubRestrictedVisitor<'tcx> { } impl Visitor<'tcx> for PubRestrictedVisitor<'tcx> { - fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> { + type Map = Map<'tcx>; + + fn nested_visit_map(&mut self) -> NestedVisitorMap<'_, Self::Map> { NestedVisitorMap::All(&self.tcx.hir()) } fn visit_vis(&mut self, vis: &'tcx hir::Visibility<'tcx>) { @@ -670,9 +673,11 @@ impl EmbargoVisitor<'tcx> { } impl Visitor<'tcx> for EmbargoVisitor<'tcx> { + type Map = Map<'tcx>; + /// We want to visit items in the context of their containing /// module and so forth, so supply a crate for doing a deep walk. - fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> { + fn nested_visit_map(&mut self) -> NestedVisitorMap<'_, Self::Map> { NestedVisitorMap::All(&self.tcx.hir()) } @@ -1039,9 +1044,11 @@ impl<'a, 'tcx> NamePrivacyVisitor<'a, 'tcx> { } impl<'a, 'tcx> Visitor<'tcx> for NamePrivacyVisitor<'a, 'tcx> { + type Map = Map<'tcx>; + /// We want to visit items in the context of their containing /// module and so forth, so supply a crate for doing a deep walk. - fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> { + fn nested_visit_map(&mut self) -> NestedVisitorMap<'_, Self::Map> { NestedVisitorMap::All(&self.tcx.hir()) } @@ -1179,9 +1186,11 @@ impl<'a, 'tcx> TypePrivacyVisitor<'a, 'tcx> { } impl<'a, 'tcx> Visitor<'tcx> for TypePrivacyVisitor<'a, 'tcx> { + type Map = Map<'tcx>; + /// We want to visit items in the context of their containing /// module and so forth, so supply a crate for doing a deep walk. - fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> { + fn nested_visit_map(&mut self) -> NestedVisitorMap<'_, Self::Map> { NestedVisitorMap::All(&self.tcx.hir()) } @@ -1437,7 +1446,9 @@ impl<'a, 'tcx> ObsoleteVisiblePrivateTypesVisitor<'a, 'tcx> { } impl<'a, 'b, 'tcx, 'v> Visitor<'v> for ObsoleteCheckTypeForPrivatenessVisitor<'a, 'b, 'tcx> { - fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'v> { + type Map = Map<'v>; + + fn nested_visit_map(&mut self) -> NestedVisitorMap<'_, Self::Map> { NestedVisitorMap::None } @@ -1463,9 +1474,11 @@ impl<'a, 'b, 'tcx, 'v> Visitor<'v> for ObsoleteCheckTypeForPrivatenessVisitor<'a } impl<'a, 'tcx> Visitor<'tcx> for ObsoleteVisiblePrivateTypesVisitor<'a, 'tcx> { + type Map = Map<'tcx>; + /// We want to visit items in the context of their containing /// module and so forth, so supply a crate for doing a deep walk. - fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> { + fn nested_visit_map(&mut self) -> NestedVisitorMap<'_, Self::Map> { NestedVisitorMap::All(&self.tcx.hir()) } @@ -1906,7 +1919,9 @@ impl<'a, 'tcx> PrivateItemsInPublicInterfacesVisitor<'a, 'tcx> { } impl<'a, 'tcx> Visitor<'tcx> for PrivateItemsInPublicInterfacesVisitor<'a, 'tcx> { - fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> { + type Map = Map<'tcx>; + + fn nested_visit_map(&mut self) -> NestedVisitorMap<'_, Self::Map> { NestedVisitorMap::OnlyBodies(&self.tcx.hir()) } diff --git a/src/librustc_resolve/lifetimes.rs b/src/librustc_resolve/lifetimes.rs index 15858f7d8abc8..469e1b9aa6207 100644 --- a/src/librustc_resolve/lifetimes.rs +++ b/src/librustc_resolve/lifetimes.rs @@ -6,7 +6,6 @@ //! way. Therefore, we break lifetime name resolution into a separate pass. use errors::{pluralize, struct_span_err, Applicability, DiagnosticBuilder}; -use rustc::hir::intravisit::{self, NestedVisitorMap, Visitor}; use rustc::hir::map::Map; use rustc::lint; use rustc::middle::resolve_lifetime::*; @@ -17,6 +16,7 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_hir as hir; use rustc_hir::def::{DefKind, Res}; use rustc_hir::def_id::{CrateNum, DefId, DefIdMap, LocalDefId, LOCAL_CRATE}; +use rustc_hir::intravisit::{self, NestedVisitorMap, Visitor}; use rustc_hir::{GenericArg, GenericParam, LifetimeName, Node, ParamName, QPath}; use rustc_hir::{GenericParamKind, HirIdMap, HirIdSet, LifetimeParamKind}; use rustc_span::symbol::{kw, sym}; @@ -361,7 +361,9 @@ fn sub_items_have_self_param(node: &hir::ItemKind<'_>) -> bool { } impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> { - fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> { + type Map = Map<'tcx>; + + fn nested_visit_map(&mut self) -> NestedVisitorMap<'_, Self::Map> { NestedVisitorMap::All(&self.tcx.hir()) } @@ -1086,7 +1088,9 @@ fn extract_labels(ctxt: &mut LifetimeContext<'_, '_>, body: &hir::Body<'_>) { gather.visit_body(body); impl<'v, 'a, 'tcx> Visitor<'v> for GatherLabels<'a, 'tcx> { - fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'v> { + type Map = Map<'v>; + + fn nested_visit_map(&mut self) -> NestedVisitorMap<'_, Self::Map> { NestedVisitorMap::None } @@ -2129,7 +2133,9 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> { } impl<'a> Visitor<'a> for SelfVisitor<'a> { - fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'a> { + type Map = Map<'a>; + + fn nested_visit_map(&mut self) -> NestedVisitorMap<'_, Self::Map> { NestedVisitorMap::None } @@ -2217,7 +2223,9 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> { } impl<'v, 'a> Visitor<'v> for GatherLifetimes<'a> { - fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'v> { + type Map = Map<'v>; + + fn nested_visit_map(&mut self) -> NestedVisitorMap<'_, Self::Map> { NestedVisitorMap::None } @@ -2802,7 +2810,9 @@ fn insert_late_bound_lifetimes( } impl<'v> Visitor<'v> for ConstrainedCollector { - fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'v> { + type Map = Map<'v>; + + fn nested_visit_map(&mut self) -> NestedVisitorMap<'_, Self::Map> { NestedVisitorMap::None } @@ -2843,7 +2853,9 @@ fn insert_late_bound_lifetimes( } impl<'v> Visitor<'v> for AllCollector { - fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'v> { + type Map = Map<'v>; + + fn nested_visit_map(&mut self) -> NestedVisitorMap<'_, Self::Map> { NestedVisitorMap::None } diff --git a/src/librustc_session/options.rs b/src/librustc_session/options.rs index 656c1b019b2e2..4b5736adc17c3 100644 --- a/src/librustc_session/options.rs +++ b/src/librustc_session/options.rs @@ -772,8 +772,6 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options, "set the current terminal width"), panic_abort_tests: bool = (false, parse_bool, [TRACKED], "support compiling tests with panic=abort"), - continue_parse_after_error: bool = (false, parse_bool, [TRACKED], - "attempt to recover from parse errors (experimental)"), dep_tasks: bool = (false, parse_bool, [UNTRACKED], "print tasks that execute and the color their dep node gets (requires debug build)"), incremental: Option = (None, parse_opt_string, [UNTRACKED], diff --git a/src/librustc_traits/lowering/mod.rs b/src/librustc_traits/lowering/mod.rs index 47009ac41232f..4b4fa4b7147fc 100644 --- a/src/librustc_traits/lowering/mod.rs +++ b/src/librustc_traits/lowering/mod.rs @@ -1,7 +1,7 @@ mod environment; -use rustc::hir::intravisit::{self, NestedVisitorMap, Visitor}; use rustc::hir::map::definitions::DefPathData; +use rustc::hir::map::Map; use rustc::traits::{ Clause, Clauses, DomainGoal, FromEnv, GoalKind, PolyDomainGoal, ProgramClause, ProgramClauseCategory, WellFormed, WhereClause, @@ -12,6 +12,7 @@ use rustc::ty::{self, List, TyCtxt}; use rustc_hir as hir; use rustc_hir::def::DefKind; use rustc_hir::def_id::DefId; +use rustc_hir::intravisit::{self, NestedVisitorMap, Visitor}; use rustc_span::symbol::sym; use syntax::ast; @@ -600,7 +601,9 @@ impl ClauseDumper<'tcx> { } impl Visitor<'tcx> for ClauseDumper<'tcx> { - fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> { + type Map = Map<'tcx>; + + fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, Self::Map> { NestedVisitorMap::OnlyBodies(&self.tcx.hir()) } diff --git a/src/librustc_typeck/astconv.rs b/src/librustc_typeck/astconv.rs index 4bacf9349379e..0233b68a7ce21 100644 --- a/src/librustc_typeck/astconv.rs +++ b/src/librustc_typeck/astconv.rs @@ -10,7 +10,6 @@ use crate::namespace::Namespace; use crate::require_c_abi_if_c_variadic; use crate::util::common::ErrorReported; use errors::{struct_span_err, Applicability, DiagnosticId}; -use rustc::hir::intravisit::Visitor; use rustc::lint::builtin::AMBIGUOUS_ASSOCIATED_ITEMS; use rustc::traits; use rustc::traits::astconv_object_safety_violations; @@ -23,6 +22,7 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_hir as hir; use rustc_hir::def::{CtorOf, DefKind, Res}; use rustc_hir::def_id::DefId; +use rustc_hir::intravisit::Visitor; use rustc_hir::print; use rustc_hir::{ExprKind, GenericArg, GenericArgs}; use rustc_span::symbol::sym; diff --git a/src/librustc_typeck/check/compare_method.rs b/src/librustc_typeck/check/compare_method.rs index e1f2950469b86..449c2e90ff202 100644 --- a/src/librustc_typeck/check/compare_method.rs +++ b/src/librustc_typeck/check/compare_method.rs @@ -1,5 +1,5 @@ use errors::{pluralize, struct_span_err, Applicability, DiagnosticId}; -use rustc::hir::intravisit; +use rustc::hir::map::Map; use rustc::infer::{self, InferOk}; use rustc::traits::{self, ObligationCause, ObligationCauseCode, Reveal}; use rustc::ty::error::{ExpectedFound, TypeError}; @@ -9,6 +9,7 @@ use rustc::ty::{self, GenericParamDefKind, TyCtxt}; use rustc::util::common::ErrorReported; use rustc_hir as hir; use rustc_hir::def::{DefKind, Res}; +use rustc_hir::intravisit; use rustc_hir::{GenericParamKind, ImplItemKind, TraitItemKind}; use rustc_span::Span; @@ -890,9 +891,10 @@ fn compare_synthetic_generics<'tcx>( } } } - fn nested_visit_map<'this>( - &'this mut self, - ) -> intravisit::NestedVisitorMap<'this, 'v> + type Map = Map<'v>; + fn nested_visit_map( + &mut self, + ) -> intravisit::NestedVisitorMap<'_, Self::Map> { intravisit::NestedVisitorMap::None } diff --git a/src/librustc_typeck/check/generator_interior.rs b/src/librustc_typeck/check/generator_interior.rs index f004d04fdfeba..9d8805f225d7e 100644 --- a/src/librustc_typeck/check/generator_interior.rs +++ b/src/librustc_typeck/check/generator_interior.rs @@ -4,13 +4,14 @@ //! types computed here. use super::FnCtxt; -use rustc::hir::intravisit::{self, NestedVisitorMap, Visitor}; +use rustc::hir::map::Map; use rustc::middle::region::{self, YieldData}; use rustc::ty::{self, Ty}; use rustc_data_structures::fx::FxHashMap; use rustc_hir as hir; use rustc_hir::def::{CtorKind, DefKind, Res}; use rustc_hir::def_id::DefId; +use rustc_hir::intravisit::{self, NestedVisitorMap, Visitor}; use rustc_hir::{Expr, ExprKind, Pat, PatKind}; use rustc_span::Span; @@ -193,7 +194,9 @@ pub fn resolve_interior<'a, 'tcx>( // librustc/middle/region.rs since `expr_count` is compared against the results // there. impl<'a, 'tcx> Visitor<'tcx> for InteriorVisitor<'a, 'tcx> { - fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> { + type Map = Map<'tcx>; + + fn nested_visit_map(&mut self) -> NestedVisitorMap<'_, Self::Map> { NestedVisitorMap::None } diff --git a/src/librustc_typeck/check/method/suggest.rs b/src/librustc_typeck/check/method/suggest.rs index 8bf9f488e5977..4f55d9ab70ede 100644 --- a/src/librustc_typeck/check/method/suggest.rs +++ b/src/librustc_typeck/check/method/suggest.rs @@ -5,8 +5,8 @@ use crate::check::FnCtxt; use crate::middle::lang_items::FnOnceTraitLangItem; use crate::namespace::Namespace; use errors::{pluralize, struct_span_err, Applicability, DiagnosticBuilder}; -use rustc::hir::intravisit; use rustc::hir::map as hir_map; +use rustc::hir::map::Map; use rustc::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind}; use rustc::traits::Obligation; use rustc::ty::print::with_crate_prefix; @@ -15,6 +15,7 @@ use rustc_data_structures::fx::FxHashSet; use rustc_hir as hir; use rustc_hir::def::{DefKind, Res}; use rustc_hir::def_id::{DefId, CRATE_DEF_INDEX, LOCAL_CRATE}; +use rustc_hir::intravisit; use rustc_hir::{ExprKind, Node, QPath}; use rustc_span::{source_map, FileName, Span}; use syntax::ast; @@ -1124,7 +1125,9 @@ impl intravisit::Visitor<'tcx> for UsePlacementFinder<'tcx> { } } - fn nested_visit_map<'this>(&'this mut self) -> intravisit::NestedVisitorMap<'this, 'tcx> { + type Map = Map<'tcx>; + + fn nested_visit_map(&mut self) -> intravisit::NestedVisitorMap<'_, Self::Map> { intravisit::NestedVisitorMap::None } } diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index e6fbae09ba1a0..f10edc1a468b4 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -91,7 +91,7 @@ use crate::astconv::{AstConv, PathSeg}; use crate::middle::lang_items; use crate::namespace::Namespace; use errors::{pluralize, struct_span_err, Applicability, DiagnosticBuilder, DiagnosticId}; -use rustc::hir::intravisit::{self, NestedVisitorMap, Visitor}; +use rustc::hir::map::Map; use rustc::infer::canonical::{Canonical, OriginalQueryValues, QueryResponse}; use rustc::infer::error_reporting::TypeAnnotationNeeded::E0282; use rustc::infer::opaque_types::OpaqueTypeDecl; @@ -118,6 +118,7 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_hir as hir; use rustc_hir::def::{CtorOf, DefKind, Res}; use rustc_hir::def_id::{CrateNum, DefId, DefIdMap, DefIdSet, LOCAL_CRATE}; +use rustc_hir::intravisit::{self, NestedVisitorMap, Visitor}; use rustc_hir::itemlikevisit::ItemLikeVisitor; use rustc_hir::{ExprKind, GenericArg, HirIdMap, ItemKind, Node, PatKind, QPath}; use rustc_index::vec::Idx; @@ -1170,7 +1171,9 @@ impl<'a, 'tcx> GatherLocalsVisitor<'a, 'tcx> { } impl<'a, 'tcx> Visitor<'tcx> for GatherLocalsVisitor<'a, 'tcx> { - fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> { + type Map = Map<'tcx>; + + fn nested_visit_map(&mut self) -> NestedVisitorMap<'_, Self::Map> { NestedVisitorMap::None } diff --git a/src/librustc_typeck/check/op.rs b/src/librustc_typeck/check/op.rs index 3dd1122085939..d746b97472735 100644 --- a/src/librustc_typeck/check/op.rs +++ b/src/librustc_typeck/check/op.rs @@ -330,7 +330,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { Some("std::ops::Add"), ), hir::BinOpKind::Sub => ( - format!("cannot substract `{}` from `{}`", rhs_ty, lhs_ty), + format!("cannot subtract `{}` from `{}`", rhs_ty, lhs_ty), Some("std::ops::Sub"), ), hir::BinOpKind::Mul => ( diff --git a/src/librustc_typeck/check/regionck.rs b/src/librustc_typeck/check/regionck.rs index 3b2f3d17e8da6..967741092febe 100644 --- a/src/librustc_typeck/check/regionck.rs +++ b/src/librustc_typeck/check/regionck.rs @@ -76,7 +76,7 @@ use crate::check::dropck; use crate::check::FnCtxt; use crate::mem_categorization as mc; use crate::middle::region; -use rustc::hir::intravisit::{self, NestedVisitorMap, Visitor}; +use rustc::hir::map::Map; use rustc::infer::outlives::env::OutlivesEnvironment; use rustc::infer::{self, RegionObligation, SuppressRegionErrors}; use rustc::ty::adjustment; @@ -84,6 +84,7 @@ use rustc::ty::subst::{GenericArgKind, SubstsRef}; use rustc::ty::{self, Ty}; use rustc_hir as hir; use rustc_hir::def_id::DefId; +use rustc_hir::intravisit::{self, NestedVisitorMap, Visitor}; use rustc_hir::PatKind; use rustc_span::Span; use std::mem; @@ -414,7 +415,9 @@ impl<'a, 'tcx> Visitor<'tcx> for RegionCtxt<'a, 'tcx> { // hierarchy, and in particular the relationships between free // regions, until regionck, as described in #3238. - fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> { + type Map = Map<'tcx>; + + fn nested_visit_map(&mut self) -> NestedVisitorMap<'_, Self::Map> { NestedVisitorMap::None } diff --git a/src/librustc_typeck/check/upvar.rs b/src/librustc_typeck/check/upvar.rs index be912b6bcafc0..9b4bd6d78ff28 100644 --- a/src/librustc_typeck/check/upvar.rs +++ b/src/librustc_typeck/check/upvar.rs @@ -35,13 +35,14 @@ use super::FnCtxt; use crate::expr_use_visitor as euv; use crate::mem_categorization as mc; use crate::mem_categorization::PlaceBase; -use rustc::hir::intravisit::{self, NestedVisitorMap, Visitor}; +use rustc::hir::map::Map; use rustc::infer::UpvarRegion; use rustc::ty::{self, Ty, TyCtxt, UpvarSubsts}; use rustc_data_structures::fx::FxIndexMap; use rustc_hir as hir; use rustc_hir::def_id::DefId; use rustc_hir::def_id::LocalDefId; +use rustc_hir::intravisit::{self, NestedVisitorMap, Visitor}; use rustc_span::Span; use syntax::ast; @@ -59,7 +60,9 @@ struct InferBorrowKindVisitor<'a, 'tcx> { } impl<'a, 'tcx> Visitor<'tcx> for InferBorrowKindVisitor<'a, 'tcx> { - fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> { + type Map = Map<'tcx>; + + fn nested_visit_map(&mut self) -> NestedVisitorMap<'_, Self::Map> { NestedVisitorMap::None } diff --git a/src/librustc_typeck/check/writeback.rs b/src/librustc_typeck/check/writeback.rs index ad9a2f2e2b45e..b4798fb67f80f 100644 --- a/src/librustc_typeck/check/writeback.rs +++ b/src/librustc_typeck/check/writeback.rs @@ -4,7 +4,7 @@ use crate::check::FnCtxt; -use rustc::hir::intravisit::{self, NestedVisitorMap, Visitor}; +use rustc::hir::map::Map; use rustc::infer::error_reporting::TypeAnnotationNeeded::E0282; use rustc::infer::InferCtxt; use rustc::ty::adjustment::{Adjust, Adjustment, PointerCast}; @@ -13,6 +13,7 @@ use rustc::ty::{self, Ty, TyCtxt}; use rustc_data_structures::sync::Lrc; use rustc_hir as hir; use rustc_hir::def_id::{DefId, DefIdSet, DefIndex}; +use rustc_hir::intravisit::{self, NestedVisitorMap, Visitor}; use rustc_span::symbol::sym; use rustc_span::Span; @@ -242,7 +243,9 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> { // traffic in node-ids or update tables in the type context etc. impl<'cx, 'tcx> Visitor<'tcx> for WritebackCx<'cx, 'tcx> { - fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> { + type Map = Map<'tcx>; + + fn nested_visit_map(&mut self) -> NestedVisitorMap<'_, Self::Map> { NestedVisitorMap::None } diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs index 35c380612d2fb..84f2e186eaa35 100644 --- a/src/librustc_typeck/collect.rs +++ b/src/librustc_typeck/collect.rs @@ -21,7 +21,7 @@ use crate::lint; use crate::middle::resolve_lifetime as rl; use crate::middle::weak_lang_items; use errors::{struct_span_err, Applicability, StashKey}; -use rustc::hir::intravisit::{self, NestedVisitorMap, Visitor}; +use rustc::hir::map::Map; use rustc::middle::codegen_fn_attrs::{CodegenFnAttrFlags, CodegenFnAttrs}; use rustc::mir::mono::Linkage; use rustc::traits; @@ -37,6 +37,7 @@ use rustc_data_structures::fx::FxHashMap; use rustc_hir as hir; use rustc_hir::def::{CtorKind, DefKind, Res}; use rustc_hir::def_id::{DefId, LOCAL_CRATE}; +use rustc_hir::intravisit::{self, NestedVisitorMap, Visitor}; use rustc_hir::{GenericParamKind, Node, Unsafety}; use rustc_span::symbol::{kw, sym, Symbol}; use rustc_span::{Span, DUMMY_SP}; @@ -104,7 +105,9 @@ pub struct ItemCtxt<'tcx> { crate struct PlaceholderHirTyCollector(crate Vec); impl<'v> Visitor<'v> for PlaceholderHirTyCollector { - fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'v> { + type Map = Map<'v>; + + fn nested_visit_map(&mut self) -> NestedVisitorMap<'_, Self::Map> { NestedVisitorMap::None } fn visit_ty(&mut self, t: &'v hir::Ty<'v>) { @@ -185,7 +188,9 @@ fn reject_placeholder_type_signatures_in_item(tcx: TyCtxt<'tcx>, item: &'tcx hir } impl Visitor<'tcx> for CollectItemTypesVisitor<'tcx> { - fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> { + type Map = Map<'tcx>; + + fn nested_visit_map(&mut self) -> NestedVisitorMap<'_, Self::Map> { NestedVisitorMap::OnlyBodies(&self.tcx.hir()) } @@ -885,7 +890,9 @@ fn has_late_bound_regions<'tcx>(tcx: TyCtxt<'tcx>, node: Node<'tcx>) -> Option for LateBoundRegionsDetector<'tcx> { - fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> { + type Map = Map<'tcx>; + + fn nested_visit_map(&mut self) -> NestedVisitorMap<'_, Self::Map> { NestedVisitorMap::None } @@ -1715,7 +1722,9 @@ fn find_opaque_ty_constraints(tcx: TyCtxt<'_>, def_id: DefId) -> Ty<'_> { } impl<'tcx> intravisit::Visitor<'tcx> for ConstraintLocator<'tcx> { - fn nested_visit_map<'this>(&'this mut self) -> intravisit::NestedVisitorMap<'this, 'tcx> { + type Map = Map<'tcx>; + + fn nested_visit_map(&mut self) -> intravisit::NestedVisitorMap<'_, Self::Map> { intravisit::NestedVisitorMap::All(&self.tcx.hir()) } fn visit_item(&mut self, it: &'tcx Item<'tcx>) { diff --git a/src/librustdoc/test.rs b/src/librustdoc/test.rs index d94e940a7f72c..94e31108901ea 100644 --- a/src/librustdoc/test.rs +++ b/src/librustdoc/test.rs @@ -1,10 +1,10 @@ -use rustc::hir::intravisit; use rustc::hir::map::Map; use rustc::session::{self, config, DiagnosticOutput}; use rustc::util::common::ErrorReported; use rustc_data_structures::sync::Lrc; use rustc_feature::UnstableFeatures; use rustc_hir as hir; +use rustc_hir::intravisit; use rustc_interface::interface; use rustc_span::edition::Edition; use rustc_span::source_map::SourceMap; @@ -899,7 +899,9 @@ impl<'a, 'hir> HirCollector<'a, 'hir> { } impl<'a, 'hir> intravisit::Visitor<'hir> for HirCollector<'a, 'hir> { - fn nested_visit_map<'this>(&'this mut self) -> intravisit::NestedVisitorMap<'this, 'hir> { + type Map = Map<'hir>; + + fn nested_visit_map(&mut self) -> intravisit::NestedVisitorMap<'_, Self::Map> { intravisit::NestedVisitorMap::All(&self.map) } diff --git a/src/libstd/net/addr.rs b/src/libstd/net/addr.rs index a9d88370c612f..a59d7f0263bb0 100644 --- a/src/libstd/net/addr.rs +++ b/src/libstd/net/addr.rs @@ -227,10 +227,7 @@ impl SocketAddr { /// ``` #[stable(feature = "sockaddr_checker", since = "1.16.0")] pub fn is_ipv4(&self) -> bool { - match *self { - SocketAddr::V4(_) => true, - SocketAddr::V6(_) => false, - } + matches!(*self, SocketAddr::V4(_)) } /// Returns [`true`] if the [IP address] in this `SocketAddr` is an @@ -252,10 +249,7 @@ impl SocketAddr { /// ``` #[stable(feature = "sockaddr_checker", since = "1.16.0")] pub fn is_ipv6(&self) -> bool { - match *self { - SocketAddr::V4(_) => false, - SocketAddr::V6(_) => true, - } + matches!(*self, SocketAddr::V6(_)) } } diff --git a/src/libstd/net/ip.rs b/src/libstd/net/ip.rs index 15d2361acd916..6410a4f2b65b3 100644 --- a/src/libstd/net/ip.rs +++ b/src/libstd/net/ip.rs @@ -281,10 +281,7 @@ impl IpAddr { /// ``` #[stable(feature = "ipaddr_checker", since = "1.16.0")] pub fn is_ipv4(&self) -> bool { - match self { - IpAddr::V4(_) => true, - IpAddr::V6(_) => false, - } + matches!(self, IpAddr::V4(_)) } /// Returns [`true`] if this address is an [IPv6 address], and [`false`] otherwise. @@ -303,10 +300,7 @@ impl IpAddr { /// ``` #[stable(feature = "ipaddr_checker", since = "1.16.0")] pub fn is_ipv6(&self) -> bool { - match self { - IpAddr::V4(_) => false, - IpAddr::V6(_) => true, - } + matches!(self, IpAddr::V6(_)) } } diff --git a/src/libstd/path.rs b/src/libstd/path.rs index f308d511cf850..fbbdc1ddac297 100644 --- a/src/libstd/path.rs +++ b/src/libstd/path.rs @@ -224,18 +224,12 @@ impl<'a> Prefix<'a> { #[stable(feature = "rust1", since = "1.0.0")] pub fn is_verbatim(&self) -> bool { use self::Prefix::*; - match *self { - Verbatim(_) | VerbatimDisk(_) | VerbatimUNC(..) => true, - _ => false, - } + matches!(*self, Verbatim(_) | VerbatimDisk(_) | VerbatimUNC(..)) } #[inline] fn is_drive(&self) -> bool { - match *self { - Prefix::Disk(_) => true, - _ => false, - } + matches!(*self, Prefix::Disk(_)) } #[inline] diff --git a/src/libstd/sync/barrier.rs b/src/libstd/sync/barrier.rs index eddbdff257a99..01314370ce399 100644 --- a/src/libstd/sync/barrier.rs +++ b/src/libstd/sync/barrier.rs @@ -199,10 +199,7 @@ mod tests { // At this point, all spawned threads should be blocked, // so we shouldn't get anything from the port - assert!(match rx.try_recv() { - Err(TryRecvError::Empty) => true, - _ => false, - }); + assert!(matches!(rx.try_recv(), Err(TryRecvError::Empty))); let mut leader_found = barrier.wait().is_leader(); diff --git a/src/libstd/sync/mpsc/oneshot.rs b/src/libstd/sync/mpsc/oneshot.rs index bbe77e7d0fb5c..5b41525e06aaa 100644 --- a/src/libstd/sync/mpsc/oneshot.rs +++ b/src/libstd/sync/mpsc/oneshot.rs @@ -118,12 +118,7 @@ impl Packet { // Just tests whether this channel has been sent on or not, this is only // safe to use from the sender. pub fn sent(&self) -> bool { - unsafe { - match *self.upgrade.get() { - NothingSent => false, - _ => true, - } - } + unsafe { !matches!(*self.upgrade.get(), NothingSent) } } pub fn recv(&self, deadline: Option) -> Result> { diff --git a/src/test/mir-opt/const-promotion-extern-static.rs b/src/test/mir-opt/const-promotion-extern-static.rs new file mode 100644 index 0000000000000..d611ec22c38ec --- /dev/null +++ b/src/test/mir-opt/const-promotion-extern-static.rs @@ -0,0 +1,71 @@ +extern "C" { + static X: i32; +} + +static Y: i32 = 42; + +static mut BAR: *const &'static i32 = [&Y].as_ptr(); + +static mut FOO: *const &'static i32 = [unsafe { &X }].as_ptr(); + +fn main() {} + +// END RUST SOURCE +// START rustc.FOO.PromoteTemps.before.mir +// bb0: { +// ... +// _5 = const Scalar(AllocId(1).0x0) : &i32; +// _4 = &(*_5); +// _3 = [move _4]; +// _2 = &_3; +// _1 = move _2 as &[&'static i32] (Pointer(Unsize)); +// _0 = const core::slice::::as_ptr(move _1) -> [return: bb2, unwind: bb1]; +// } +// ... +// bb2: { +// StorageDead(_5); +// StorageDead(_3); +// return; +// } +// END rustc.FOO.PromoteTemps.before.mir +// START rustc.BAR.PromoteTemps.before.mir +// bb0: { +// ... +// _5 = const Scalar(AllocId(0).0x0) : &i32; +// _4 = &(*_5); +// _3 = [move _4]; +// _2 = &_3; +// _1 = move _2 as &[&'static i32] (Pointer(Unsize)); +// _0 = const core::slice::::as_ptr(move _1) -> [return: bb2, unwind: bb1]; +// } +// ... +// bb2: { +// StorageDead(_5); +// StorageDead(_3); +// return; +// } +// END rustc.BAR.PromoteTemps.before.mir +// START rustc.BAR.PromoteTemps.after.mir +// bb0: { +// ... +// _2 = &(promoted[0]: [&'static i32; 1]); +// _1 = move _2 as &[&'static i32] (Pointer(Unsize)); +// _0 = const core::slice::::as_ptr(move _1) -> [return: bb2, unwind: bb1]; +// } +// ... +// bb2: { +// return; +// } +// END rustc.BAR.PromoteTemps.after.mir +// START rustc.FOO.PromoteTemps.after.mir +// bb0: { +// ... +// _2 = &(promoted[0]: [&'static i32; 1]); +// _1 = move _2 as &[&'static i32] (Pointer(Unsize)); +// _0 = const core::slice::::as_ptr(move _1) -> [return: bb2, unwind: bb1]; +// } +// ... +// bb2: { +// return; +// } +// END rustc.FOO.PromoteTemps.after.mir diff --git a/src/test/ui-fulldeps/auxiliary/issue-40001-plugin.rs b/src/test/ui-fulldeps/auxiliary/issue-40001-plugin.rs index ee14d71573041..abb2e93757ed3 100644 --- a/src/test/ui-fulldeps/auxiliary/issue-40001-plugin.rs +++ b/src/test/ui-fulldeps/auxiliary/issue-40001-plugin.rs @@ -8,7 +8,7 @@ extern crate rustc_hir; extern crate rustc_span; extern crate syntax; -use rustc::hir::intravisit; +use rustc_hir::intravisit; use rustc_hir as hir; use rustc_hir::Node; use rustc::lint::{LateContext, LintPass, LintArray, LateLintPass, LintContext}; diff --git a/src/test/ui/associated-const/issue-63496.stderr b/src/test/ui/associated-const/issue-63496.stderr index 23916a3ba440c..3a70e7d43c25e 100644 --- a/src/test/ui/associated-const/issue-63496.stderr +++ b/src/test/ui/associated-const/issue-63496.stderr @@ -5,9 +5,13 @@ LL | const C: usize; | --------------- required by `A::C` LL | LL | fn f() -> ([u8; A::C], [u8; A::C]); - | ^^^^ cannot infer type + | ^^^^ + | | + | cannot infer type + | help: use the fully qualified path to an implementation: `::C` | = note: cannot resolve `_: A` + = note: associated constants cannot be accessed directly on a `trait`, they can only be accessed through a specific `impl` error[E0283]: type annotations needed --> $DIR/issue-63496.rs:4:33 @@ -16,9 +20,13 @@ LL | const C: usize; | --------------- required by `A::C` LL | LL | fn f() -> ([u8; A::C], [u8; A::C]); - | ^^^^ cannot infer type + | ^^^^ + | | + | cannot infer type + | help: use the fully qualified path to an implementation: `::C` | = note: cannot resolve `_: A` + = note: associated constants cannot be accessed directly on a `trait`, they can only be accessed through a specific `impl` error: aborting due to 2 previous errors diff --git a/src/test/ui/associated-item/issue-48027.stderr b/src/test/ui/associated-item/issue-48027.stderr index 9c825d593d3e4..ddabd552897a8 100644 --- a/src/test/ui/associated-item/issue-48027.stderr +++ b/src/test/ui/associated-item/issue-48027.stderr @@ -13,9 +13,13 @@ error[E0283]: type annotations needed LL | const X: usize; | --------------- required by `Bar::X` LL | fn return_n(&self) -> [u8; Bar::X]; - | ^^^^^^ cannot infer type + | ^^^^^^ + | | + | cannot infer type + | help: use the fully qualified path to an implementation: `::X` | = note: cannot resolve `_: Bar` + = note: associated constants cannot be accessed directly on a `trait`, they can only be accessed through a specific `impl` error: aborting due to 2 previous errors diff --git a/src/test/ui/borrowck/borrowck-move-out-from-array-match.rs b/src/test/ui/borrowck/borrowck-move-out-from-array-match.rs new file mode 100644 index 0000000000000..232d43679b484 --- /dev/null +++ b/src/test/ui/borrowck/borrowck-move-out-from-array-match.rs @@ -0,0 +1,118 @@ +#![feature(slice_patterns)] + +fn array() -> [(String, String); 3] { + Default::default() +} + +// Const Index + Const Index + +fn move_out_from_begin_and_end() { + let a = array(); + match a { + [_, _, _x] => {} + } + match a { + [.., _y] => {} //~ ERROR use of moved value + } +} + +fn move_out_from_begin_field_and_end() { + let a = array(); + match a { + [_, _, (_x, _)] => {} + } + match a { + [.., _y] => {} //~ ERROR use of moved value + } +} + +fn move_out_from_begin_field_and_end_field() { + let a = array(); + match a { + [_, _, (_x, _)] => {} + } + match a { + [.., (_y, _)] => {} //~ ERROR use of moved value + } +} + +// Const Index + Slice + +fn move_out_by_const_index_and_subslice() { + let a = array(); + match a { + [_x, _, _] => {} + } + match a { + //~^ ERROR use of moved value + [_y @ .., _, _] => {} + } +} + +fn move_out_by_const_index_end_and_subslice() { + let a = array(); + match a { + [.., _x] => {} + } + match a { + //~^ ERROR use of moved value + [_, _, _y @ ..] => {} + } +} + +fn move_out_by_const_index_field_and_subslice() { + let a = array(); + match a { + [(_x, _), _, _] => {} + } + match a { + //~^ ERROR use of moved value + [_y @ .., _, _] => {} + } +} + +fn move_out_by_const_index_end_field_and_subslice() { + let a = array(); + match a { + [.., (_x, _)] => {} + } + match a { + //~^ ERROR use of moved value + [_, _, _y @ ..] => {} + } +} + +fn move_out_by_subslice_and_const_index_field() { + let a = array(); + match a { + [_y @ .., _, _] => {} + } + match a { + [(_x, _), _, _] => {} //~ ERROR use of moved value + } +} + +fn move_out_by_subslice_and_const_index_end_field() { + let a = array(); + match a { + [_, _, _y @ ..] => {} + } + match a { + [.., (_x, _)] => {} //~ ERROR use of moved value + } +} + +// Slice + Slice + +fn move_out_by_subslice_and_subslice() { + let a = array(); + match a { + [x @ .., _] => {} + } + match a { + //~^ ERROR use of moved value + [_, _y @ ..] => {} + } +} + +fn main() {} diff --git a/src/test/ui/borrowck/borrowck-move-out-from-array-match.stderr b/src/test/ui/borrowck/borrowck-move-out-from-array-match.stderr new file mode 100644 index 0000000000000..e46a58a8a3500 --- /dev/null +++ b/src/test/ui/borrowck/borrowck-move-out-from-array-match.stderr @@ -0,0 +1,113 @@ +error[E0382]: use of moved value: `a[..]` + --> $DIR/borrowck-move-out-from-array-match.rs:15:14 + | +LL | [_, _, _x] => {} + | -- value moved here +... +LL | [.., _y] => {} + | ^^ value used here after move + | + = note: move occurs because `a[..]` has type `(std::string::String, std::string::String)`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `a[..]` + --> $DIR/borrowck-move-out-from-array-match.rs:25:14 + | +LL | [_, _, (_x, _)] => {} + | -- value moved here +... +LL | [.., _y] => {} + | ^^ value used here after partial move + | + = note: move occurs because `a[..].0` has type `std::string::String`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `a[..].0` + --> $DIR/borrowck-move-out-from-array-match.rs:35:15 + | +LL | [_, _, (_x, _)] => {} + | -- value moved here +... +LL | [.., (_y, _)] => {} + | ^^ value used here after move + | + = note: move occurs because `a[..].0` has type `std::string::String`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `a` + --> $DIR/borrowck-move-out-from-array-match.rs:46:11 + | +LL | [_x, _, _] => {} + | -- value moved here +LL | } +LL | match a { + | ^ value used here after partial move + | + = note: move occurs because `a[..]` has type `(std::string::String, std::string::String)`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `a` + --> $DIR/borrowck-move-out-from-array-match.rs:57:11 + | +LL | [.., _x] => {} + | -- value moved here +LL | } +LL | match a { + | ^ value used here after partial move + | + = note: move occurs because `a[..]` has type `(std::string::String, std::string::String)`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `a` + --> $DIR/borrowck-move-out-from-array-match.rs:68:11 + | +LL | [(_x, _), _, _] => {} + | -- value moved here +LL | } +LL | match a { + | ^ value used here after partial move + | + = note: move occurs because `a[..].0` has type `std::string::String`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `a` + --> $DIR/borrowck-move-out-from-array-match.rs:79:11 + | +LL | [.., (_x, _)] => {} + | -- value moved here +LL | } +LL | match a { + | ^ value used here after partial move + | + = note: move occurs because `a[..].0` has type `std::string::String`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `a[..].0` + --> $DIR/borrowck-move-out-from-array-match.rs:91:11 + | +LL | [_y @ .., _, _] => {} + | ------- value moved here +... +LL | [(_x, _), _, _] => {} + | ^^ value used here after move + | + = note: move occurs because `a[..]` has type `(std::string::String, std::string::String)`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `a[..].0` + --> $DIR/borrowck-move-out-from-array-match.rs:101:15 + | +LL | [_, _, _y @ ..] => {} + | ------- value moved here +... +LL | [.., (_x, _)] => {} + | ^^ value used here after move + | + = note: move occurs because `a[..]` has type `(std::string::String, std::string::String)`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `a` + --> $DIR/borrowck-move-out-from-array-match.rs:112:11 + | +LL | [x @ .., _] => {} + | ------ value moved here +LL | } +LL | match a { + | ^ value used here after partial move + | + = note: move occurs because `a[..]` has type `(std::string::String, std::string::String)`, which does not implement the `Copy` trait + +error: aborting due to 10 previous errors + +For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/borrowck/borrowck-move-out-from-array-no-overlap-match.rs b/src/test/ui/borrowck/borrowck-move-out-from-array-no-overlap-match.rs new file mode 100644 index 0000000000000..e5e61697c68c6 --- /dev/null +++ b/src/test/ui/borrowck/borrowck-move-out-from-array-no-overlap-match.rs @@ -0,0 +1,117 @@ +// Due to #53114, which causes a "read" of the `_` patterns, +// the borrow-checker refuses this code, while it should probably be allowed. +// Once the bug is fixed, the test, which is derived from a +// passing test for `let` statements, should become check-pass. + +#![feature(slice_patterns)] + +fn array() -> [(String, String); 3] { + Default::default() +} + +// Const Index + Const Index + +fn move_out_from_begin_and_one_from_end() { + let a = array(); + match a { + [_, _, _x] => {} + } + match a { + //~^ ERROR use of moved value + [.., _y, _] => {} + } +} + +fn move_out_from_begin_field_and_end_field() { + let a = array(); + match a { + [_, _, (_x, _)] => {} + } + match a { + //~^ ERROR use of moved value + [.., (_, _y)] => {} + } +} + +// Const Index + Slice + +fn move_out_by_const_index_and_subslice() { + let a = array(); + match a { + [_x, _, _] => {} + } + match a { + //~^ ERROR use of moved value + [_, _y @ ..] => {} + } +} + +fn move_out_by_const_index_end_and_subslice() { + let a = array(); + match a { + [.., _x] => {} + } + match a { + //~^ ERROR use of moved value + [_y @ .., _] => {} + } +} + +fn move_out_by_const_index_field_and_subslice() { + let a = array(); + match a { + [(_x, _), _, _] => {} + } + match a { + //~^ ERROR use of moved value + [_, _y @ ..] => {} + } +} + +fn move_out_by_const_index_end_field_and_subslice() { + let a = array(); + match a { + [.., (_x, _)] => {} + } + match a { + //~^ ERROR use of moved value + [_y @ .., _] => {} + } +} + +fn move_out_by_const_subslice_and_index_field() { + let a = array(); + match a { + [_, _y @ ..] => {} + } + match a { + //~^ ERROR use of moved value + [(_x, _), _, _] => {} + } +} + +fn move_out_by_const_subslice_and_end_index_field() { + let a = array(); + match a { + [_y @ .., _] => {} + } + match a { + //~^ ERROR use of moved value + [.., (_x, _)] => {} + } +} + +// Slice + Slice + +fn move_out_by_subslice_and_subslice() { + let a = array(); + match a { + [x @ .., _, _] => {} + } + match a { + //~^ ERROR use of moved value + [_, _y @ ..] => {} + } +} + +fn main() {} diff --git a/src/test/ui/borrowck/borrowck-move-out-from-array-no-overlap-match.stderr b/src/test/ui/borrowck/borrowck-move-out-from-array-no-overlap-match.stderr new file mode 100644 index 0000000000000..72cd4207cce65 --- /dev/null +++ b/src/test/ui/borrowck/borrowck-move-out-from-array-no-overlap-match.stderr @@ -0,0 +1,102 @@ +error[E0382]: use of moved value: `a` + --> $DIR/borrowck-move-out-from-array-no-overlap-match.rs:19:11 + | +LL | [_, _, _x] => {} + | -- value moved here +LL | } +LL | match a { + | ^ value used here after partial move + | + = note: move occurs because `a[..]` has type `(std::string::String, std::string::String)`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `a` + --> $DIR/borrowck-move-out-from-array-no-overlap-match.rs:30:11 + | +LL | [_, _, (_x, _)] => {} + | -- value moved here +LL | } +LL | match a { + | ^ value used here after partial move + | + = note: move occurs because `a[..].0` has type `std::string::String`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `a` + --> $DIR/borrowck-move-out-from-array-no-overlap-match.rs:43:11 + | +LL | [_x, _, _] => {} + | -- value moved here +LL | } +LL | match a { + | ^ value used here after partial move + | + = note: move occurs because `a[..]` has type `(std::string::String, std::string::String)`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `a` + --> $DIR/borrowck-move-out-from-array-no-overlap-match.rs:54:11 + | +LL | [.., _x] => {} + | -- value moved here +LL | } +LL | match a { + | ^ value used here after partial move + | + = note: move occurs because `a[..]` has type `(std::string::String, std::string::String)`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `a` + --> $DIR/borrowck-move-out-from-array-no-overlap-match.rs:65:11 + | +LL | [(_x, _), _, _] => {} + | -- value moved here +LL | } +LL | match a { + | ^ value used here after partial move + | + = note: move occurs because `a[..].0` has type `std::string::String`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `a` + --> $DIR/borrowck-move-out-from-array-no-overlap-match.rs:76:11 + | +LL | [.., (_x, _)] => {} + | -- value moved here +LL | } +LL | match a { + | ^ value used here after partial move + | + = note: move occurs because `a[..].0` has type `std::string::String`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `a` + --> $DIR/borrowck-move-out-from-array-no-overlap-match.rs:87:11 + | +LL | [_, _y @ ..] => {} + | ------- value moved here +LL | } +LL | match a { + | ^ value used here after partial move + | + = note: move occurs because `a[..]` has type `(std::string::String, std::string::String)`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `a` + --> $DIR/borrowck-move-out-from-array-no-overlap-match.rs:98:11 + | +LL | [_y @ .., _] => {} + | ------- value moved here +LL | } +LL | match a { + | ^ value used here after partial move + | + = note: move occurs because `a[..]` has type `(std::string::String, std::string::String)`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `a` + --> $DIR/borrowck-move-out-from-array-no-overlap-match.rs:111:11 + | +LL | [x @ .., _, _] => {} + | ------ value moved here +LL | } +LL | match a { + | ^ value used here after partial move + | + = note: move occurs because `a[..]` has type `(std::string::String, std::string::String)`, which does not implement the `Copy` trait + +error: aborting due to 9 previous errors + +For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/borrowck/borrowck-move-out-from-array-use-match.rs b/src/test/ui/borrowck/borrowck-move-out-from-array-use-match.rs new file mode 100644 index 0000000000000..1ca3df52ada91 --- /dev/null +++ b/src/test/ui/borrowck/borrowck-move-out-from-array-use-match.rs @@ -0,0 +1,152 @@ +#![feature(slice_patterns)] + +fn array() -> [(String, String); 3] { + Default::default() +} + +// Const Index + Const Index + +fn move_out_from_begin_and_end() { + let a = array(); + match a { + [_, _, _x] => {} + } + match a { + [.., ref _y] => {} //~ ERROR [E0382] + } +} + +fn move_out_from_begin_field_and_end() { + let a = array(); + match a { + [_, _, (_x, _)] => {} + } + match a { + [.., ref _y] => {} //~ ERROR [E0382] + } +} + +fn move_out_from_begin_field_and_end_field() { + let a = array(); + match a { + [_, _, (_x, _)] => {} + } + match a { + [.., (ref _y, _)] => {} //~ ERROR [E0382] + } +} + +// Const Index + Slice + +fn move_out_by_const_index_and_subslice() { + let a = array(); + match a { + [_x, _, _] => {} + } + match a { + //~^ ERROR [E0382] + [ref _y @ .., _, _] => {} + } +} + +fn move_out_by_const_index_end_and_subslice() { + let a = array(); + match a { + [.., _x] => {} + } + match a { + //~^ ERROR [E0382] + [_, _, ref _y @ ..] => {} + } +} + +fn move_out_by_const_index_field_and_subslice() { + let a = array(); + match a { + [(_x, _), _, _] => {} + } + match a { + //~^ ERROR [E0382] + [ref _y @ .., _, _] => {} + } +} + +fn move_out_by_const_index_end_field_and_subslice() { + let a = array(); + match a { + [.., (_x, _)] => {} + } + match a { + //~^ ERROR [E0382] + [_, _, ref _y @ ..] => {} + } +} + +fn move_out_by_subslice_and_const_index_field() { + let a = array(); + match a { + [_y @ .., _, _] => {} + } + match a { + [(ref _x, _), _, _] => {} //~ ERROR [E0382] + } +} + +fn move_out_by_subslice_and_const_index_end_field() { + let a = array(); + match a { + [_, _, _y @ ..] => {} + } + match a { + [.., (ref _x, _)] => {} //~ ERROR [E0382] + } +} + +// Slice + Slice + +fn move_out_by_subslice_and_subslice() { + let a = array(); + match a { + [x @ .., _] => {} + } + match a { + //~^ ERROR [E0382] + [_, ref _y @ ..] => {} + } +} + +// Move + Assign + +fn move_out_and_assign_end() { + let mut a = array(); + match a { + [_, _, _x] => {} + } + a[2] = Default::default(); //~ ERROR [E0382] +} + +fn move_out_and_assign_end_field() { + let mut a = array(); + match a { + [_, _, (_x, _)] => {} + } + a[2].1 = Default::default(); //~ ERROR [E0382] +} + +fn move_out_slice_and_assign_end() { + let mut a = array(); + match a { + [_, _, _x @ ..] => {} + } + a[0] = Default::default(); //~ ERROR [E0382] +} + +fn move_out_slice_and_assign_end_field() { + let mut a = array(); + match a { + [_, _, _x @ ..] => {} + } + a[0].1 = Default::default(); //~ ERROR [E0382] +} + +fn main() {} diff --git a/src/test/ui/borrowck/borrowck-move-out-from-array-use-match.stderr b/src/test/ui/borrowck/borrowck-move-out-from-array-use-match.stderr new file mode 100644 index 0000000000000..028442a4c07ea --- /dev/null +++ b/src/test/ui/borrowck/borrowck-move-out-from-array-use-match.stderr @@ -0,0 +1,157 @@ +error[E0382]: borrow of moved value: `a[..]` + --> $DIR/borrowck-move-out-from-array-use-match.rs:15:14 + | +LL | [_, _, _x] => {} + | -- value moved here +... +LL | [.., ref _y] => {} + | ^^^^^^ value borrowed here after move + | + = note: move occurs because `a[..]` has type `(std::string::String, std::string::String)`, which does not implement the `Copy` trait + +error[E0382]: borrow of moved value: `a[..]` + --> $DIR/borrowck-move-out-from-array-use-match.rs:25:14 + | +LL | [_, _, (_x, _)] => {} + | -- value moved here +... +LL | [.., ref _y] => {} + | ^^^^^^ value borrowed here after partial move + | + = note: move occurs because `a[..].0` has type `std::string::String`, which does not implement the `Copy` trait + +error[E0382]: borrow of moved value: `a[..].0` + --> $DIR/borrowck-move-out-from-array-use-match.rs:35:15 + | +LL | [_, _, (_x, _)] => {} + | -- value moved here +... +LL | [.., (ref _y, _)] => {} + | ^^^^^^ value borrowed here after move + | + = note: move occurs because `a[..].0` has type `std::string::String`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `a` + --> $DIR/borrowck-move-out-from-array-use-match.rs:46:11 + | +LL | [_x, _, _] => {} + | -- value moved here +LL | } +LL | match a { + | ^ value used here after partial move + | + = note: move occurs because `a[..]` has type `(std::string::String, std::string::String)`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `a` + --> $DIR/borrowck-move-out-from-array-use-match.rs:57:11 + | +LL | [.., _x] => {} + | -- value moved here +LL | } +LL | match a { + | ^ value used here after partial move + | + = note: move occurs because `a[..]` has type `(std::string::String, std::string::String)`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `a` + --> $DIR/borrowck-move-out-from-array-use-match.rs:68:11 + | +LL | [(_x, _), _, _] => {} + | -- value moved here +LL | } +LL | match a { + | ^ value used here after partial move + | + = note: move occurs because `a[..].0` has type `std::string::String`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `a` + --> $DIR/borrowck-move-out-from-array-use-match.rs:79:11 + | +LL | [.., (_x, _)] => {} + | -- value moved here +LL | } +LL | match a { + | ^ value used here after partial move + | + = note: move occurs because `a[..].0` has type `std::string::String`, which does not implement the `Copy` trait + +error[E0382]: borrow of moved value: `a[..]` + --> $DIR/borrowck-move-out-from-array-use-match.rs:91:11 + | +LL | [_y @ .., _, _] => {} + | ------- value moved here +... +LL | [(ref _x, _), _, _] => {} + | ^^^^^^ value borrowed here after move + | + = note: move occurs because `a[..]` has type `(std::string::String, std::string::String)`, which does not implement the `Copy` trait + +error[E0382]: borrow of moved value: `a[..]` + --> $DIR/borrowck-move-out-from-array-use-match.rs:101:15 + | +LL | [_, _, _y @ ..] => {} + | ------- value moved here +... +LL | [.., (ref _x, _)] => {} + | ^^^^^^ value borrowed here after move + | + = note: move occurs because `a[..]` has type `(std::string::String, std::string::String)`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `a` + --> $DIR/borrowck-move-out-from-array-use-match.rs:112:11 + | +LL | [x @ .., _] => {} + | ------ value moved here +LL | } +LL | match a { + | ^ value used here after partial move + | + = note: move occurs because `a[..]` has type `(std::string::String, std::string::String)`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `a` + --> $DIR/borrowck-move-out-from-array-use-match.rs:125:5 + | +LL | [_, _, _x] => {} + | -- value moved here +LL | } +LL | a[2] = Default::default(); + | ^^^^ value used here after partial move + | + = note: move occurs because `a[..]` has type `(std::string::String, std::string::String)`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `a` + --> $DIR/borrowck-move-out-from-array-use-match.rs:133:5 + | +LL | [_, _, (_x, _)] => {} + | -- value moved here +LL | } +LL | a[2].1 = Default::default(); + | ^^^^ value used here after partial move + | + = note: move occurs because `a[..].0` has type `std::string::String`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `a` + --> $DIR/borrowck-move-out-from-array-use-match.rs:141:5 + | +LL | [_, _, _x @ ..] => {} + | ------- value moved here +LL | } +LL | a[0] = Default::default(); + | ^^^^ value used here after partial move + | + = note: move occurs because `a[..]` has type `(std::string::String, std::string::String)`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `a` + --> $DIR/borrowck-move-out-from-array-use-match.rs:149:5 + | +LL | [_, _, _x @ ..] => {} + | ------- value moved here +LL | } +LL | a[0].1 = Default::default(); + | ^^^^ value used here after partial move + | + = note: move occurs because `a[..]` has type `(std::string::String, std::string::String)`, which does not implement the `Copy` trait + +error: aborting due to 14 previous errors + +For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/borrowck/borrowck-move-out-from-array-use-no-overlap-match.rs b/src/test/ui/borrowck/borrowck-move-out-from-array-use-no-overlap-match.rs new file mode 100644 index 0000000000000..79fe593009652 --- /dev/null +++ b/src/test/ui/borrowck/borrowck-move-out-from-array-use-no-overlap-match.rs @@ -0,0 +1,117 @@ +// Due to #53114, which causes a "read" of the `_` patterns, +// the borrow-checker refuses this code, while it should probably be allowed. +// Once the bug is fixed, the test, which is derived from a +// passing test for `let` statements, should become check-pass. + +#![feature(slice_patterns)] + +fn array() -> [(String, String); 3] { + Default::default() +} + +// Const Index + Const Index + +fn move_out_from_begin_and_one_from_end() { + let a = array(); + match a { + [_, _, _x] => {} + } + match a { + //~^ ERROR use of moved value + [.., ref _y, _] => {} + } +} + +fn move_out_from_begin_field_and_end_field() { + let a = array(); + match a { + [_, _, (_x, _)] => {} + } + match a { + //~^ ERROR use of moved value + [.., (_, ref _y)] => {} + } +} + +// Const Index + Slice + +fn move_out_by_const_index_and_subslice() { + let a = array(); + match a { + [_x, _, _] => {} + } + match a { + //~^ ERROR use of moved value + [_, ref _y @ ..] => {} + } +} + +fn move_out_by_const_index_end_and_subslice() { + let a = array(); + match a { + [.., _x] => {} + } + match a { + //~^ ERROR use of moved value + [ref _y @ .., _] => {} + } +} + +fn move_out_by_const_index_field_and_subslice() { + let a = array(); + match a { + [(_x, _), _, _] => {} + } + match a { + //~^ ERROR use of moved value + [_, ref _y @ ..] => {} + } +} + +fn move_out_by_const_index_end_field_and_subslice() { + let a = array(); + match a { + [.., (_x, _)] => {} + } + match a { + //~^ ERROR use of moved value + [ref _y @ .., _] => {} + } +} + +fn move_out_by_const_subslice_and_index_field() { + let a = array(); + match a { + [_, _y @ ..] => {} + } + match a { + //~^ ERROR use of moved value + [(ref _x, _), _, _] => {} + } +} + +fn move_out_by_const_subslice_and_end_index_field() { + let a = array(); + match a { + [_y @ .., _] => {} + } + match a { + //~^ ERROR use of moved value + [.., (ref _x, _)] => {} + } +} + +// Slice + Slice + +fn move_out_by_subslice_and_subslice() { + let a = array(); + match a { + [x @ .., _, _] => {} + } + match a { + //~^ ERROR use of moved value + [_, ref _y @ ..] => {} + } +} + +fn main() {} diff --git a/src/test/ui/borrowck/borrowck-move-out-from-array-use-no-overlap-match.stderr b/src/test/ui/borrowck/borrowck-move-out-from-array-use-no-overlap-match.stderr new file mode 100644 index 0000000000000..43ba2b664a1e1 --- /dev/null +++ b/src/test/ui/borrowck/borrowck-move-out-from-array-use-no-overlap-match.stderr @@ -0,0 +1,102 @@ +error[E0382]: use of moved value: `a` + --> $DIR/borrowck-move-out-from-array-use-no-overlap-match.rs:19:11 + | +LL | [_, _, _x] => {} + | -- value moved here +LL | } +LL | match a { + | ^ value used here after partial move + | + = note: move occurs because `a[..]` has type `(std::string::String, std::string::String)`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `a` + --> $DIR/borrowck-move-out-from-array-use-no-overlap-match.rs:30:11 + | +LL | [_, _, (_x, _)] => {} + | -- value moved here +LL | } +LL | match a { + | ^ value used here after partial move + | + = note: move occurs because `a[..].0` has type `std::string::String`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `a` + --> $DIR/borrowck-move-out-from-array-use-no-overlap-match.rs:43:11 + | +LL | [_x, _, _] => {} + | -- value moved here +LL | } +LL | match a { + | ^ value used here after partial move + | + = note: move occurs because `a[..]` has type `(std::string::String, std::string::String)`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `a` + --> $DIR/borrowck-move-out-from-array-use-no-overlap-match.rs:54:11 + | +LL | [.., _x] => {} + | -- value moved here +LL | } +LL | match a { + | ^ value used here after partial move + | + = note: move occurs because `a[..]` has type `(std::string::String, std::string::String)`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `a` + --> $DIR/borrowck-move-out-from-array-use-no-overlap-match.rs:65:11 + | +LL | [(_x, _), _, _] => {} + | -- value moved here +LL | } +LL | match a { + | ^ value used here after partial move + | + = note: move occurs because `a[..].0` has type `std::string::String`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `a` + --> $DIR/borrowck-move-out-from-array-use-no-overlap-match.rs:76:11 + | +LL | [.., (_x, _)] => {} + | -- value moved here +LL | } +LL | match a { + | ^ value used here after partial move + | + = note: move occurs because `a[..].0` has type `std::string::String`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `a` + --> $DIR/borrowck-move-out-from-array-use-no-overlap-match.rs:87:11 + | +LL | [_, _y @ ..] => {} + | ------- value moved here +LL | } +LL | match a { + | ^ value used here after partial move + | + = note: move occurs because `a[..]` has type `(std::string::String, std::string::String)`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `a` + --> $DIR/borrowck-move-out-from-array-use-no-overlap-match.rs:98:11 + | +LL | [_y @ .., _] => {} + | ------- value moved here +LL | } +LL | match a { + | ^ value used here after partial move + | + = note: move occurs because `a[..]` has type `(std::string::String, std::string::String)`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `a` + --> $DIR/borrowck-move-out-from-array-use-no-overlap-match.rs:111:11 + | +LL | [x @ .., _, _] => {} + | ------ value moved here +LL | } +LL | match a { + | ^ value used here after partial move + | + = note: move occurs because `a[..]` has type `(std::string::String, std::string::String)`, which does not implement the `Copy` trait + +error: aborting due to 9 previous errors + +For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/consts/miri_unleashed/mutable_const2.stderr b/src/test/ui/consts/miri_unleashed/mutable_const2.stderr index 3493b7c54c43b..88418e57acdda 100644 --- a/src/test/ui/consts/miri_unleashed/mutable_const2.stderr +++ b/src/test/ui/consts/miri_unleashed/mutable_const2.stderr @@ -10,7 +10,7 @@ error: internal compiler error: mutable allocation in constant LL | const MUTABLE_BEHIND_RAW: *mut i32 = &UnsafeCell::new(42) as *const _ as *mut _; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -thread 'rustc' panicked at 'no errors encountered even though `delay_span_bug` issued', src/librustc_errors/lib.rs:347:17 +thread 'rustc' panicked at 'no errors encountered even though `delay_span_bug` issued', src/librustc_errors/lib.rs:346:17 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace. error: internal compiler error: unexpected panic diff --git a/src/test/ui/issues/issue-28837.rs b/src/test/ui/issues/issue-28837.rs index 438a4c521b198..f874b00db0b49 100644 --- a/src/test/ui/issues/issue-28837.rs +++ b/src/test/ui/issues/issue-28837.rs @@ -5,7 +5,7 @@ fn main() { a + a; //~ ERROR cannot add `A` to `A` - a - a; //~ ERROR cannot substract `A` from `A` + a - a; //~ ERROR cannot subtract `A` from `A` a * a; //~ ERROR cannot multiply `A` to `A` diff --git a/src/test/ui/issues/issue-28837.stderr b/src/test/ui/issues/issue-28837.stderr index 2ef571b576f89..b63e168caf196 100644 --- a/src/test/ui/issues/issue-28837.stderr +++ b/src/test/ui/issues/issue-28837.stderr @@ -8,7 +8,7 @@ LL | a + a; | = note: an implementation of `std::ops::Add` might be missing for `A` -error[E0369]: cannot substract `A` from `A` +error[E0369]: cannot subtract `A` from `A` --> $DIR/issue-28837.rs:8:7 | LL | a - a; diff --git a/src/test/ui/issues/issue-58022.stderr b/src/test/ui/issues/issue-58022.stderr index ef0d66d7ad6d1..70a7c38b83425 100644 --- a/src/test/ui/issues/issue-58022.stderr +++ b/src/test/ui/issues/issue-58022.stderr @@ -11,9 +11,13 @@ LL | const SIZE: usize; | ------------------ required by `Foo::SIZE` LL | LL | fn new(slice: &[u8; Foo::SIZE]) -> Self; - | ^^^^^^^^^ cannot infer type + | ^^^^^^^^^ + | | + | cannot infer type + | help: use the fully qualified path to an implementation: `::SIZE` | = note: cannot resolve `_: Foo` + = note: associated constants cannot be accessed directly on a `trait`, they can only be accessed through a specific `impl` error: aborting due to 2 previous errors diff --git a/src/test/ui/parse-error-correct.rs b/src/test/ui/parse-error-correct.rs index f167b3595d92f..13759a2351997 100644 --- a/src/test/ui/parse-error-correct.rs +++ b/src/test/ui/parse-error-correct.rs @@ -1,5 +1,3 @@ -// compile-flags: -Z continue-parse-after-error - // Test that the parser is error correcting missing idents. Despite a parsing // error (or two), we still run type checking (and don't get extra errors there). diff --git a/src/test/ui/parse-error-correct.stderr b/src/test/ui/parse-error-correct.stderr index d593431d9781d..c54baf00b27f2 100644 --- a/src/test/ui/parse-error-correct.stderr +++ b/src/test/ui/parse-error-correct.stderr @@ -1,17 +1,17 @@ error: unexpected token: `;` - --> $DIR/parse-error-correct.rs:8:15 + --> $DIR/parse-error-correct.rs:6:15 | LL | let x = y.; | ^ error: unexpected token: `(` - --> $DIR/parse-error-correct.rs:9:15 + --> $DIR/parse-error-correct.rs:7:15 | LL | let x = y.(); | ^ error[E0618]: expected function, found `{integer}` - --> $DIR/parse-error-correct.rs:9:13 + --> $DIR/parse-error-correct.rs:7:13 | LL | let y = 42; | - `{integer}` defined here @@ -22,7 +22,7 @@ LL | let x = y.(); | call expression requires function error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields - --> $DIR/parse-error-correct.rs:11:15 + --> $DIR/parse-error-correct.rs:9:15 | LL | let x = y.foo; | ^^^ diff --git a/src/test/ui/parser-recovery-1.rs b/src/test/ui/parser-recovery-1.rs index dcc0dc00a72ea..7e26b4f2b6a22 100644 --- a/src/test/ui/parser-recovery-1.rs +++ b/src/test/ui/parser-recovery-1.rs @@ -1,5 +1,3 @@ -// compile-flags: -Z continue-parse-after-error - // Test that we can recover from missing braces in the parser. trait Foo { diff --git a/src/test/ui/parser-recovery-1.stderr b/src/test/ui/parser-recovery-1.stderr index 4d881918c40cc..f56060c3e356f 100644 --- a/src/test/ui/parser-recovery-1.stderr +++ b/src/test/ui/parser-recovery-1.stderr @@ -1,5 +1,5 @@ error: this file contains an unclosed delimiter - --> $DIR/parser-recovery-1.rs:15:54 + --> $DIR/parser-recovery-1.rs:13:54 | LL | trait Foo { | - unclosed delimiter @@ -13,19 +13,19 @@ LL | } | ^ error: unexpected token: `;` - --> $DIR/parser-recovery-1.rs:12:15 + --> $DIR/parser-recovery-1.rs:10:15 | LL | let x = y.; | ^ error[E0425]: cannot find function `foo` in this scope - --> $DIR/parser-recovery-1.rs:7:17 + --> $DIR/parser-recovery-1.rs:5:17 | LL | let x = foo(); | ^^^ not found in this scope error[E0425]: cannot find value `y` in this scope - --> $DIR/parser-recovery-1.rs:12:13 + --> $DIR/parser-recovery-1.rs:10:13 | LL | let x = y.; | ^ not found in this scope diff --git a/src/test/ui/parser-recovery-2.rs b/src/test/ui/parser-recovery-2.rs index dc5be96cc6405..48b22afffe7f0 100644 --- a/src/test/ui/parser-recovery-2.rs +++ b/src/test/ui/parser-recovery-2.rs @@ -1,5 +1,3 @@ -// compile-flags: -Z continue-parse-after-error - // Test that we can recover from mismatched braces in the parser. trait Foo { diff --git a/src/test/ui/parser-recovery-2.stderr b/src/test/ui/parser-recovery-2.stderr index c48211d406479..cd3da4c71f0b5 100644 --- a/src/test/ui/parser-recovery-2.stderr +++ b/src/test/ui/parser-recovery-2.stderr @@ -1,11 +1,11 @@ error: unexpected token: `;` - --> $DIR/parser-recovery-2.rs:12:15 + --> $DIR/parser-recovery-2.rs:10:15 | LL | let x = y.; | ^ error: mismatched closing delimiter: `)` - --> $DIR/parser-recovery-2.rs:8:5 + --> $DIR/parser-recovery-2.rs:6:5 | LL | fn bar() { | - unclosed delimiter @@ -14,13 +14,13 @@ LL | ) | ^ mismatched closing delimiter error[E0425]: cannot find function `foo` in this scope - --> $DIR/parser-recovery-2.rs:7:17 + --> $DIR/parser-recovery-2.rs:5:17 | LL | let x = foo(); | ^^^ not found in this scope error[E0425]: cannot find value `y` in this scope - --> $DIR/parser-recovery-2.rs:12:13 + --> $DIR/parser-recovery-2.rs:10:13 | LL | let x = y.; | ^ not found in this scope diff --git a/src/test/ui/parser/ascii-only-character-escape.rs b/src/test/ui/parser/ascii-only-character-escape.rs index f1b028ea8de02..20d3edf125175 100644 --- a/src/test/ui/parser/ascii-only-character-escape.rs +++ b/src/test/ui/parser/ascii-only-character-escape.rs @@ -1,5 +1,3 @@ -// compile-flags: -Z continue-parse-after-error - fn main() { let x = "\x80"; //~ ERROR may only be used let y = "\xff"; //~ ERROR may only be used diff --git a/src/test/ui/parser/ascii-only-character-escape.stderr b/src/test/ui/parser/ascii-only-character-escape.stderr index 391677917580b..cf51b00cdc39a 100644 --- a/src/test/ui/parser/ascii-only-character-escape.stderr +++ b/src/test/ui/parser/ascii-only-character-escape.stderr @@ -1,17 +1,17 @@ error: this form of character escape may only be used with characters in the range [\x00-\x7f] - --> $DIR/ascii-only-character-escape.rs:4:14 + --> $DIR/ascii-only-character-escape.rs:2:14 | LL | let x = "\x80"; | ^^^^ error: this form of character escape may only be used with characters in the range [\x00-\x7f] - --> $DIR/ascii-only-character-escape.rs:5:14 + --> $DIR/ascii-only-character-escape.rs:3:14 | LL | let y = "\xff"; | ^^^^ error: this form of character escape may only be used with characters in the range [\x00-\x7f] - --> $DIR/ascii-only-character-escape.rs:6:14 + --> $DIR/ascii-only-character-escape.rs:4:14 | LL | let z = "\xe2"; | ^^^^ diff --git a/src/test/ui/parser/bad-char-literals.rs b/src/test/ui/parser/bad-char-literals.rs index 1c9b5973be7fe..11696b82bc9ac 100644 --- a/src/test/ui/parser/bad-char-literals.rs +++ b/src/test/ui/parser/bad-char-literals.rs @@ -1,7 +1,6 @@ -// compile-flags: -Z continue-parse-after-error - // ignore-tidy-cr // ignore-tidy-tab + fn main() { // these literals are just silly. '''; diff --git a/src/test/ui/parser/bad-char-literals.stderr b/src/test/ui/parser/bad-char-literals.stderr index 8e96ea22771b8..093978fd84d00 100644 --- a/src/test/ui/parser/bad-char-literals.stderr +++ b/src/test/ui/parser/bad-char-literals.stderr @@ -1,11 +1,11 @@ error: character constant must be escaped: ' - --> $DIR/bad-char-literals.rs:7:6 + --> $DIR/bad-char-literals.rs:6:6 | LL | '''; | ^ error: character constant must be escaped: \n - --> $DIR/bad-char-literals.rs:11:6 + --> $DIR/bad-char-literals.rs:10:6 | LL | ' | ______^ @@ -13,13 +13,13 @@ LL | | '; | |_ error: character constant must be escaped: \r - --> $DIR/bad-char-literals.rs:16:6 + --> $DIR/bad-char-literals.rs:15:6 | LL | ' '; | ^ error: character constant must be escaped: \t - --> $DIR/bad-char-literals.rs:19:6 + --> $DIR/bad-char-literals.rs:18:6 | LL | ' '; | ^^^^ diff --git a/src/test/ui/parser/byte-literals.rs b/src/test/ui/parser/byte-literals.rs index bd358af29843a..dadf3971220f7 100644 --- a/src/test/ui/parser/byte-literals.rs +++ b/src/test/ui/parser/byte-literals.rs @@ -1,6 +1,3 @@ -// compile-flags: -Z continue-parse-after-error - - // ignore-tidy-tab static FOO: u8 = b'\f'; //~ ERROR unknown byte escape diff --git a/src/test/ui/parser/byte-literals.stderr b/src/test/ui/parser/byte-literals.stderr index 58a5797b90776..53d50af88d33b 100644 --- a/src/test/ui/parser/byte-literals.stderr +++ b/src/test/ui/parser/byte-literals.stderr @@ -1,41 +1,41 @@ error: unknown byte escape: f - --> $DIR/byte-literals.rs:6:21 + --> $DIR/byte-literals.rs:3:21 | LL | static FOO: u8 = b'\f'; | ^ unknown byte escape error: unknown byte escape: f - --> $DIR/byte-literals.rs:9:8 + --> $DIR/byte-literals.rs:6:8 | LL | b'\f'; | ^ unknown byte escape error: invalid character in numeric character escape: Z - --> $DIR/byte-literals.rs:10:10 + --> $DIR/byte-literals.rs:7:10 | LL | b'\x0Z'; | ^ error: byte constant must be escaped: \t - --> $DIR/byte-literals.rs:11:7 + --> $DIR/byte-literals.rs:8:7 | LL | b' '; | ^^^^ error: byte constant must be escaped: ' - --> $DIR/byte-literals.rs:12:7 + --> $DIR/byte-literals.rs:9:7 | LL | b'''; | ^ error: byte constant must be ASCII. Use a \xHH escape for a non-ASCII byte - --> $DIR/byte-literals.rs:13:7 + --> $DIR/byte-literals.rs:10:7 | LL | b'é'; | ^ error: unterminated byte constant - --> $DIR/byte-literals.rs:14:6 + --> $DIR/byte-literals.rs:11:6 | LL | b'a | ^^^^ diff --git a/src/test/ui/parser/byte-string-literals.rs b/src/test/ui/parser/byte-string-literals.rs index 8d8ee4da98717..caffd9efbed37 100644 --- a/src/test/ui/parser/byte-string-literals.rs +++ b/src/test/ui/parser/byte-string-literals.rs @@ -1,5 +1,3 @@ -// compile-flags: -Z continue-parse-after-error - static FOO: &'static [u8] = b"\f"; //~ ERROR unknown byte escape pub fn main() { diff --git a/src/test/ui/parser/byte-string-literals.stderr b/src/test/ui/parser/byte-string-literals.stderr index eeb2fcd12320b..ca964cd4b8f21 100644 --- a/src/test/ui/parser/byte-string-literals.stderr +++ b/src/test/ui/parser/byte-string-literals.stderr @@ -1,29 +1,29 @@ error: unknown byte escape: f - --> $DIR/byte-string-literals.rs:3:32 + --> $DIR/byte-string-literals.rs:1:32 | LL | static FOO: &'static [u8] = b"\f"; | ^ unknown byte escape error: unknown byte escape: f - --> $DIR/byte-string-literals.rs:6:8 + --> $DIR/byte-string-literals.rs:4:8 | LL | b"\f"; | ^ unknown byte escape error: invalid character in numeric character escape: Z - --> $DIR/byte-string-literals.rs:7:10 + --> $DIR/byte-string-literals.rs:5:10 | LL | b"\x0Z"; | ^ error: byte constant must be ASCII. Use a \xHH escape for a non-ASCII byte - --> $DIR/byte-string-literals.rs:8:7 + --> $DIR/byte-string-literals.rs:6:7 | LL | b"é"; | ^ error: unterminated double quote byte string - --> $DIR/byte-string-literals.rs:9:6 + --> $DIR/byte-string-literals.rs:7:6 | LL | b"a | ______^ diff --git a/src/test/ui/parser/impl-parsing.rs b/src/test/ui/parser/impl-parsing.rs index c2a80e8fa1594..270c8b43dfd5e 100644 --- a/src/test/ui/parser/impl-parsing.rs +++ b/src/test/ui/parser/impl-parsing.rs @@ -1,5 +1,3 @@ -// compile-flags: -Z continue-parse-after-error - impl ! {} // OK impl ! where u8: Copy {} // OK diff --git a/src/test/ui/parser/impl-parsing.stderr b/src/test/ui/parser/impl-parsing.stderr index e929fa53620f6..7c2a7937c5da7 100644 --- a/src/test/ui/parser/impl-parsing.stderr +++ b/src/test/ui/parser/impl-parsing.stderr @@ -1,29 +1,29 @@ error: missing `for` in a trait impl - --> $DIR/impl-parsing.rs:6:11 + --> $DIR/impl-parsing.rs:4:11 | LL | impl Trait Type {} | ^ help: add `for` here error: missing `for` in a trait impl - --> $DIR/impl-parsing.rs:7:11 + --> $DIR/impl-parsing.rs:5:11 | LL | impl Trait .. {} | ^ help: add `for` here error: expected a trait, found type - --> $DIR/impl-parsing.rs:8:6 + --> $DIR/impl-parsing.rs:6:6 | LL | impl ?Sized for Type {} | ^^^^^^ error: expected a trait, found type - --> $DIR/impl-parsing.rs:9:6 + --> $DIR/impl-parsing.rs:7:6 | LL | impl ?Sized for .. {} | ^^^^^^ error: expected `impl`, found `FAIL` - --> $DIR/impl-parsing.rs:11:16 + --> $DIR/impl-parsing.rs:9:16 | LL | default unsafe FAIL | ^^^^ expected `impl` diff --git a/src/test/ui/parser/issue-23620-invalid-escapes.rs b/src/test/ui/parser/issue-23620-invalid-escapes.rs index 53629973a1b5f..ab445a9329426 100644 --- a/src/test/ui/parser/issue-23620-invalid-escapes.rs +++ b/src/test/ui/parser/issue-23620-invalid-escapes.rs @@ -1,5 +1,3 @@ -// compile-flags: -Z continue-parse-after-error - fn main() { let _ = b"\u{a66e}"; //~^ ERROR unicode escape sequences cannot be used as a byte or in a byte string diff --git a/src/test/ui/parser/issue-23620-invalid-escapes.stderr b/src/test/ui/parser/issue-23620-invalid-escapes.stderr index 5fabc1d7e4326..b391ac75bf8d1 100644 --- a/src/test/ui/parser/issue-23620-invalid-escapes.stderr +++ b/src/test/ui/parser/issue-23620-invalid-escapes.stderr @@ -1,17 +1,17 @@ error: unicode escape sequences cannot be used as a byte or in a byte string - --> $DIR/issue-23620-invalid-escapes.rs:4:15 + --> $DIR/issue-23620-invalid-escapes.rs:2:15 | LL | let _ = b"\u{a66e}"; | ^^^^^^^^ error: unicode escape sequences cannot be used as a byte or in a byte string - --> $DIR/issue-23620-invalid-escapes.rs:7:15 + --> $DIR/issue-23620-invalid-escapes.rs:5:15 | LL | let _ = b'\u{a66e}'; | ^^^^^^^^ error: incorrect unicode escape sequence - --> $DIR/issue-23620-invalid-escapes.rs:10:15 + --> $DIR/issue-23620-invalid-escapes.rs:8:15 | LL | let _ = b'\u'; | ^^ incorrect unicode escape sequence @@ -19,43 +19,43 @@ LL | let _ = b'\u'; = help: format of unicode escape sequences is `\u{...}` error: numeric character escape is too short - --> $DIR/issue-23620-invalid-escapes.rs:13:15 + --> $DIR/issue-23620-invalid-escapes.rs:11:15 | LL | let _ = b'\x5'; | ^^^ error: invalid character in numeric character escape: x - --> $DIR/issue-23620-invalid-escapes.rs:16:17 + --> $DIR/issue-23620-invalid-escapes.rs:14:17 | LL | let _ = b'\xxy'; | ^ error: numeric character escape is too short - --> $DIR/issue-23620-invalid-escapes.rs:19:14 + --> $DIR/issue-23620-invalid-escapes.rs:17:14 | LL | let _ = '\x5'; | ^^^ error: invalid character in numeric character escape: x - --> $DIR/issue-23620-invalid-escapes.rs:22:16 + --> $DIR/issue-23620-invalid-escapes.rs:20:16 | LL | let _ = '\xxy'; | ^ error: unicode escape sequences cannot be used as a byte or in a byte string - --> $DIR/issue-23620-invalid-escapes.rs:25:15 + --> $DIR/issue-23620-invalid-escapes.rs:23:15 | LL | let _ = b"\u{a4a4} \xf \u"; | ^^^^^^^^ error: invalid character in numeric character escape: - --> $DIR/issue-23620-invalid-escapes.rs:25:27 + --> $DIR/issue-23620-invalid-escapes.rs:23:27 | LL | let _ = b"\u{a4a4} \xf \u"; | ^ error: incorrect unicode escape sequence - --> $DIR/issue-23620-invalid-escapes.rs:25:28 + --> $DIR/issue-23620-invalid-escapes.rs:23:28 | LL | let _ = b"\u{a4a4} \xf \u"; | ^^ incorrect unicode escape sequence @@ -63,13 +63,13 @@ LL | let _ = b"\u{a4a4} \xf \u"; = help: format of unicode escape sequences is `\u{...}` error: invalid character in numeric character escape: - --> $DIR/issue-23620-invalid-escapes.rs:30:17 + --> $DIR/issue-23620-invalid-escapes.rs:28:17 | LL | let _ = "\xf \u"; | ^ error: incorrect unicode escape sequence - --> $DIR/issue-23620-invalid-escapes.rs:30:18 + --> $DIR/issue-23620-invalid-escapes.rs:28:18 | LL | let _ = "\xf \u"; | ^^ incorrect unicode escape sequence @@ -77,7 +77,7 @@ LL | let _ = "\xf \u"; = help: format of unicode escape sequences is `\u{...}` error: incorrect unicode escape sequence - --> $DIR/issue-23620-invalid-escapes.rs:34:14 + --> $DIR/issue-23620-invalid-escapes.rs:32:14 | LL | let _ = "\u8f"; | ^^-- diff --git a/src/test/ui/parser/issue-62913.rs b/src/test/ui/parser/issue-62913.rs index cfa19a2a310a2..0db06f636c3ec 100644 --- a/src/test/ui/parser/issue-62913.rs +++ b/src/test/ui/parser/issue-62913.rs @@ -1,3 +1,4 @@ "\u\\" //~^ ERROR incorrect unicode escape sequence //~| ERROR invalid trailing slash in literal +//~| ERROR expected item, found `"\u\\"` diff --git a/src/test/ui/parser/issue-62913.stderr b/src/test/ui/parser/issue-62913.stderr index 05c5c4d000a86..f72174f8929b8 100644 --- a/src/test/ui/parser/issue-62913.stderr +++ b/src/test/ui/parser/issue-62913.stderr @@ -12,5 +12,11 @@ error: invalid trailing slash in literal LL | "\u\" | ^ -error: aborting due to 2 previous errors +error: expected item, found `"\u\"` + --> $DIR/issue-62913.rs:1:1 + | +LL | "\u\" + | ^^^^^^ expected item + +error: aborting due to 3 previous errors diff --git a/src/test/ui/parser/lex-bad-char-literals-1.rs b/src/test/ui/parser/lex-bad-char-literals-1.rs index 54d75ed682d0d..e7951cfd2d20c 100644 --- a/src/test/ui/parser/lex-bad-char-literals-1.rs +++ b/src/test/ui/parser/lex-bad-char-literals-1.rs @@ -1,4 +1,3 @@ -// compile-flags: -Z continue-parse-after-error static c3: char = '\x1' //~ ERROR: numeric character escape is too short ; 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 000d155c26833..fcf4802f79bba 100644 --- a/src/test/ui/parser/lex-bad-char-literals-1.stderr +++ b/src/test/ui/parser/lex-bad-char-literals-1.stderr @@ -1,23 +1,23 @@ error: numeric character escape is too short - --> $DIR/lex-bad-char-literals-1.rs:3:6 + --> $DIR/lex-bad-char-literals-1.rs:2:6 | LL | '\x1' | ^^^ error: numeric character escape is too short - --> $DIR/lex-bad-char-literals-1.rs:7:6 + --> $DIR/lex-bad-char-literals-1.rs:6:6 | LL | "\x1" | ^^^ error: unknown character escape: \u{25cf} - --> $DIR/lex-bad-char-literals-1.rs:11:7 + --> $DIR/lex-bad-char-literals-1.rs:10:7 | LL | '\●' | ^ unknown character escape error: unknown character escape: \u{25cf} - --> $DIR/lex-bad-char-literals-1.rs:15:7 + --> $DIR/lex-bad-char-literals-1.rs:14:7 | LL | "\●" | ^ unknown character escape diff --git a/src/test/ui/parser/lex-bad-char-literals-7.rs b/src/test/ui/parser/lex-bad-char-literals-7.rs index 70eafcb91dacb..1580157210e69 100644 --- a/src/test/ui/parser/lex-bad-char-literals-7.rs +++ b/src/test/ui/parser/lex-bad-char-literals-7.rs @@ -1,4 +1,3 @@ -// compile-flags: -Z continue-parse-after-error fn main() { let _: char = ''; //~^ ERROR: empty character literal diff --git a/src/test/ui/parser/lex-bad-char-literals-7.stderr b/src/test/ui/parser/lex-bad-char-literals-7.stderr index e1ba3c3ee0f17..ee9aa86935299 100644 --- a/src/test/ui/parser/lex-bad-char-literals-7.stderr +++ b/src/test/ui/parser/lex-bad-char-literals-7.stderr @@ -1,17 +1,17 @@ error: empty character literal - --> $DIR/lex-bad-char-literals-7.rs:3:20 + --> $DIR/lex-bad-char-literals-7.rs:2:20 | LL | let _: char = ''; | ^ error: empty unicode escape (must have at least 1 hex digit) - --> $DIR/lex-bad-char-literals-7.rs:5:20 + --> $DIR/lex-bad-char-literals-7.rs:4:20 | LL | let _: char = '\u{}'; | ^^^^ error: unterminated character literal - --> $DIR/lex-bad-char-literals-7.rs:12:13 + --> $DIR/lex-bad-char-literals-7.rs:11:13 | LL | let _ = ' hello // here's a comment | ^^^^^^^^ diff --git a/src/test/ui/parser/lex-bare-cr-string-literal-doc-comment.rs b/src/test/ui/parser/lex-bare-cr-string-literal-doc-comment.rs index b588b007ae929..9a9f9c433e1d6 100644 --- a/src/test/ui/parser/lex-bare-cr-string-literal-doc-comment.rs +++ b/src/test/ui/parser/lex-bare-cr-string-literal-doc-comment.rs @@ -1,5 +1,3 @@ -// compile-flags: -Z continue-parse-after-error - // ignore-tidy-cr /// doc comment with bare CR: ' ' 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 b0fe4b6acd484..598da6b930730 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 @@ -1,41 +1,41 @@ error: bare CR not allowed in doc-comment - --> $DIR/lex-bare-cr-string-literal-doc-comment.rs:5:32 + --> $DIR/lex-bare-cr-string-literal-doc-comment.rs:3:32 | LL | /// doc comment with bare CR: ' ' | ^ error: bare CR not allowed in block doc-comment - --> $DIR/lex-bare-cr-string-literal-doc-comment.rs:9:38 + --> $DIR/lex-bare-cr-string-literal-doc-comment.rs:7:38 | LL | /** block doc comment with bare CR: ' ' */ | ^ error: bare CR not allowed in doc-comment - --> $DIR/lex-bare-cr-string-literal-doc-comment.rs:14:36 + --> $DIR/lex-bare-cr-string-literal-doc-comment.rs:12:36 | LL | //! doc comment with bare CR: ' ' | ^ error: bare CR not allowed in block doc-comment - --> $DIR/lex-bare-cr-string-literal-doc-comment.rs:17:42 + --> $DIR/lex-bare-cr-string-literal-doc-comment.rs:15:42 | LL | /*! block doc comment with bare CR: ' ' */ | ^ error: bare CR not allowed in string, use \r instead - --> $DIR/lex-bare-cr-string-literal-doc-comment.rs:21:18 + --> $DIR/lex-bare-cr-string-literal-doc-comment.rs:19:18 | LL | let _s = "foo bar"; | ^ error: bare CR not allowed in raw string - --> $DIR/lex-bare-cr-string-literal-doc-comment.rs:24:19 + --> $DIR/lex-bare-cr-string-literal-doc-comment.rs:22:19 | LL | let _s = r"bar foo"; | ^ error: unknown character escape: \r - --> $DIR/lex-bare-cr-string-literal-doc-comment.rs:27:19 + --> $DIR/lex-bare-cr-string-literal-doc-comment.rs:25:19 | LL | let _s = "foo\ bar"; | ^ unknown character escape diff --git a/src/test/ui/parser/raw-byte-string-literals.rs b/src/test/ui/parser/raw-byte-string-literals.rs index 534afabdf777e..163c8ac66b022 100644 --- a/src/test/ui/parser/raw-byte-string-literals.rs +++ b/src/test/ui/parser/raw-byte-string-literals.rs @@ -1,5 +1,5 @@ // ignore-tidy-cr -// compile-flags: -Z continue-parse-after-error + pub fn main() { br"a "; //~ ERROR bare CR not allowed in raw string br"é"; //~ ERROR raw byte string must be ASCII diff --git a/src/test/ui/parser/type-parameters-in-field-exprs.rs b/src/test/ui/parser/type-parameters-in-field-exprs.rs index 1b8ed9f12b880..6a3b2c1c60605 100644 --- a/src/test/ui/parser/type-parameters-in-field-exprs.rs +++ b/src/test/ui/parser/type-parameters-in-field-exprs.rs @@ -1,5 +1,3 @@ -// compile-flags: -Z continue-parse-after-error - struct Foo { x: isize, y: isize, diff --git a/src/test/ui/parser/type-parameters-in-field-exprs.stderr b/src/test/ui/parser/type-parameters-in-field-exprs.stderr index 8f32fb0eca106..306b4754d0d69 100644 --- a/src/test/ui/parser/type-parameters-in-field-exprs.stderr +++ b/src/test/ui/parser/type-parameters-in-field-exprs.stderr @@ -1,17 +1,17 @@ error: field expressions may not have generic arguments - --> $DIR/type-parameters-in-field-exprs.rs:13:10 + --> $DIR/type-parameters-in-field-exprs.rs:11:10 | LL | f.x::; | ^^^^^^^ error: field expressions may not have generic arguments - --> $DIR/type-parameters-in-field-exprs.rs:15:10 + --> $DIR/type-parameters-in-field-exprs.rs:13:10 | LL | f.x::<>; | ^^ error: field expressions may not have generic arguments - --> $DIR/type-parameters-in-field-exprs.rs:17:7 + --> $DIR/type-parameters-in-field-exprs.rs:15:7 | LL | f.x::(); | ^^^^^