From 37f5cc22391e693523e8320a1d5c214610790911 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Mon, 2 Sep 2019 18:03:54 -0700 Subject: [PATCH 01/27] Do not complain about unconstrained params when Self is Ty Error --- .../constrained_generic_params.rs | 18 ++++++++---------- src/librustc_typeck/impl_wf_check.rs | 4 ++++ src/test/ui/issues/issue-36836.rs | 5 +++++ src/test/ui/issues/issue-36836.stderr | 9 +++++++++ 4 files changed, 26 insertions(+), 10 deletions(-) create mode 100644 src/test/ui/issues/issue-36836.rs create mode 100644 src/test/ui/issues/issue-36836.stderr diff --git a/src/librustc_typeck/constrained_generic_params.rs b/src/librustc_typeck/constrained_generic_params.rs index 79a04b9423a8e..c95f81506cd59 100644 --- a/src/librustc_typeck/constrained_generic_params.rs +++ b/src/librustc_typeck/constrained_generic_params.rs @@ -20,10 +20,10 @@ impl From for Parameter { } /// Returns the set of parameters constrained by the impl header. -pub fn parameters_for_impl<'tcx>(impl_self_ty: Ty<'tcx>, - impl_trait_ref: Option>) - -> FxHashSet -{ +pub fn parameters_for_impl<'tcx>( + impl_self_ty: Ty<'tcx>, + impl_trait_ref: Option>, +) -> FxHashSet { let vec = match impl_trait_ref { Some(tr) => parameters_for(&tr, false), None => parameters_for(&impl_self_ty, false), @@ -36,12 +36,10 @@ pub fn parameters_for_impl<'tcx>(impl_self_ty: Ty<'tcx>, /// uniquely determined by `t` (see RFC 447). If it is true, return the list /// of parameters whose values are needed in order to constrain `ty` - these /// differ, with the latter being a superset, in the presence of projections. -pub fn parameters_for<'tcx, T>(t: &T, - include_nonconstraining: bool) - -> Vec - where T: TypeFoldable<'tcx> -{ - +pub fn parameters_for<'tcx, T: TypeFoldable<'tcx>>( + t: &T, + include_nonconstraining: bool, +) -> Vec { let mut collector = ParameterCollector { parameters: vec![], include_nonconstraining, diff --git a/src/librustc_typeck/impl_wf_check.rs b/src/librustc_typeck/impl_wf_check.rs index fcfd9adef54df..8e69fbd9a79ef 100644 --- a/src/librustc_typeck/impl_wf_check.rs +++ b/src/librustc_typeck/impl_wf_check.rs @@ -99,6 +99,10 @@ fn enforce_impl_params_are_constrained( ) { // Every lifetime used in an associated type must be constrained. let impl_self_ty = tcx.type_of(impl_def_id); + if impl_self_ty.sty == ty::Error { + // Don't complain about unconstrained type params when self ty doesn't exist. (#36836) + return; + } let impl_generics = tcx.generics_of(impl_def_id); let impl_predicates = tcx.predicates_of(impl_def_id); let impl_trait_ref = tcx.impl_trait_ref(impl_def_id); diff --git a/src/test/ui/issues/issue-36836.rs b/src/test/ui/issues/issue-36836.rs new file mode 100644 index 0000000000000..56d5a7cca4566 --- /dev/null +++ b/src/test/ui/issues/issue-36836.rs @@ -0,0 +1,5 @@ +trait Foo {} + +impl Foo for Bar {} //~ ERROR cannot find type `Bar` in this scope + +fn main() {} diff --git a/src/test/ui/issues/issue-36836.stderr b/src/test/ui/issues/issue-36836.stderr new file mode 100644 index 0000000000000..bfda9b0bbdd7e --- /dev/null +++ b/src/test/ui/issues/issue-36836.stderr @@ -0,0 +1,9 @@ +error[E0412]: cannot find type `Bar` in this scope + --> $DIR/issue-36836.rs:3:17 + | +LL | impl Foo for Bar {} + | ^^^ not found in this scope + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0412`. From 3cb1ed4279d8ca4528e3777d5470ca7dc85a976a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Mon, 2 Sep 2019 20:51:31 -0700 Subject: [PATCH 02/27] review comments --- src/librustc_typeck/constrained_generic_params.rs | 4 ++-- src/test/ui/issues/issue-36836.rs | 10 ++++++++++ src/test/ui/issues/issue-36836.stderr | 2 +- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/librustc_typeck/constrained_generic_params.rs b/src/librustc_typeck/constrained_generic_params.rs index c95f81506cd59..dd44f86717fe5 100644 --- a/src/librustc_typeck/constrained_generic_params.rs +++ b/src/librustc_typeck/constrained_generic_params.rs @@ -36,8 +36,8 @@ pub fn parameters_for_impl<'tcx>( /// uniquely determined by `t` (see RFC 447). If it is true, return the list /// of parameters whose values are needed in order to constrain `ty` - these /// differ, with the latter being a superset, in the presence of projections. -pub fn parameters_for<'tcx, T: TypeFoldable<'tcx>>( - t: &T, +pub fn parameters_for<'tcx>( + t: &impl TypeFoldable<'tcx>, include_nonconstraining: bool, ) -> Vec { let mut collector = ParameterCollector { diff --git a/src/test/ui/issues/issue-36836.rs b/src/test/ui/issues/issue-36836.rs index 56d5a7cca4566..99c56213153e4 100644 --- a/src/test/ui/issues/issue-36836.rs +++ b/src/test/ui/issues/issue-36836.rs @@ -1,3 +1,13 @@ +// Previously, in addition to the real cause of the problem as seen below, +// the compiler would tell the user: +// +// ``` +// error[E0207]: the type parameter `T` is not constrained by the impl trait, self type, or +// predicates +// ``` +// +// With this test, we check that only the relevant error is emitted. + trait Foo {} impl Foo for Bar {} //~ ERROR cannot find type `Bar` in this scope diff --git a/src/test/ui/issues/issue-36836.stderr b/src/test/ui/issues/issue-36836.stderr index bfda9b0bbdd7e..418194fac9923 100644 --- a/src/test/ui/issues/issue-36836.stderr +++ b/src/test/ui/issues/issue-36836.stderr @@ -1,5 +1,5 @@ error[E0412]: cannot find type `Bar` in this scope - --> $DIR/issue-36836.rs:3:17 + --> $DIR/issue-36836.rs:13:17 | LL | impl Foo for Bar {} | ^^^ not found in this scope From 87866714ee1cf3fba6e659f46413e361b9088362 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Tue, 3 Sep 2019 08:12:28 -0700 Subject: [PATCH 03/27] fix comment and add delay_span_bug --- src/librustc_typeck/impl_wf_check.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/librustc_typeck/impl_wf_check.rs b/src/librustc_typeck/impl_wf_check.rs index 8e69fbd9a79ef..82acbf7c74803 100644 --- a/src/librustc_typeck/impl_wf_check.rs +++ b/src/librustc_typeck/impl_wf_check.rs @@ -12,7 +12,7 @@ use crate::constrained_generic_params as cgp; use rustc::hir; use rustc::hir::itemlikevisit::ItemLikeVisitor; use rustc::hir::def_id::DefId; -use rustc::ty::{self, TyCtxt}; +use rustc::ty::{self, TyCtxt, TypeFoldable}; use rustc::ty::query::Providers; use rustc::util::nodemap::{FxHashMap, FxHashSet}; use std::collections::hash_map::Entry::{Occupied, Vacant}; @@ -99,8 +99,13 @@ fn enforce_impl_params_are_constrained( ) { // Every lifetime used in an associated type must be constrained. let impl_self_ty = tcx.type_of(impl_def_id); - if impl_self_ty.sty == ty::Error { - // Don't complain about unconstrained type params when self ty doesn't exist. (#36836) + if impl_self_ty.references_error() { + // Don't complain about unconstrained type params when self ty isn't known due to errors. + // (#36836) + tcx.sess.delay_span_bug(tcx.def_span(impl_def_id), &format( + "potentially unconstrained type parameters weren't evaluated on `{:?}`", + impl_self_ty, + )); return; } let impl_generics = tcx.generics_of(impl_def_id); From c44ffafab902e687ef01d2366a7de7237e25245c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Tue, 3 Sep 2019 08:33:06 -0700 Subject: [PATCH 04/27] review comment --- src/librustc_typeck/impl_wf_check.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/librustc_typeck/impl_wf_check.rs b/src/librustc_typeck/impl_wf_check.rs index 82acbf7c74803..bc0f17c3bf0fb 100644 --- a/src/librustc_typeck/impl_wf_check.rs +++ b/src/librustc_typeck/impl_wf_check.rs @@ -102,10 +102,10 @@ fn enforce_impl_params_are_constrained( if impl_self_ty.references_error() { // Don't complain about unconstrained type params when self ty isn't known due to errors. // (#36836) - tcx.sess.delay_span_bug(tcx.def_span(impl_def_id), &format( - "potentially unconstrained type parameters weren't evaluated on `{:?}`", - impl_self_ty, - )); + tcx.sess.delay_span_bug( + tcx.def_span(impl_def_id), + "potentially unconstrained type parameters weren't evaluated", + ); return; } let impl_generics = tcx.generics_of(impl_def_id); From 78908f2e0963ceed461e9961020226d3e12c5978 Mon Sep 17 00:00:00 2001 From: Tim Vermeulen Date: Tue, 3 Sep 2019 11:56:08 +0200 Subject: [PATCH 05/27] Override `StepBy::{try_fold, try_rfold}` --- src/libcore/iter/adapters/mod.rs | 44 +++++++++++++++++++++++++++++++- src/libcore/tests/iter.rs | 35 +++++++++++++++++++++++++ 2 files changed, 78 insertions(+), 1 deletion(-) diff --git a/src/libcore/iter/adapters/mod.rs b/src/libcore/iter/adapters/mod.rs index f50781890ab22..7c9dde81a48fb 100644 --- a/src/libcore/iter/adapters/mod.rs +++ b/src/libcore/iter/adapters/mod.rs @@ -5,7 +5,7 @@ use crate::usize; use crate::intrinsics; use super::{Iterator, DoubleEndedIterator, ExactSizeIterator, FusedIterator, TrustedLen}; -use super::LoopState; +use super::{LoopState, from_fn}; mod chain; mod flatten; @@ -541,6 +541,26 @@ impl Iterator for StepBy where I: Iterator { self.iter.nth(nth - 1); } } + + fn try_fold(&mut self, mut acc: Acc, mut f: F) -> R + where + F: FnMut(Acc, Self::Item) -> R, + R: Try, + { + #[inline] + fn nth(iter: &mut I, step: usize) -> impl FnMut() -> Option + '_ { + move || iter.nth(step) + } + + if self.first_take { + self.first_take = false; + match self.iter.next() { + None => return Try::from_ok(acc), + Some(x) => acc = f(acc, x)?, + } + } + from_fn(nth(&mut self.iter, self.step)).try_fold(acc, f) + } } impl StepBy where I: ExactSizeIterator { @@ -574,6 +594,28 @@ impl DoubleEndedIterator for StepBy where I: DoubleEndedIterator + ExactSi .saturating_add(self.next_back_index()); self.iter.nth_back(n) } + + fn try_rfold(&mut self, init: Acc, mut f: F) -> R + where + F: FnMut(Acc, Self::Item) -> R, + R: Try, + { + #[inline] + fn nth_back( + iter: &mut I, + step: usize, + ) -> impl FnMut() -> Option + '_ { + move || iter.nth_back(step) + } + + match self.next_back() { + None => Try::from_ok(init), + Some(x) => { + let acc = f(init, x)?; + from_fn(nth_back(&mut self.iter, self.step)).try_fold(acc, f) + } + } + } } // StepBy can only make the iterator shorter, so the len will still fit. diff --git a/src/libcore/tests/iter.rs b/src/libcore/tests/iter.rs index 3a4f76852a0d7..f52899b500a3a 100644 --- a/src/libcore/tests/iter.rs +++ b/src/libcore/tests/iter.rs @@ -329,6 +329,23 @@ fn test_iterator_step_by_nth_overflow() { assert_eq!(it.0, (usize::MAX as Bigger) * 1); } +#[test] +fn test_iterator_step_by_nth_try_fold() { + let mut it = (0..).step_by(10); + assert_eq!(it.try_fold(0, i8::checked_add), None); + assert_eq!(it.next(), Some(60)); + assert_eq!(it.try_fold(0, i8::checked_add), None); + assert_eq!(it.next(), Some(90)); + + let mut it = (100..).step_by(10); + assert_eq!(it.try_fold(50, i8::checked_add), None); + assert_eq!(it.next(), Some(110)); + + let mut it = (100..=100).step_by(10); + assert_eq!(it.next(), Some(100)); + assert_eq!(it.try_fold(0, i8::checked_add), Some(0)); +} + #[test] fn test_iterator_step_by_nth_back() { let mut it = (0..16).step_by(5); @@ -354,6 +371,24 @@ fn test_iterator_step_by_nth_back() { assert_eq!(it().nth_back(42), None); } +#[test] +fn test_iterator_step_by_nth_try_rfold() { + let mut it = (0..100).step_by(10); + assert_eq!(it.try_rfold(0, i8::checked_add), None); + assert_eq!(it.next_back(), Some(70)); + assert_eq!(it.next(), Some(0)); + assert_eq!(it.try_rfold(0, i8::checked_add), None); + assert_eq!(it.next_back(), Some(30)); + + let mut it = (0..100).step_by(10); + assert_eq!(it.try_rfold(50, i8::checked_add), None); + assert_eq!(it.next_back(), Some(80)); + + let mut it = (100..=100).step_by(10); + assert_eq!(it.next_back(), Some(100)); + assert_eq!(it.try_fold(0, i8::checked_add), Some(0)); +} + #[test] #[should_panic] fn test_iterator_step_by_zero() { From 961a4da08e7ec1ed15cce6170566332646bd65cb Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Mon, 29 Jul 2019 23:29:14 +0200 Subject: [PATCH 06/27] Stabilize bind_by_move_pattern_guards in 1.39.0. --- src/librustc_mir/hair/pattern/check_match.rs | 90 +------------------- src/libsyntax/feature_gate/accepted.rs | 2 + src/libsyntax/feature_gate/active.rs | 3 - 3 files changed, 6 insertions(+), 89 deletions(-) diff --git a/src/librustc_mir/hair/pattern/check_match.rs b/src/librustc_mir/hair/pattern/check_match.rs index 5352888006c30..1b4b56082a696 100644 --- a/src/librustc_mir/hair/pattern/check_match.rs +++ b/src/librustc_mir/hair/pattern/check_match.rs @@ -5,11 +5,6 @@ use super::_match::WitnessPreference::*; use super::{Pattern, PatternContext, PatternError, PatternKind}; use rustc::middle::borrowck::SignalledError; -use rustc::middle::expr_use_visitor::{ConsumeMode, Delegate, ExprUseVisitor}; -use rustc::middle::expr_use_visitor::{LoanCause, MutateMode}; -use rustc::middle::expr_use_visitor as euv; -use rustc::middle::mem_categorization::cmt_; -use rustc::middle::region; use rustc::session::Session; use rustc::ty::{self, Ty, TyCtxt}; use rustc::ty::subst::{InternalSubsts, SubstsRef}; @@ -36,9 +31,7 @@ crate fn check_match(tcx: TyCtxt<'_>, def_id: DefId) -> SignalledError { let mut visitor = MatchVisitor { tcx, - body_owner: def_id, tables: tcx.body_tables(body_id), - region_scope_tree: &tcx.region_scope_tree(def_id), param_env: tcx.param_env(def_id), identity_substs: InternalSubsts::identity_for_item(tcx, def_id), signalled_error: SignalledError::NoErrorsSeen, @@ -53,11 +46,9 @@ fn create_e0004(sess: &Session, sp: Span, error_message: String) -> DiagnosticBu struct MatchVisitor<'a, 'tcx> { tcx: TyCtxt<'tcx>, - body_owner: DefId, tables: &'a ty::TypeckTables<'tcx>, param_env: ty::ParamEnv<'tcx>, identity_substs: SubstsRef<'tcx>, - region_scope_tree: &'a region::ScopeTree, signalled_error: SignalledError, } @@ -151,11 +142,8 @@ impl<'a, 'tcx> MatchVisitor<'a, 'tcx> { // Second, if there is a guard on each arm, make sure it isn't // assigning or borrowing anything mutably. - if let Some(ref guard) = arm.guard { + if arm.guard.is_some() { self.signalled_error = SignalledError::SawSomeError; - if !self.tcx.features().bind_by_move_pattern_guards { - check_for_mutation_in_guard(self, &guard); - } } // Third, perform some lints. @@ -582,19 +570,10 @@ fn check_legality_of_move_bindings( "cannot bind by-move with sub-bindings") .span_label(p.span, "binds an already bound by-move value by moving it") .emit(); - } else if has_guard { - if !cx.tcx.features().bind_by_move_pattern_guards { - let mut err = struct_span_err!(cx.tcx.sess, p.span, E0008, - "cannot bind by-move into a pattern guard"); - err.span_label(p.span, "moves value into pattern guard"); - if cx.tcx.sess.opts.unstable_features.is_nightly_build() { - err.help("add `#![feature(bind_by_move_pattern_guards)]` to the \ - crate attributes to enable"); - } - err.emit(); + } else if !has_guard { + if let Some(_by_ref_span) = by_ref_span { + span_vec.push(p.span); } - } else if let Some(_by_ref_span) = by_ref_span { - span_vec.push(p.span); } }; @@ -636,67 +615,6 @@ fn check_legality_of_move_bindings( } } -/// Ensures that a pattern guard doesn't borrow by mutable reference or assign. -// -// FIXME: this should be done by borrowck. -fn check_for_mutation_in_guard(cx: &MatchVisitor<'_, '_>, guard: &hir::Guard) { - let mut checker = MutationChecker { - cx, - }; - match guard { - hir::Guard::If(expr) => - ExprUseVisitor::new(&mut checker, - cx.tcx, - cx.body_owner, - cx.param_env, - cx.region_scope_tree, - cx.tables, - None).walk_expr(expr), - }; -} - -struct MutationChecker<'a, 'tcx> { - cx: &'a MatchVisitor<'a, 'tcx>, -} - -impl<'a, 'tcx> Delegate<'tcx> for MutationChecker<'a, 'tcx> { - fn matched_pat(&mut self, _: &Pat, _: &cmt_<'_>, _: euv::MatchMode) {} - fn consume(&mut self, _: hir::HirId, _: Span, _: &cmt_<'_>, _: ConsumeMode) {} - fn consume_pat(&mut self, _: &Pat, _: &cmt_<'_>, _: ConsumeMode) {} - fn borrow(&mut self, - _: hir::HirId, - span: Span, - _: &cmt_<'_>, - _: ty::Region<'tcx>, - kind:ty:: BorrowKind, - _: LoanCause) { - match kind { - ty::MutBorrow => { - let mut err = struct_span_err!(self.cx.tcx.sess, span, E0301, - "cannot mutably borrow in a pattern guard"); - err.span_label(span, "borrowed mutably in pattern guard"); - if self.cx.tcx.sess.opts.unstable_features.is_nightly_build() { - err.help("add `#![feature(bind_by_move_pattern_guards)]` to the \ - crate attributes to enable"); - } - err.emit(); - } - ty::ImmBorrow | ty::UniqueImmBorrow => {} - } - } - fn decl_without_init(&mut self, _: hir::HirId, _: Span) {} - fn mutate(&mut self, _: hir::HirId, span: Span, _: &cmt_<'_>, mode: MutateMode) { - match mode { - MutateMode::JustWrite | MutateMode::WriteAndRead => { - struct_span_err!(self.cx.tcx.sess, span, E0302, "cannot assign in a pattern guard") - .span_label(span, "assignment in pattern guard") - .emit(); - } - MutateMode::Init => {} - } - } -} - /// Forbids bindings in `@` patterns. This is necessary for memory safety, /// because of the way rvalues are handled in the borrow check. (See issue /// #14587.) diff --git a/src/libsyntax/feature_gate/accepted.rs b/src/libsyntax/feature_gate/accepted.rs index 6c0b271c6c5e9..eff9f90a8619e 100644 --- a/src/libsyntax/feature_gate/accepted.rs +++ b/src/libsyntax/feature_gate/accepted.rs @@ -241,6 +241,8 @@ declare_features! ( (accepted, underscore_const_names, "1.37.0", Some(54912), None), /// Allows free and inherent `async fn`s, `async` blocks, and `.await` expressions. (accepted, async_await, "1.39.0", Some(50547), None), + /// Allows mixing bind-by-move in patterns and references to those identifiers in guards. + (accepted, bind_by_move_pattern_guards, "1.39.0", Some(15287), None), // ------------------------------------------------------------------------- // feature-group-end: accepted features diff --git a/src/libsyntax/feature_gate/active.rs b/src/libsyntax/feature_gate/active.rs index 5a248df6af252..dd78777b56986 100644 --- a/src/libsyntax/feature_gate/active.rs +++ b/src/libsyntax/feature_gate/active.rs @@ -461,9 +461,6 @@ declare_features! ( /// Allows non-builtin attributes in inner attribute position. (active, custom_inner_attributes, "1.30.0", Some(54726), None), - /// Allows mixing bind-by-move in patterns and references to those identifiers in guards. - (active, bind_by_move_pattern_guards, "1.30.0", Some(15287), None), - /// Allows `impl Trait` in bindings (`let`, `const`, `static`). (active, impl_trait_in_bindings, "1.30.0", Some(63065), None), From 2a21c0f6d10ad843c12f23140cab797aeab0b675 Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Mon, 29 Jul 2019 23:35:43 +0200 Subject: [PATCH 07/27] Update bind_and_guard_matched_candidate docs. --- src/librustc_mir/build/matches/mod.rs | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/librustc_mir/build/matches/mod.rs b/src/librustc_mir/build/matches/mod.rs index 94323b15b696f..f949b529e9762 100644 --- a/src/librustc_mir/build/matches/mod.rs +++ b/src/librustc_mir/build/matches/mod.rs @@ -1345,13 +1345,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { /// any, and then branches to the arm. Returns the block for the case where /// the guard fails. /// - /// Note: we check earlier that if there is a guard, there cannot be move - /// bindings (unless feature(bind_by_move_pattern_guards) is used). This - /// isn't really important for the self-consistency of this fn, but the - /// reason for it should be clear: after we've done the assignments, if - /// there were move bindings, further tests would be a use-after-move. - /// bind_by_move_pattern_guards avoids this by only moving the binding once - /// the guard has evaluated to true (see below). + /// Note: we do not check earlier that if there is a guard, + /// there cannot be move bindings. We avoid a use-after-move by only + /// moving the binding once the guard has evaluated to true (see below). fn bind_and_guard_matched_candidate<'pat>( &mut self, candidate: Candidate<'pat, 'tcx>, From 0356813b27262bf9ceec5f0fa48302262d501cd4 Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Mon, 29 Jul 2019 23:36:58 +0200 Subject: [PATCH 08/27] Dont use gate bind_by_move_pattern_guards internally. --- src/libcore/lib.rs | 2 +- src/librustc_passes/lib.rs | 2 +- src/librustdoc/lib.rs | 2 +- src/libstd/lib.rs | 2 +- src/libsyntax/lib.rs | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/libcore/lib.rs b/src/libcore/lib.rs index c168d5c8a2eac..0b4b6322534f2 100644 --- a/src/libcore/lib.rs +++ b/src/libcore/lib.rs @@ -87,7 +87,7 @@ #![feature(link_llvm_intrinsics)] #![feature(never_type)] #![feature(nll)] -#![feature(bind_by_move_pattern_guards)] +#![cfg_attr(bootstrap, feature(bind_by_move_pattern_guards))] #![feature(exhaustive_patterns)] #![feature(no_core)] #![feature(on_unimplemented)] diff --git a/src/librustc_passes/lib.rs b/src/librustc_passes/lib.rs index cf2da4ffa2af0..a5a8315a1e73f 100644 --- a/src/librustc_passes/lib.rs +++ b/src/librustc_passes/lib.rs @@ -8,7 +8,7 @@ #![feature(in_band_lifetimes)] #![feature(nll)] -#![feature(bind_by_move_pattern_guards)] +#![cfg_attr(bootstrap, feature(bind_by_move_pattern_guards))] #![recursion_limit="256"] diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs index 301946733dc55..25ee8b4273d52 100644 --- a/src/librustdoc/lib.rs +++ b/src/librustdoc/lib.rs @@ -1,7 +1,7 @@ #![doc(html_root_url = "https://doc.rust-lang.org/nightly/", html_playground_url = "https://play.rust-lang.org/")] -#![feature(bind_by_move_pattern_guards)] +#![cfg_attr(bootstrap, feature(bind_by_move_pattern_guards))] #![feature(rustc_private)] #![feature(arbitrary_self_types)] #![feature(box_patterns)] diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs index 71050b0dcd1f5..8a7b66f019669 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs @@ -238,7 +238,7 @@ #![feature(array_error_internals)] #![feature(asm)] #![feature(associated_type_bounds)] -#![feature(bind_by_move_pattern_guards)] +#![cfg_attr(bootstrap, feature(bind_by_move_pattern_guards))] #![feature(box_syntax)] #![feature(c_variadic)] #![feature(cfg_target_has_atomic)] diff --git a/src/libsyntax/lib.rs b/src/libsyntax/lib.rs index 49efbce482fa3..aaf6f3e537eb6 100644 --- a/src/libsyntax/lib.rs +++ b/src/libsyntax/lib.rs @@ -7,7 +7,7 @@ #![doc(html_root_url = "https://doc.rust-lang.org/nightly/", test(attr(deny(warnings))))] -#![feature(bind_by_move_pattern_guards)] +#![cfg_attr(bootstrap, feature(bind_by_move_pattern_guards))] #![feature(box_syntax)] #![feature(const_fn)] #![feature(const_transmute)] From 072942d569b898ef65569a21bd1b73d15cc1caf6 Mon Sep 17 00:00:00 2001 From: Mark Rousskov Date: Sun, 1 Sep 2019 17:05:02 -0400 Subject: [PATCH 09/27] run-pass tests shouldn't have unused contents --- src/tools/compiletest/src/header.rs | 5 +++++ src/tools/compiletest/src/runtest.rs | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/tools/compiletest/src/header.rs b/src/tools/compiletest/src/header.rs index 819d399f34a41..48dd68d0f61ee 100644 --- a/src/tools/compiletest/src/header.rs +++ b/src/tools/compiletest/src/header.rs @@ -628,6 +628,11 @@ impl TestProps { } self.pass_mode } + + // does not consider CLI override for pass mode + pub fn local_pass_mode(&self) -> Option { + self.pass_mode + } } fn iter_header(testfile: &Path, cfg: Option<&str>, it: &mut dyn FnMut(&str)) { diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index 9a3d24facc2c8..aff554678a3f4 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -1557,7 +1557,11 @@ impl<'test> TestCx<'test> { // want to actually assert warnings about all this code. Instead // let's just ignore unused code warnings by defaults and tests // can turn it back on if needed. - if !self.config.src_base.ends_with("rustdoc-ui") { + if !self.config.src_base.ends_with("rustdoc-ui") && + // Note that we don't call pass_mode() here as we don't want + // to set unused to allow if we've overriden the pass mode + // via command line flags. + self.props.local_pass_mode() != Some(PassMode::Run) { rustc.args(&["-A", "unused"]); } } From 642993e6dca427ce3cc5ca97bccaf6f6c872eb16 Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Tue, 30 Jul 2019 01:25:30 +0200 Subject: [PATCH 10/27] Update tests wrt. bind_by_by_move_pattern_guards stabilization. --- src/librustc_mir/error_codes.rs | 1 - src/test/mir-opt/match-arm-scopes.rs | 2 - .../ui/bind-by-move/bind-by-move-no-guards.rs | 13 ------ .../bind-by-move-no-guards.stderr | 11 ----- .../ui/borrowck/borrowck-mutate-in-guard.rs | 7 +--- .../borrowck/borrowck-mutate-in-guard.stderr | 27 ++----------- src/test/ui/error-codes/E0008.rs | 7 ---- src/test/ui/error-codes/E0008.stderr | 11 ----- src/test/ui/error-codes/E0301.rs | 2 +- src/test/ui/error-codes/E0301.stderr | 13 +----- src/test/ui/error-codes/E0302.rs | 2 +- src/test/ui/error-codes/E0302.stderr | 9 +---- ...535-allow-mutable-borrow-in-match-guard.rs | 2 - .../issue-27282-reborrow-ref-mut-in-guard.rs | 2 - ...sue-27282-reborrow-ref-mut-in-guard.stderr | 2 +- src/test/ui/match/match-ref-mut-stability.rs | 2 - src/test/ui/nll/match-cfg-fake-edges.rs | 2 - src/test/ui/nll/match-cfg-fake-edges.stderr | 4 +- .../ui/nll/match-guards-partially-borrow.rs | 2 - .../nll/match-guards-partially-borrow.stderr | 18 ++++----- .../bind-by-move-no-guards.rs | 2 - .../feature-gate.gate_and_2015.stderr | 10 ----- .../feature-gate.gate_and_2018.stderr | 10 ----- .../feature-gate.gate_and_feature_nll.stderr | 10 ----- .../feature-gate.gate_and_znll.stderr | 10 ----- .../feature-gate.no_gate.stderr | 11 ----- .../feature-gate.rs | 40 ------------------- .../former-E0008-now-pass.rs | 11 +++++ .../rfc-basic-examples.rs | 2 - .../rfc-reject-double-move-across-arms.rs | 2 - .../rfc-reject-double-move-across-arms.stderr | 2 +- .../rfc-reject-double-move-in-first-arm.rs | 2 - ...rfc-reject-double-move-in-first-arm.stderr | 2 +- 33 files changed, 35 insertions(+), 218 deletions(-) delete mode 100644 src/test/ui/bind-by-move/bind-by-move-no-guards.rs delete mode 100644 src/test/ui/bind-by-move/bind-by-move-no-guards.stderr delete mode 100644 src/test/ui/error-codes/E0008.rs delete mode 100644 src/test/ui/error-codes/E0008.stderr delete mode 100644 src/test/ui/rfc-0107-bind-by-move-pattern-guards/feature-gate.gate_and_2015.stderr delete mode 100644 src/test/ui/rfc-0107-bind-by-move-pattern-guards/feature-gate.gate_and_2018.stderr delete mode 100644 src/test/ui/rfc-0107-bind-by-move-pattern-guards/feature-gate.gate_and_feature_nll.stderr delete mode 100644 src/test/ui/rfc-0107-bind-by-move-pattern-guards/feature-gate.gate_and_znll.stderr delete mode 100644 src/test/ui/rfc-0107-bind-by-move-pattern-guards/feature-gate.no_gate.stderr delete mode 100644 src/test/ui/rfc-0107-bind-by-move-pattern-guards/feature-gate.rs create mode 100644 src/test/ui/rfc-0107-bind-by-move-pattern-guards/former-E0008-now-pass.rs diff --git a/src/librustc_mir/error_codes.rs b/src/librustc_mir/error_codes.rs index d80449ac23724..844711acbf875 100644 --- a/src/librustc_mir/error_codes.rs +++ b/src/librustc_mir/error_codes.rs @@ -1989,7 +1989,6 @@ When matching on a variable it cannot be mutated in the match guards, as this could cause the match to be non-exhaustive: ```compile_fail,E0510 -#![feature(bind_by_move_pattern_guards)] let mut x = Some(0); match x { None => (), diff --git a/src/test/mir-opt/match-arm-scopes.rs b/src/test/mir-opt/match-arm-scopes.rs index 18e0642eb3427..c898d3a6f168c 100644 --- a/src/test/mir-opt/match-arm-scopes.rs +++ b/src/test/mir-opt/match-arm-scopes.rs @@ -8,8 +8,6 @@ // all of the bindings for that scope. // * No drop flags are used. -#![feature(nll, bind_by_move_pattern_guards)] - fn complicated_match(cond: bool, items: (bool, bool, String)) -> i32 { match items { (false, a, s) | (a, false, s) if if cond { return 3 } else { a } => 1, diff --git a/src/test/ui/bind-by-move/bind-by-move-no-guards.rs b/src/test/ui/bind-by-move/bind-by-move-no-guards.rs deleted file mode 100644 index bc9b3a8de4ef5..0000000000000 --- a/src/test/ui/bind-by-move/bind-by-move-no-guards.rs +++ /dev/null @@ -1,13 +0,0 @@ -use std::sync::mpsc::channel; - -fn main() { - let (tx, rx) = channel(); - let x = Some(rx); - tx.send(false); - match x { - Some(z) if z.recv().unwrap() => { panic!() }, - //~^ ERROR cannot bind by-move into a pattern guard - Some(z) => { assert!(!z.recv().unwrap()); }, - None => panic!() - } -} diff --git a/src/test/ui/bind-by-move/bind-by-move-no-guards.stderr b/src/test/ui/bind-by-move/bind-by-move-no-guards.stderr deleted file mode 100644 index c5f0256c2c92f..0000000000000 --- a/src/test/ui/bind-by-move/bind-by-move-no-guards.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0008]: cannot bind by-move into a pattern guard - --> $DIR/bind-by-move-no-guards.rs:8:14 - | -LL | Some(z) if z.recv().unwrap() => { panic!() }, - | ^ moves value into pattern guard - | - = help: add `#![feature(bind_by_move_pattern_guards)]` to the crate attributes to enable - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0008`. diff --git a/src/test/ui/borrowck/borrowck-mutate-in-guard.rs b/src/test/ui/borrowck/borrowck-mutate-in-guard.rs index 5b6aa7a979be5..9cbceeb945ccc 100644 --- a/src/test/ui/borrowck/borrowck-mutate-in-guard.rs +++ b/src/test/ui/borrowck/borrowck-mutate-in-guard.rs @@ -8,12 +8,9 @@ fn foo() -> isize { let mut x = Enum::A(&mut n); match x { Enum::A(_) if { x = Enum::B(false); false } => 1, - //~^ ERROR cannot assign in a pattern guard - //~| ERROR cannot assign `x` in match guard + //~^ ERROR cannot assign `x` in match guard Enum::A(_) if { let y = &mut x; *y = Enum::B(false); false } => 1, - //~^ ERROR cannot mutably borrow in a pattern guard - //~| ERROR cannot assign in a pattern guard - //~| ERROR cannot mutably borrow `x` in match guard + //~^ ERROR cannot mutably borrow `x` in match guard Enum::A(p) => *p, Enum::B(_) => 2, } diff --git a/src/test/ui/borrowck/borrowck-mutate-in-guard.stderr b/src/test/ui/borrowck/borrowck-mutate-in-guard.stderr index 674f137dbb043..6d05e97252d92 100644 --- a/src/test/ui/borrowck/borrowck-mutate-in-guard.stderr +++ b/src/test/ui/borrowck/borrowck-mutate-in-guard.stderr @@ -1,23 +1,3 @@ -error[E0302]: cannot assign in a pattern guard - --> $DIR/borrowck-mutate-in-guard.rs:10:25 - | -LL | Enum::A(_) if { x = Enum::B(false); false } => 1, - | ^^^^^^^^^^^^^^^^^^ assignment in pattern guard - -error[E0301]: cannot mutably borrow in a pattern guard - --> $DIR/borrowck-mutate-in-guard.rs:13:38 - | -LL | Enum::A(_) if { let y = &mut x; *y = Enum::B(false); false } => 1, - | ^ borrowed mutably in pattern guard - | - = help: add `#![feature(bind_by_move_pattern_guards)]` to the crate attributes to enable - -error[E0302]: cannot assign in a pattern guard - --> $DIR/borrowck-mutate-in-guard.rs:13:41 - | -LL | Enum::A(_) if { let y = &mut x; *y = Enum::B(false); false } => 1, - | ^^^^^^^^^^^^^^^^^^^ assignment in pattern guard - error[E0510]: cannot assign `x` in match guard --> $DIR/borrowck-mutate-in-guard.rs:10:25 | @@ -27,7 +7,7 @@ LL | Enum::A(_) if { x = Enum::B(false); false } => 1, | ^^^^^^^^^^^^^^^^^^ cannot assign error[E0510]: cannot mutably borrow `x` in match guard - --> $DIR/borrowck-mutate-in-guard.rs:13:33 + --> $DIR/borrowck-mutate-in-guard.rs:12:33 | LL | match x { | - value is immutable in match guard @@ -35,7 +15,6 @@ LL | match x { LL | Enum::A(_) if { let y = &mut x; *y = Enum::B(false); false } => 1, | ^^^^^^ cannot mutably borrow -error: aborting due to 5 previous errors +error: aborting due to 2 previous errors -Some errors have detailed explanations: E0301, E0302, E0510. -For more information about an error, try `rustc --explain E0301`. +For more information about this error, try `rustc --explain E0510`. diff --git a/src/test/ui/error-codes/E0008.rs b/src/test/ui/error-codes/E0008.rs deleted file mode 100644 index c87ef4cb8541f..0000000000000 --- a/src/test/ui/error-codes/E0008.rs +++ /dev/null @@ -1,7 +0,0 @@ -fn main() { - match Some("hi".to_string()) { - Some(s) if s.len() == 0 => {}, - //~^ ERROR E0008 - _ => {}, - } -} diff --git a/src/test/ui/error-codes/E0008.stderr b/src/test/ui/error-codes/E0008.stderr deleted file mode 100644 index 6b45439c4b587..0000000000000 --- a/src/test/ui/error-codes/E0008.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0008]: cannot bind by-move into a pattern guard - --> $DIR/E0008.rs:3:14 - | -LL | Some(s) if s.len() == 0 => {}, - | ^ moves value into pattern guard - | - = help: add `#![feature(bind_by_move_pattern_guards)]` to the crate attributes to enable - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0008`. diff --git a/src/test/ui/error-codes/E0301.rs b/src/test/ui/error-codes/E0301.rs index 3b451801c99df..0df04036bb767 100644 --- a/src/test/ui/error-codes/E0301.rs +++ b/src/test/ui/error-codes/E0301.rs @@ -1,7 +1,7 @@ fn main() { match Some(()) { None => { }, - option if option.take().is_none() => {}, //~ ERROR E0301 + option if option.take().is_none() => {}, Some(_) => { } //~^ ERROR E0596 } } diff --git a/src/test/ui/error-codes/E0301.stderr b/src/test/ui/error-codes/E0301.stderr index 4f12fd3850e33..661b86e389485 100644 --- a/src/test/ui/error-codes/E0301.stderr +++ b/src/test/ui/error-codes/E0301.stderr @@ -1,11 +1,3 @@ -error[E0301]: cannot mutably borrow in a pattern guard - --> $DIR/E0301.rs:4:19 - | -LL | option if option.take().is_none() => {}, - | ^^^^^^ borrowed mutably in pattern guard - | - = help: add `#![feature(bind_by_move_pattern_guards)]` to the crate attributes to enable - error[E0596]: cannot borrow `option` as mutable, as it is immutable for the pattern guard --> $DIR/E0301.rs:4:19 | @@ -14,7 +6,6 @@ LL | option if option.take().is_none() => {}, | = note: variables bound in patterns are immutable until the end of the pattern guard -error: aborting due to 2 previous errors +error: aborting due to previous error -Some errors have detailed explanations: E0301, E0596. -For more information about an error, try `rustc --explain E0301`. +For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/error-codes/E0302.rs b/src/test/ui/error-codes/E0302.rs index 69f5953deb223..28a1bc31bea7b 100644 --- a/src/test/ui/error-codes/E0302.rs +++ b/src/test/ui/error-codes/E0302.rs @@ -1,7 +1,7 @@ fn main() { match Some(()) { None => { }, - option if { option = None; false } => { }, //~ ERROR E0302 + option if { option = None; false } => { }, //~^ ERROR cannot assign to `option`, as it is immutable for the pattern guard Some(_) => { } } diff --git a/src/test/ui/error-codes/E0302.stderr b/src/test/ui/error-codes/E0302.stderr index a077fcaea4101..5854772f1d34a 100644 --- a/src/test/ui/error-codes/E0302.stderr +++ b/src/test/ui/error-codes/E0302.stderr @@ -1,9 +1,3 @@ -error[E0302]: cannot assign in a pattern guard - --> $DIR/E0302.rs:4:21 - | -LL | option if { option = None; false } => { }, - | ^^^^^^^^^^^^^ assignment in pattern guard - error[E0594]: cannot assign to `option`, as it is immutable for the pattern guard --> $DIR/E0302.rs:4:21 | @@ -12,6 +6,5 @@ LL | option if { option = None; false } => { }, | = note: variables bound in patterns are immutable until the end of the pattern guard -error: aborting due to 2 previous errors +error: aborting due to previous error -For more information about this error, try `rustc --explain E0302`. diff --git a/src/test/ui/issues/issue-24535-allow-mutable-borrow-in-match-guard.rs b/src/test/ui/issues/issue-24535-allow-mutable-borrow-in-match-guard.rs index 48362d0bb6282..7253d35ed2d4f 100644 --- a/src/test/ui/issues/issue-24535-allow-mutable-borrow-in-match-guard.rs +++ b/src/test/ui/issues/issue-24535-allow-mutable-borrow-in-match-guard.rs @@ -5,8 +5,6 @@ // See further discussion on rust-lang/rust#24535, // rust-lang/rfcs#1006, and rust-lang/rfcs#107 -#![feature(bind_by_move_pattern_guards)] - fn main() { rust_issue_24535(); rfcs_issue_1006_1(); diff --git a/src/test/ui/issues/issue-27282-reborrow-ref-mut-in-guard.rs b/src/test/ui/issues/issue-27282-reborrow-ref-mut-in-guard.rs index 1ffb7f6fd4acd..82d8b9e9ed977 100644 --- a/src/test/ui/issues/issue-27282-reborrow-ref-mut-in-guard.rs +++ b/src/test/ui/issues/issue-27282-reborrow-ref-mut-in-guard.rs @@ -5,8 +5,6 @@ // reject it. But I want to make sure that we continue to reject it // (under NLL) even when that conservaive check goes away. -#![feature(bind_by_move_pattern_guards)] - fn main() { let mut b = &mut true; match b { diff --git a/src/test/ui/issues/issue-27282-reborrow-ref-mut-in-guard.stderr b/src/test/ui/issues/issue-27282-reborrow-ref-mut-in-guard.stderr index a8eb78b7cc007..f0264b56ea569 100644 --- a/src/test/ui/issues/issue-27282-reborrow-ref-mut-in-guard.stderr +++ b/src/test/ui/issues/issue-27282-reborrow-ref-mut-in-guard.stderr @@ -1,5 +1,5 @@ error[E0596]: cannot borrow `r` as mutable, as it is immutable for the pattern guard - --> $DIR/issue-27282-reborrow-ref-mut-in-guard.rs:14:25 + --> $DIR/issue-27282-reborrow-ref-mut-in-guard.rs:12:25 | LL | ref mut r if { (|| { let bar = &mut *r; **bar = false; })(); | ^^ - mutable borrow occurs due to use of `r` in closure diff --git a/src/test/ui/match/match-ref-mut-stability.rs b/src/test/ui/match/match-ref-mut-stability.rs index 49e0dfaa3eb84..52120360be71e 100644 --- a/src/test/ui/match/match-ref-mut-stability.rs +++ b/src/test/ui/match/match-ref-mut-stability.rs @@ -3,8 +3,6 @@ // run-pass -#![feature(bind_by_move_pattern_guards)] - // Test that z always point to the same temporary. fn referent_stability() { let p; diff --git a/src/test/ui/nll/match-cfg-fake-edges.rs b/src/test/ui/nll/match-cfg-fake-edges.rs index 5fc9966cdf807..2e6d675fb641e 100644 --- a/src/test/ui/nll/match-cfg-fake-edges.rs +++ b/src/test/ui/nll/match-cfg-fake-edges.rs @@ -1,8 +1,6 @@ // Test that we have enough false edges to avoid exposing the exact matching // algorithm in borrow checking. -#![feature(bind_by_move_pattern_guards)] - fn guard_always_precedes_arm(y: i32) { let mut x; // x should always be initialized, as the only way to reach the arm is diff --git a/src/test/ui/nll/match-cfg-fake-edges.stderr b/src/test/ui/nll/match-cfg-fake-edges.stderr index 3d9037bbe7bf8..06fe564ac69e3 100644 --- a/src/test/ui/nll/match-cfg-fake-edges.stderr +++ b/src/test/ui/nll/match-cfg-fake-edges.stderr @@ -1,11 +1,11 @@ error[E0381]: use of possibly-uninitialized variable: `x` - --> $DIR/match-cfg-fake-edges.rs:23:13 + --> $DIR/match-cfg-fake-edges.rs:21:13 | LL | x; | ^ use of possibly-uninitialized `x` error[E0382]: use of moved value: `x` - --> $DIR/match-cfg-fake-edges.rs:37:13 + --> $DIR/match-cfg-fake-edges.rs:35:13 | LL | let x = String::new(); | - move occurs because `x` has type `std::string::String`, which does not implement the `Copy` trait diff --git a/src/test/ui/nll/match-guards-partially-borrow.rs b/src/test/ui/nll/match-guards-partially-borrow.rs index 601c46ff86cc7..81ae19ebf8a72 100644 --- a/src/test/ui/nll/match-guards-partially-borrow.rs +++ b/src/test/ui/nll/match-guards-partially-borrow.rs @@ -5,8 +5,6 @@ // Test that we don't allow mutating the value being matched on in a way that // changes which patterns it matches, until we have chosen an arm. -#![feature(bind_by_move_pattern_guards)] - fn ok_mutation_in_guard(mut q: i32) { match q { // OK, mutation doesn't change which patterns g matches diff --git a/src/test/ui/nll/match-guards-partially-borrow.stderr b/src/test/ui/nll/match-guards-partially-borrow.stderr index b2951fd339da4..48e3a7c699318 100644 --- a/src/test/ui/nll/match-guards-partially-borrow.stderr +++ b/src/test/ui/nll/match-guards-partially-borrow.stderr @@ -1,5 +1,5 @@ error[E0510]: cannot assign `q` in match guard - --> $DIR/match-guards-partially-borrow.rs:57:13 + --> $DIR/match-guards-partially-borrow.rs:55:13 | LL | match q { | - value is immutable in match guard @@ -8,7 +8,7 @@ LL | q = true; | ^^^^^^^^ cannot assign error[E0510]: cannot assign `r` in match guard - --> $DIR/match-guards-partially-borrow.rs:69:13 + --> $DIR/match-guards-partially-borrow.rs:67:13 | LL | match r { | - value is immutable in match guard @@ -17,7 +17,7 @@ LL | r = true; | ^^^^^^^^ cannot assign error[E0510]: cannot assign `t` in match guard - --> $DIR/match-guards-partially-borrow.rs:93:13 + --> $DIR/match-guards-partially-borrow.rs:91:13 | LL | match t { | - value is immutable in match guard @@ -26,7 +26,7 @@ LL | t = true; | ^^^^^^^^ cannot assign error[E0510]: cannot mutably borrow `x.0` in match guard - --> $DIR/match-guards-partially-borrow.rs:107:22 + --> $DIR/match-guards-partially-borrow.rs:105:22 | LL | match x { | - value is immutable in match guard @@ -35,7 +35,7 @@ LL | Some(ref mut r) => *r = None, | ^^^^^^^^^ cannot mutably borrow error[E0506]: cannot assign to `t` because it is borrowed - --> $DIR/match-guards-partially-borrow.rs:119:13 + --> $DIR/match-guards-partially-borrow.rs:117:13 | LL | s if { | - borrow of `t` occurs here @@ -46,7 +46,7 @@ LL | } => (), // What value should `s` have in the arm? | - borrow later used here error[E0510]: cannot assign `y` in match guard - --> $DIR/match-guards-partially-borrow.rs:130:13 + --> $DIR/match-guards-partially-borrow.rs:128:13 | LL | match *y { | -- value is immutable in match guard @@ -55,7 +55,7 @@ LL | y = &true; | ^^^^^^^^^ cannot assign error[E0510]: cannot assign `z` in match guard - --> $DIR/match-guards-partially-borrow.rs:141:13 + --> $DIR/match-guards-partially-borrow.rs:139:13 | LL | match z { | - value is immutable in match guard @@ -64,7 +64,7 @@ LL | z = &true; | ^^^^^^^^^ cannot assign error[E0510]: cannot assign `a` in match guard - --> $DIR/match-guards-partially-borrow.rs:153:13 + --> $DIR/match-guards-partially-borrow.rs:151:13 | LL | match a { | - value is immutable in match guard @@ -73,7 +73,7 @@ LL | a = &true; | ^^^^^^^^^ cannot assign error[E0510]: cannot assign `b` in match guard - --> $DIR/match-guards-partially-borrow.rs:164:13 + --> $DIR/match-guards-partially-borrow.rs:162:13 | LL | match b { | - value is immutable in match guard diff --git a/src/test/ui/rfc-0107-bind-by-move-pattern-guards/bind-by-move-no-guards.rs b/src/test/ui/rfc-0107-bind-by-move-pattern-guards/bind-by-move-no-guards.rs index e43c8541e6d6d..40a47ce45fbb5 100644 --- a/src/test/ui/rfc-0107-bind-by-move-pattern-guards/bind-by-move-no-guards.rs +++ b/src/test/ui/rfc-0107-bind-by-move-pattern-guards/bind-by-move-no-guards.rs @@ -4,8 +4,6 @@ // run-pass -#![feature(bind_by_move_pattern_guards)] - use std::sync::mpsc::channel; fn main() { diff --git a/src/test/ui/rfc-0107-bind-by-move-pattern-guards/feature-gate.gate_and_2015.stderr b/src/test/ui/rfc-0107-bind-by-move-pattern-guards/feature-gate.gate_and_2015.stderr deleted file mode 100644 index fe1f699074735..0000000000000 --- a/src/test/ui/rfc-0107-bind-by-move-pattern-guards/feature-gate.gate_and_2015.stderr +++ /dev/null @@ -1,10 +0,0 @@ -error: compilation successful - --> $DIR/feature-gate.rs:36:1 - | -LL | / fn main() { -LL | | foo(107) -LL | | } - | |_^ - -error: aborting due to previous error - diff --git a/src/test/ui/rfc-0107-bind-by-move-pattern-guards/feature-gate.gate_and_2018.stderr b/src/test/ui/rfc-0107-bind-by-move-pattern-guards/feature-gate.gate_and_2018.stderr deleted file mode 100644 index fe1f699074735..0000000000000 --- a/src/test/ui/rfc-0107-bind-by-move-pattern-guards/feature-gate.gate_and_2018.stderr +++ /dev/null @@ -1,10 +0,0 @@ -error: compilation successful - --> $DIR/feature-gate.rs:36:1 - | -LL | / fn main() { -LL | | foo(107) -LL | | } - | |_^ - -error: aborting due to previous error - diff --git a/src/test/ui/rfc-0107-bind-by-move-pattern-guards/feature-gate.gate_and_feature_nll.stderr b/src/test/ui/rfc-0107-bind-by-move-pattern-guards/feature-gate.gate_and_feature_nll.stderr deleted file mode 100644 index 34e8b0e14399e..0000000000000 --- a/src/test/ui/rfc-0107-bind-by-move-pattern-guards/feature-gate.gate_and_feature_nll.stderr +++ /dev/null @@ -1,10 +0,0 @@ -error: compilation successful - --> $DIR/feature-gate.rs:41:1 - | -LL | / fn main() { -LL | | foo(107) -LL | | } - | |_^ - -error: aborting due to previous error - diff --git a/src/test/ui/rfc-0107-bind-by-move-pattern-guards/feature-gate.gate_and_znll.stderr b/src/test/ui/rfc-0107-bind-by-move-pattern-guards/feature-gate.gate_and_znll.stderr deleted file mode 100644 index 34e8b0e14399e..0000000000000 --- a/src/test/ui/rfc-0107-bind-by-move-pattern-guards/feature-gate.gate_and_znll.stderr +++ /dev/null @@ -1,10 +0,0 @@ -error: compilation successful - --> $DIR/feature-gate.rs:41:1 - | -LL | / fn main() { -LL | | foo(107) -LL | | } - | |_^ - -error: aborting due to previous error - diff --git a/src/test/ui/rfc-0107-bind-by-move-pattern-guards/feature-gate.no_gate.stderr b/src/test/ui/rfc-0107-bind-by-move-pattern-guards/feature-gate.no_gate.stderr deleted file mode 100644 index 7a7b1c253528f..0000000000000 --- a/src/test/ui/rfc-0107-bind-by-move-pattern-guards/feature-gate.no_gate.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0008]: cannot bind by-move into a pattern guard - --> $DIR/feature-gate.rs:28:16 - | -LL | A { a: v } if *v == 42 => v, - | ^ moves value into pattern guard - | - = help: add `#![feature(bind_by_move_pattern_guards)]` to the crate attributes to enable - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0008`. diff --git a/src/test/ui/rfc-0107-bind-by-move-pattern-guards/feature-gate.rs b/src/test/ui/rfc-0107-bind-by-move-pattern-guards/feature-gate.rs deleted file mode 100644 index 69fce0bc775f7..0000000000000 --- a/src/test/ui/rfc-0107-bind-by-move-pattern-guards/feature-gate.rs +++ /dev/null @@ -1,40 +0,0 @@ -// Check that pattern-guards with move-bound variables is only allowed -// with the appropriate set of feature gates. (Note that we require -// the code to opt into MIR-borrowck in *some* way before the feature -// will work; we use the revision system here to enumerate a number of -// ways that opt-in could occur.) - -// gate-test-bind_by_move_pattern_guards - -// revisions: no_gate gate_and_2015 gate_and_2018 - -// (We're already testing NLL behavior quite explicitly, no need for compare-mode=nll.) -// ignore-compare-mode-nll - -#![feature(rustc_attrs)] - -#![cfg_attr(gate_and_2015, feature(bind_by_move_pattern_guards))] -#![cfg_attr(gate_and_2018, feature(bind_by_move_pattern_guards))] - -//[gate_and_2015] edition:2015 -//[gate_and_2018] edition:2018 - -struct A { a: Box } - -fn foo(n: i32) { - let x = A { a: Box::new(n) }; - let _y = match x { - - A { a: v } if *v == 42 => v, - //[no_gate]~^ ERROR cannot bind by-move into a pattern guard - - _ => Box::new(0) - }; -} - -#[rustc_error] -fn main() { - foo(107) -} -//[gate_and_2015]~^^^ ERROR compilation successful -//[gate_and_2018]~^^^^ ERROR compilation successful diff --git a/src/test/ui/rfc-0107-bind-by-move-pattern-guards/former-E0008-now-pass.rs b/src/test/ui/rfc-0107-bind-by-move-pattern-guards/former-E0008-now-pass.rs new file mode 100644 index 0000000000000..3161d6fbbe647 --- /dev/null +++ b/src/test/ui/rfc-0107-bind-by-move-pattern-guards/former-E0008-now-pass.rs @@ -0,0 +1,11 @@ +// This test used to emit E0008 but now passed since `bind_by_move_pattern_guards` +// have been stabilized. + +// check-pass + +fn main() { + match Some("hi".to_string()) { + Some(s) if s.len() == 0 => {}, + _ => {}, + } +} diff --git a/src/test/ui/rfc-0107-bind-by-move-pattern-guards/rfc-basic-examples.rs b/src/test/ui/rfc-0107-bind-by-move-pattern-guards/rfc-basic-examples.rs index eccb4e417b694..b716fc870e071 100644 --- a/src/test/ui/rfc-0107-bind-by-move-pattern-guards/rfc-basic-examples.rs +++ b/src/test/ui/rfc-0107-bind-by-move-pattern-guards/rfc-basic-examples.rs @@ -1,5 +1,3 @@ -#![feature(bind_by_move_pattern_guards)] - // run-pass struct A { a: Box } diff --git a/src/test/ui/rfc-0107-bind-by-move-pattern-guards/rfc-reject-double-move-across-arms.rs b/src/test/ui/rfc-0107-bind-by-move-pattern-guards/rfc-reject-double-move-across-arms.rs index 602a8e15cb180..d1f685f3e7a6d 100644 --- a/src/test/ui/rfc-0107-bind-by-move-pattern-guards/rfc-reject-double-move-across-arms.rs +++ b/src/test/ui/rfc-0107-bind-by-move-pattern-guards/rfc-reject-double-move-across-arms.rs @@ -1,5 +1,3 @@ -#![feature(bind_by_move_pattern_guards)] - enum VecWrapper { A(Vec) } fn foo(x: VecWrapper) -> usize { diff --git a/src/test/ui/rfc-0107-bind-by-move-pattern-guards/rfc-reject-double-move-across-arms.stderr b/src/test/ui/rfc-0107-bind-by-move-pattern-guards/rfc-reject-double-move-across-arms.stderr index c9e8fc8ee532b..7becd013249d4 100644 --- a/src/test/ui/rfc-0107-bind-by-move-pattern-guards/rfc-reject-double-move-across-arms.stderr +++ b/src/test/ui/rfc-0107-bind-by-move-pattern-guards/rfc-reject-double-move-across-arms.stderr @@ -1,5 +1,5 @@ error[E0507]: cannot move out of `v` in pattern guard - --> $DIR/rfc-reject-double-move-across-arms.rs:7:36 + --> $DIR/rfc-reject-double-move-across-arms.rs:5:36 | LL | VecWrapper::A(v) if { drop(v); false } => 1, | ^ move occurs because `v` has type `std::vec::Vec`, which does not implement the `Copy` trait diff --git a/src/test/ui/rfc-0107-bind-by-move-pattern-guards/rfc-reject-double-move-in-first-arm.rs b/src/test/ui/rfc-0107-bind-by-move-pattern-guards/rfc-reject-double-move-in-first-arm.rs index 77252a1ce1569..571f51c900120 100644 --- a/src/test/ui/rfc-0107-bind-by-move-pattern-guards/rfc-reject-double-move-in-first-arm.rs +++ b/src/test/ui/rfc-0107-bind-by-move-pattern-guards/rfc-reject-double-move-in-first-arm.rs @@ -1,5 +1,3 @@ -#![feature(bind_by_move_pattern_guards)] - struct A { a: Box } fn foo(n: i32) { diff --git a/src/test/ui/rfc-0107-bind-by-move-pattern-guards/rfc-reject-double-move-in-first-arm.stderr b/src/test/ui/rfc-0107-bind-by-move-pattern-guards/rfc-reject-double-move-in-first-arm.stderr index a345022cee7c5..b93e72190680d 100644 --- a/src/test/ui/rfc-0107-bind-by-move-pattern-guards/rfc-reject-double-move-in-first-arm.stderr +++ b/src/test/ui/rfc-0107-bind-by-move-pattern-guards/rfc-reject-double-move-in-first-arm.stderr @@ -1,5 +1,5 @@ error[E0507]: cannot move out of `v` in pattern guard - --> $DIR/rfc-reject-double-move-in-first-arm.rs:8:30 + --> $DIR/rfc-reject-double-move-in-first-arm.rs:6:30 | LL | A { a: v } if { drop(v); true } => v, | ^ move occurs because `v` has type `std::boxed::Box`, which does not implement the `Copy` trait From c6bfb1e9fdce7b94b4258d20d7402d551b30096c Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Tue, 30 Jul 2019 05:56:02 +0200 Subject: [PATCH 11/27] Tests: No longer emitting 0008, E0301, E0302. --- src/librustc_mir/error_codes.rs | 83 ++-------------------------- src/test/ui/error-codes/E0301.rs | 7 --- src/test/ui/error-codes/E0301.stderr | 11 ---- src/test/ui/error-codes/E0302.rs | 8 --- src/test/ui/error-codes/E0302.stderr | 10 ---- 5 files changed, 6 insertions(+), 113 deletions(-) delete mode 100644 src/test/ui/error-codes/E0301.rs delete mode 100644 src/test/ui/error-codes/E0301.stderr delete mode 100644 src/test/ui/error-codes/E0302.rs delete mode 100644 src/test/ui/error-codes/E0302.stderr diff --git a/src/librustc_mir/error_codes.rs b/src/librustc_mir/error_codes.rs index 844711acbf875..a10af7e2aceab 100644 --- a/src/librustc_mir/error_codes.rs +++ b/src/librustc_mir/error_codes.rs @@ -157,81 +157,6 @@ match x { See also the error E0303. "##, -E0008: r##" -Names bound in match arms retain their type in pattern guards. As such, if a -name is bound by move in a pattern, it should also be moved to wherever it is -referenced in the pattern guard code. Doing so however would prevent the name -from being available in the body of the match arm. Consider the following: - -```compile_fail,E0008 -match Some("hi".to_string()) { - Some(s) if s.len() == 0 => {}, // use s. - _ => {}, -} -``` - -The variable `s` has type `String`, and its use in the guard is as a variable of -type `String`. The guard code effectively executes in a separate scope to the -body of the arm, so the value would be moved into this anonymous scope and -therefore becomes unavailable in the body of the arm. - -The problem above can be solved by using the `ref` keyword. - -``` -match Some("hi".to_string()) { - Some(ref s) if s.len() == 0 => {}, - _ => {}, -} -``` - -Though this example seems innocuous and easy to solve, the problem becomes clear -when it encounters functions which consume the value: - -```compile_fail,E0008 -struct A{} - -impl A { - fn consume(self) -> usize { - 0 - } -} - -fn main() { - let a = Some(A{}); - match a { - Some(y) if y.consume() > 0 => {} - _ => {} - } -} -``` - -In this situation, even the `ref` keyword cannot solve it, since borrowed -content cannot be moved. This problem cannot be solved generally. If the value -can be cloned, here is a not-so-specific solution: - -``` -#[derive(Clone)] -struct A{} - -impl A { - fn consume(self) -> usize { - 0 - } -} - -fn main() { - let a = Some(A{}); - match a{ - Some(ref y) if y.clone().consume() > 0 => {} - _ => {} - } -} -``` - -If the value will be consumed in the pattern guard, using its clone will not -move its ownership, so the code works. -"##, - E0009: r##" In a pattern, all values that don't implement the `Copy` trait have to be bound the same way. The goal here is to avoid binding simultaneously by-move and @@ -475,13 +400,15 @@ for item in xs { "##, E0301: r##" +#### Note: this error code is no longer emitted by the compiler. + Mutable borrows are not allowed in pattern guards, because matching cannot have side effects. Side effects could alter the matched object or the environment on which the match depends in such a way, that the match would not be exhaustive. For instance, the following would not match any arm if mutable borrows were allowed: -```compile_fail,E0301 +```compile_fail,E0596 match Some(()) { None => { }, option if option.take().is_none() => { @@ -493,13 +420,15 @@ match Some(()) { "##, E0302: r##" +#### Note: this error code is no longer emitted by the compiler. + Assignments are not allowed in pattern guards, because matching cannot have side effects. Side effects could alter the matched object or the environment on which the match depends in such a way, that the match would not be exhaustive. For instance, the following would not match any arm if assignments were allowed: -```compile_fail,E0302 +```compile_fail,E0594 match Some(()) { None => { }, option if { option = None; false } => { }, diff --git a/src/test/ui/error-codes/E0301.rs b/src/test/ui/error-codes/E0301.rs deleted file mode 100644 index 0df04036bb767..0000000000000 --- a/src/test/ui/error-codes/E0301.rs +++ /dev/null @@ -1,7 +0,0 @@ -fn main() { - match Some(()) { - None => { }, - option if option.take().is_none() => {}, - Some(_) => { } //~^ ERROR E0596 - } -} diff --git a/src/test/ui/error-codes/E0301.stderr b/src/test/ui/error-codes/E0301.stderr deleted file mode 100644 index 661b86e389485..0000000000000 --- a/src/test/ui/error-codes/E0301.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0596]: cannot borrow `option` as mutable, as it is immutable for the pattern guard - --> $DIR/E0301.rs:4:19 - | -LL | option if option.take().is_none() => {}, - | ^^^^^^ cannot borrow as mutable - | - = note: variables bound in patterns are immutable until the end of the pattern guard - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/error-codes/E0302.rs b/src/test/ui/error-codes/E0302.rs deleted file mode 100644 index 28a1bc31bea7b..0000000000000 --- a/src/test/ui/error-codes/E0302.rs +++ /dev/null @@ -1,8 +0,0 @@ -fn main() { - match Some(()) { - None => { }, - option if { option = None; false } => { }, - //~^ ERROR cannot assign to `option`, as it is immutable for the pattern guard - Some(_) => { } - } -} diff --git a/src/test/ui/error-codes/E0302.stderr b/src/test/ui/error-codes/E0302.stderr deleted file mode 100644 index 5854772f1d34a..0000000000000 --- a/src/test/ui/error-codes/E0302.stderr +++ /dev/null @@ -1,10 +0,0 @@ -error[E0594]: cannot assign to `option`, as it is immutable for the pattern guard - --> $DIR/E0302.rs:4:21 - | -LL | option if { option = None; false } => { }, - | ^^^^^^^^^^^^^ cannot assign - | - = note: variables bound in patterns are immutable until the end of the pattern guard - -error: aborting due to previous error - From e362ff9febb7df9a2e82cd238775b4e32e755ade Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Tue, 20 Aug 2019 05:03:58 +0200 Subject: [PATCH 12/27] bootstrap -> boostrap_stdarch_ignore_this --- src/libcore/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libcore/lib.rs b/src/libcore/lib.rs index 0b4b6322534f2..7fb8b4dbb3366 100644 --- a/src/libcore/lib.rs +++ b/src/libcore/lib.rs @@ -87,7 +87,7 @@ #![feature(link_llvm_intrinsics)] #![feature(never_type)] #![feature(nll)] -#![cfg_attr(bootstrap, feature(bind_by_move_pattern_guards))] +#![cfg_attr(boostrap_stdarch_ignore_this, feature(bind_by_move_pattern_guards))] #![feature(exhaustive_patterns)] #![feature(no_core)] #![feature(on_unimplemented)] From aaa9762651c15ee16ae210b18c843bceab7bf454 Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Thu, 5 Sep 2019 19:37:38 +0200 Subject: [PATCH 13/27] bind-by-move: add E0008 commented out to error_codes.rs --- src/librustc_mir/error_codes.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/librustc_mir/error_codes.rs b/src/librustc_mir/error_codes.rs index a10af7e2aceab..908dd601df3d0 100644 --- a/src/librustc_mir/error_codes.rs +++ b/src/librustc_mir/error_codes.rs @@ -2379,6 +2379,7 @@ There are some known bugs that trigger this message. ; +// E0008, // cannot bind by-move into a pattern guard // E0298, // cannot compare constants // E0299, // mismatched types between arms // E0471, // constant evaluation error (in pattern) From 8acab6bc566df9adbd74ab39181b7333cff26e26 Mon Sep 17 00:00:00 2001 From: Charles Lew Date: Sun, 8 Sep 2019 09:34:24 +0800 Subject: [PATCH 14/27] Improve wording. --- src/librustc_metadata/native_libs.rs | 4 ++-- src/test/ui/attributes/obsolete-attr.rs | 2 +- src/test/ui/attributes/unknown-attr.rs | 2 +- src/test/ui/feature-gate/feature-gate-static-nobundle-2.rs | 2 +- .../ui/feature-gate/feature-gate-static-nobundle-2.stderr | 2 +- src/test/ui/feature-gates/feature-gate-is_sorted.rs | 4 ++-- src/test/ui/feature-gates/feature-gate-link_cfg.rs | 2 +- src/test/ui/feature-gates/feature-gate-link_cfg.stderr | 2 +- src/test/ui/feature-gates/feature-gate-static-nobundle.rs | 2 +- src/test/ui/feature-gates/feature-gate-static-nobundle.stderr | 2 +- src/test/ui/feature-gates/feature-gate-type_ascription.rs | 2 +- src/test/ui/proc-macro/resolve-error.rs | 4 ++-- src/test/ui/tool-attributes/tool-attributes-misplaced-1.rs | 2 +- 13 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/librustc_metadata/native_libs.rs b/src/librustc_metadata/native_libs.rs index 66971bb6f8b1c..66d676b7747d0 100644 --- a/src/librustc_metadata/native_libs.rs +++ b/src/librustc_metadata/native_libs.rs @@ -159,7 +159,7 @@ impl Collector<'tcx> { sym::link_cfg, span.unwrap(), GateIssue::Language, - "is feature gated"); + "is unstable"); } if lib.kind == cstore::NativeStaticNobundle && !self.tcx.features().static_nobundle { @@ -167,7 +167,7 @@ impl Collector<'tcx> { sym::static_nobundle, span.unwrap_or_else(|| syntax_pos::DUMMY_SP), GateIssue::Language, - "kind=\"static-nobundle\" is feature gated"); + "kind=\"static-nobundle\" is unstable"); } self.libs.push(lib); } diff --git a/src/test/ui/attributes/obsolete-attr.rs b/src/test/ui/attributes/obsolete-attr.rs index 8759344e6f820..cf6dd338552b8 100644 --- a/src/test/ui/attributes/obsolete-attr.rs +++ b/src/test/ui/attributes/obsolete-attr.rs @@ -1,4 +1,4 @@ -// Obsolete attributes fall back to feature gated custom attributes. +// Obsolete attributes fall back to unstable custom attributes. #[ab_isize="stdcall"] extern {} //~^ ERROR cannot find attribute macro `ab_isize` in this scope diff --git a/src/test/ui/attributes/unknown-attr.rs b/src/test/ui/attributes/unknown-attr.rs index 140a1fc3f93e5..544a6e2a7e78a 100644 --- a/src/test/ui/attributes/unknown-attr.rs +++ b/src/test/ui/attributes/unknown-attr.rs @@ -1,4 +1,4 @@ -// Unknown attributes fall back to feature gated custom attributes. +// Unknown attributes fall back to unstable custom attributes. #![feature(custom_inner_attributes)] diff --git a/src/test/ui/feature-gate/feature-gate-static-nobundle-2.rs b/src/test/ui/feature-gate/feature-gate-static-nobundle-2.rs index 92844f9306d28..b6c8648a7d03d 100644 --- a/src/test/ui/feature-gate/feature-gate-static-nobundle-2.rs +++ b/src/test/ui/feature-gate/feature-gate-static-nobundle-2.rs @@ -1,4 +1,4 @@ -//~ ERROR kind="static-nobundle" is feature gated +//~ ERROR kind="static-nobundle" is unstable // Test the behavior of rustc when non-existent library is statically linked // compile-flags: -l static-nobundle=nonexistent diff --git a/src/test/ui/feature-gate/feature-gate-static-nobundle-2.stderr b/src/test/ui/feature-gate/feature-gate-static-nobundle-2.stderr index 059559dd92831..cfff4c36a6d7b 100644 --- a/src/test/ui/feature-gate/feature-gate-static-nobundle-2.stderr +++ b/src/test/ui/feature-gate/feature-gate-static-nobundle-2.stderr @@ -1,4 +1,4 @@ -error[E0658]: kind="static-nobundle" is feature gated +error[E0658]: kind="static-nobundle" is unstable | = note: for more information, see https://github.com/rust-lang/rust/issues/37403 = help: add `#![feature(static_nobundle)]` to the crate attributes to enable diff --git a/src/test/ui/feature-gates/feature-gate-is_sorted.rs b/src/test/ui/feature-gates/feature-gate-is_sorted.rs index 078ecc577610b..359ed835bcbb2 100644 --- a/src/test/ui/feature-gates/feature-gate-is_sorted.rs +++ b/src/test/ui/feature-gates/feature-gate-is_sorted.rs @@ -1,11 +1,11 @@ fn main() { - // Assert `Iterator` methods are feature gated + // Assert `Iterator` methods are unstable assert!([1, 2, 2, 9].iter().is_sorted()); //~^ ERROR: use of unstable library feature 'is_sorted': new API assert!(![-2i32, -1, 0, 3].iter().is_sorted_by_key(|n| n.abs())); //~^ ERROR: use of unstable library feature 'is_sorted': new API - // Assert `[T]` methods are feature gated + // Assert `[T]` methods are unstable assert!([1, 2, 2, 9].is_sorted()); //~^ ERROR: use of unstable library feature 'is_sorted': new API assert!(![-2i32, -1, 0, 3].is_sorted_by_key(|n| n.abs())); diff --git a/src/test/ui/feature-gates/feature-gate-link_cfg.rs b/src/test/ui/feature-gates/feature-gate-link_cfg.rs index 1905346e2b5d7..27ec2e98eb68b 100644 --- a/src/test/ui/feature-gates/feature-gate-link_cfg.rs +++ b/src/test/ui/feature-gates/feature-gate-link_cfg.rs @@ -1,5 +1,5 @@ #[link(name = "foo", cfg(foo))] -//~^ ERROR: is feature gated +//~^ ERROR: is unstable extern {} fn main() {} diff --git a/src/test/ui/feature-gates/feature-gate-link_cfg.stderr b/src/test/ui/feature-gates/feature-gate-link_cfg.stderr index 58aa4ed7497ce..f6c5061546438 100644 --- a/src/test/ui/feature-gates/feature-gate-link_cfg.stderr +++ b/src/test/ui/feature-gates/feature-gate-link_cfg.stderr @@ -1,4 +1,4 @@ -error[E0658]: is feature gated +error[E0658]: is unstable --> $DIR/feature-gate-link_cfg.rs:1:1 | LL | #[link(name = "foo", cfg(foo))] diff --git a/src/test/ui/feature-gates/feature-gate-static-nobundle.rs b/src/test/ui/feature-gates/feature-gate-static-nobundle.rs index 1ce6c54aa4dc2..644b1f964a059 100644 --- a/src/test/ui/feature-gates/feature-gate-static-nobundle.rs +++ b/src/test/ui/feature-gates/feature-gate-static-nobundle.rs @@ -1,5 +1,5 @@ #[link(name="foo", kind="static-nobundle")] -//~^ ERROR: kind="static-nobundle" is feature gated +//~^ ERROR: kind="static-nobundle" is unstable extern {} fn main() {} diff --git a/src/test/ui/feature-gates/feature-gate-static-nobundle.stderr b/src/test/ui/feature-gates/feature-gate-static-nobundle.stderr index f2e29cf0678ae..cc0d426d6cf9a 100644 --- a/src/test/ui/feature-gates/feature-gate-static-nobundle.stderr +++ b/src/test/ui/feature-gates/feature-gate-static-nobundle.stderr @@ -1,4 +1,4 @@ -error[E0658]: kind="static-nobundle" is feature gated +error[E0658]: kind="static-nobundle" is unstable --> $DIR/feature-gate-static-nobundle.rs:1:1 | LL | #[link(name="foo", kind="static-nobundle")] diff --git a/src/test/ui/feature-gates/feature-gate-type_ascription.rs b/src/test/ui/feature-gates/feature-gate-type_ascription.rs index e42e340550681..7a597157300ed 100644 --- a/src/test/ui/feature-gates/feature-gate-type_ascription.rs +++ b/src/test/ui/feature-gates/feature-gate-type_ascription.rs @@ -1,4 +1,4 @@ -// Type ascription is feature gated +// Type ascription is unstable fn main() { let a = 10: u8; //~ ERROR type ascription is experimental diff --git a/src/test/ui/proc-macro/resolve-error.rs b/src/test/ui/proc-macro/resolve-error.rs index 0a7861aba6ebb..088f39c6665ff 100644 --- a/src/test/ui/proc-macro/resolve-error.rs +++ b/src/test/ui/proc-macro/resolve-error.rs @@ -23,11 +23,11 @@ macro_rules! attr_proc_mac { //~^ ERROR cannot find struct Foo; -// Interpreted as a feature gated custom attribute +// Interpreted as an unstable custom attribute #[attr_proc_macra] //~ ERROR cannot find attribute macro `attr_proc_macra` in this scope struct Bar; -// Interpreted as a feature gated custom attribute +// Interpreted as an unstable custom attribute #[FooWithLongNan] //~ ERROR cannot find attribute macro `FooWithLongNan` in this scope struct Asdf; diff --git a/src/test/ui/tool-attributes/tool-attributes-misplaced-1.rs b/src/test/ui/tool-attributes/tool-attributes-misplaced-1.rs index 8c62b34bd9ea5..c07da4345f7d9 100644 --- a/src/test/ui/tool-attributes/tool-attributes-misplaced-1.rs +++ b/src/test/ui/tool-attributes/tool-attributes-misplaced-1.rs @@ -4,7 +4,7 @@ type B = rustfmt::skip; //~ ERROR expected type, found tool attribute `rustfmt:: #[derive(rustfmt)] //~ ERROR cannot find derive macro `rustfmt` in this scope struct S; -// Interpreted as a feature gated custom attribute +// Interpreted as an unstable custom attribute #[rustfmt] //~ ERROR cannot find attribute macro `rustfmt` in this scope fn check() {} From 38ab20dbf7469aa5a3cb0d7bfd3700281aa46467 Mon Sep 17 00:00:00 2001 From: V1shvesh <22243137+V1shvesh@users.noreply.github.com> Date: Sun, 8 Sep 2019 14:57:03 +0530 Subject: [PATCH 15/27] Add pluralise macro Adress issue #64238. Create a macro to be used for pluralisation check throughout rustc codebase. --- src/librustc_errors/lib.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/librustc_errors/lib.rs b/src/librustc_errors/lib.rs index 6585633e00af8..b5341a2b727a5 100644 --- a/src/librustc_errors/lib.rs +++ b/src/librustc_errors/lib.rs @@ -845,3 +845,11 @@ impl Level { } } } + +#[macro_export] +macro_rules! pluralise { + ($x:expr) => { + if $x != 1 { "s" } else { "" } + }; +} + From c2552065819288a91a7e2646d95bf53765304b4f Mon Sep 17 00:00:00 2001 From: V1shvesh <22243137+V1shvesh@users.noreply.github.com> Date: Sun, 8 Sep 2019 15:00:08 +0530 Subject: [PATCH 16/27] Refactor Pluralisation Modify files performing pluralisation checks to incorporate the dedicated macro located in `syntax::errors`. --- src/librustc/ty/error.rs | 7 +------ src/librustc_typeck/astconv.rs | 3 ++- src/librustc_typeck/check/compare_method.rs | 9 +++++---- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/src/librustc/ty/error.rs b/src/librustc/ty/error.rs index f67526ea4a1d9..62910ec320494 100644 --- a/src/librustc/ty/error.rs +++ b/src/librustc/ty/error.rs @@ -4,6 +4,7 @@ use std::borrow::Cow; use std::fmt; use rustc_target::spec::abi; use syntax::ast; +use syntax::errors::pluralise; use errors::{Applicability, DiagnosticBuilder}; use syntax_pos::Span; @@ -82,12 +83,6 @@ impl<'tcx> fmt::Display for TypeError<'tcx> { } }; - macro_rules! pluralise { - ($x:expr) => { - if $x != 1 { "s" } else { "" } - }; - } - match *self { CyclicTy(_) => write!(f, "cyclic type of infinite size"), Mismatch => write!(f, "types differ"), diff --git a/src/librustc_typeck/astconv.rs b/src/librustc_typeck/astconv.rs index 9e52eae88ef45..e9ca0f3d978ca 100644 --- a/src/librustc_typeck/astconv.rs +++ b/src/librustc_typeck/astconv.rs @@ -23,6 +23,7 @@ use rustc_target::spec::abi; use crate::require_c_abi_if_c_variadic; use smallvec::SmallVec; use syntax::ast; +use syntax::errors::pluralise; use syntax::feature_gate::{GateIssue, emit_feature_err}; use syntax::util::lev_distance::find_best_match_for_name; use syntax::symbol::sym; @@ -377,7 +378,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { quantifier, bound, kind, - if bound != 1 { "s" } else { "" }, + pluralise!(bound), )) }; diff --git a/src/librustc_typeck/check/compare_method.rs b/src/librustc_typeck/check/compare_method.rs index 8e187b7e05b51..f22499f547272 100644 --- a/src/librustc_typeck/check/compare_method.rs +++ b/src/librustc_typeck/check/compare_method.rs @@ -10,6 +10,7 @@ use rustc::util::common::ErrorReported; use errors::{Applicability, DiagnosticId}; use syntax_pos::Span; +use syntax::errors::pluralise; use super::{Inherited, FnCtxt, potentially_plural_count}; @@ -648,9 +649,9 @@ fn compare_number_of_generics<'tcx>( declaration has {} {kind} parameter{}", trait_.ident, impl_count, - if impl_count != 1 { "s" } else { "" }, + pluralise!(impl_count), trait_count, - if trait_count != 1 { "s" } else { "" }, + pluralise!(trait_count), kind = kind, ), DiagnosticId::Error("E0049".into()), @@ -665,7 +666,7 @@ fn compare_number_of_generics<'tcx>( "expected {} {} parameter{}", trait_count, kind, - if trait_count != 1 { "s" } else { "" }, + pluralise!(trait_count), )); } for span in spans { @@ -680,7 +681,7 @@ fn compare_number_of_generics<'tcx>( "found {} {} parameter{}{}", impl_count, kind, - if impl_count != 1 { "s" } else { "" }, + pluralise!(impl_count), suffix.unwrap_or_else(|| String::new()), )); } From 6fdbece55f7ccba7ac16808bd62ead27d6da9500 Mon Sep 17 00:00:00 2001 From: Mark Rousskov Date: Sun, 1 Sep 2019 17:30:19 -0400 Subject: [PATCH 17/27] Update test stderr with results of enabling unused lints --- .../bounds-on-assoc-in-trait.rs | 2 +- src/test/ui/associated-type-bounds/fn-apit.rs | 1 + .../ui/associated-type-bounds/fn-dyn-apit.rs | 1 + src/test/ui/associated-type-bounds/fn-inline.rs | 1 + src/test/ui/associated-type-bounds/fn-where.rs | 1 + .../ui/associated-type-bounds/fn-wrap-apit.rs | 1 + .../ui/associated-type-bounds/struct-bounds.rs | 1 + src/test/ui/async-await/argument-patterns.rs | 3 +-- src/test/ui/async-await/async-await.rs | 2 ++ .../drop-order-for-locals-when-cancelled.rs | 6 ++++-- .../drop-order/drop-order-when-cancelled.rs | 4 +++- .../issues/issue-54752-async-block.stderr | 8 ++++++++ src/test/ui/async-await/issues/issue-59972.rs | 2 +- .../ui/async-await/multiple-lifetimes/hrtb.rs | 2 +- src/test/ui/borrowck/borrowck-migrate-to-nll.rs | 2 +- src/test/ui/borrowck/issue-10876.rs | 2 +- .../borrowck/two-phase-multiple-activations.rs | 4 ++-- .../ui/const-generics/apit-with-const-param.rs | 2 +- .../const-generics/array-wrapper-struct-ctor.rs | 2 ++ src/test/ui/const-generics/const-types.rs | 2 +- src/test/ui/const-generics/issue-61422.rs | 4 ++-- src/test/ui/const-generics/unused-const-param.rs | 2 +- src/test/ui/consts/const-eval/const_transmute.rs | 1 + src/test/ui/consts/const-labeled-break.rs | 2 +- src/test/ui/consts/packed_pattern.stderr | 8 ++++++++ src/test/ui/consts/packed_pattern2.stderr | 8 ++++++++ src/test/ui/deprecation/deprecation-in-future.rs | 2 +- src/test/ui/drop/dynamic-drop-async.rs | 1 + src/test/ui/hrtb/issue-57639.rs | 2 +- src/test/ui/if-ret.stderr | 8 ++++++++ .../ui/impl-trait/closure-calling-parent-fn.rs | 2 +- src/test/ui/impl-trait/issues/issue-53457.rs | 4 ++-- .../multiple-lifetimes/inverse-bounds.rs | 2 +- .../ui/impl-trait/needs_least_region_or_bound.rs | 4 +--- src/test/ui/issues/issue-26448-2.rs | 2 +- src/test/ui/issues/issue-26448-3.rs | 2 +- src/test/ui/issues/issue-27697.rs | 2 +- src/test/ui/issues/issue-38591.rs | 2 +- src/test/ui/issues/issue-43806.rs | 2 +- src/test/ui/issues/issue-48132.rs | 2 ++ src/test/ui/issues/issue-48179.rs | 2 +- .../issue-61711-once-caused-rustc-inf-loop.rs | 2 +- src/test/ui/lint/empty-lint-attributes.rs | 2 +- src/test/ui/nll/issue-55288.rs | 2 +- src/test/ui/nll/issue-57960.rs | 1 - src/test/ui/nll/normalization-bounds.rs | 2 +- .../promotable-mutable-zst-doesnt-conflict.rs | 4 ++-- src/test/ui/nll/user-annotations/issue-55219.rs | 2 +- .../ui/nll/user-annotations/normalize-self-ty.rs | 4 ++-- .../bind-by-move-no-guards.rs | 4 ++-- .../variants_same_crate.rs | 6 +++--- .../protect-precedences.rs | 2 -- .../protect-precedences.stderr | 8 ++++++++ .../traits/trait-alias/trait-alias-object-wf.rs | 2 +- .../enum-variant-generic-args-pass.rs | 16 ++++++++-------- src/test/ui/while-let.rs | 7 ++++--- src/test/ui/while-let.stderr | 12 ++++++------ 57 files changed, 121 insertions(+), 68 deletions(-) create mode 100644 src/test/ui/async-await/issues/issue-54752-async-block.stderr create mode 100644 src/test/ui/consts/packed_pattern.stderr create mode 100644 src/test/ui/consts/packed_pattern2.stderr create mode 100644 src/test/ui/if-ret.stderr create mode 100644 src/test/ui/rfc-2497-if-let-chains/protect-precedences.stderr diff --git a/src/test/ui/associated-type-bounds/bounds-on-assoc-in-trait.rs b/src/test/ui/associated-type-bounds/bounds-on-assoc-in-trait.rs index 9db5233e21e57..ceca54b7cd75f 100644 --- a/src/test/ui/associated-type-bounds/bounds-on-assoc-in-trait.rs +++ b/src/test/ui/associated-type-bounds/bounds-on-assoc-in-trait.rs @@ -1,4 +1,4 @@ -// run-pass +// check-pass #![feature(associated_type_bounds)] diff --git a/src/test/ui/associated-type-bounds/fn-apit.rs b/src/test/ui/associated-type-bounds/fn-apit.rs index 7e208b4e70d81..3c9f511338f69 100644 --- a/src/test/ui/associated-type-bounds/fn-apit.rs +++ b/src/test/ui/associated-type-bounds/fn-apit.rs @@ -1,6 +1,7 @@ // run-pass // aux-build:fn-aux.rs +#![allow(unused)] #![feature(associated_type_bounds)] extern crate fn_aux; diff --git a/src/test/ui/associated-type-bounds/fn-dyn-apit.rs b/src/test/ui/associated-type-bounds/fn-dyn-apit.rs index 9ff4a50e1e6e4..c4e8092c211d6 100644 --- a/src/test/ui/associated-type-bounds/fn-dyn-apit.rs +++ b/src/test/ui/associated-type-bounds/fn-dyn-apit.rs @@ -1,6 +1,7 @@ // run-pass // aux-build:fn-dyn-aux.rs +#![allow(unused)] #![feature(associated_type_bounds)] extern crate fn_dyn_aux; diff --git a/src/test/ui/associated-type-bounds/fn-inline.rs b/src/test/ui/associated-type-bounds/fn-inline.rs index 7b188763b7a5e..8fa7212d6275b 100644 --- a/src/test/ui/associated-type-bounds/fn-inline.rs +++ b/src/test/ui/associated-type-bounds/fn-inline.rs @@ -1,6 +1,7 @@ // run-pass // aux-build:fn-aux.rs +#![allow(unused)] #![feature(associated_type_bounds)] extern crate fn_aux; diff --git a/src/test/ui/associated-type-bounds/fn-where.rs b/src/test/ui/associated-type-bounds/fn-where.rs index 60d7149a56f25..9c4f82ac991c8 100644 --- a/src/test/ui/associated-type-bounds/fn-where.rs +++ b/src/test/ui/associated-type-bounds/fn-where.rs @@ -1,6 +1,7 @@ // run-pass // aux-build:fn-aux.rs +#![allow(unused)] #![feature(associated_type_bounds)] extern crate fn_aux; diff --git a/src/test/ui/associated-type-bounds/fn-wrap-apit.rs b/src/test/ui/associated-type-bounds/fn-wrap-apit.rs index 23790d416e1f7..96df13e372a24 100644 --- a/src/test/ui/associated-type-bounds/fn-wrap-apit.rs +++ b/src/test/ui/associated-type-bounds/fn-wrap-apit.rs @@ -2,6 +2,7 @@ // aux-build:fn-aux.rs #![feature(associated_type_bounds)] +#![allow(dead_code)] extern crate fn_aux; diff --git a/src/test/ui/associated-type-bounds/struct-bounds.rs b/src/test/ui/associated-type-bounds/struct-bounds.rs index 2d189cd66724a..2c1ce1c3785ae 100644 --- a/src/test/ui/associated-type-bounds/struct-bounds.rs +++ b/src/test/ui/associated-type-bounds/struct-bounds.rs @@ -1,5 +1,6 @@ // run-pass +#![allow(unused)] #![feature(associated_type_bounds)] trait Tr1 { type As1; } diff --git a/src/test/ui/async-await/argument-patterns.rs b/src/test/ui/async-await/argument-patterns.rs index 0e42f48b8351e..b9fc1a88cee13 100644 --- a/src/test/ui/async-await/argument-patterns.rs +++ b/src/test/ui/async-await/argument-patterns.rs @@ -1,7 +1,6 @@ // edition:2018 -// run-pass +// check-pass -#![allow(unused_variables)] #![deny(unused_mut)] type A = Vec; diff --git a/src/test/ui/async-await/async-await.rs b/src/test/ui/async-await/async-await.rs index bf8bf0bcce0fe..1dc7315e88c11 100644 --- a/src/test/ui/async-await/async-await.rs +++ b/src/test/ui/async-await/async-await.rs @@ -1,5 +1,7 @@ // run-pass +#![allow(unused)] + // edition:2018 // aux-build:arc_wake.rs diff --git a/src/test/ui/async-await/drop-order/drop-order-for-locals-when-cancelled.rs b/src/test/ui/async-await/drop-order/drop-order-for-locals-when-cancelled.rs index 5d020c9a52601..15cc9fbc81fb7 100644 --- a/src/test/ui/async-await/drop-order/drop-order-for-locals-when-cancelled.rs +++ b/src/test/ui/async-await/drop-order/drop-order-for-locals-when-cancelled.rs @@ -3,6 +3,9 @@ // run-pass #![deny(dead_code)] +#![allow(unused_variables)] +#![allow(unused_must_use)] +#![allow(path_statements)] // Test that the drop order for locals in a fn and async fn matches up. extern crate arc_wake; @@ -10,7 +13,6 @@ extern crate arc_wake; use arc_wake::ArcWake; use std::cell::RefCell; use std::future::Future; -use std::marker::PhantomData; use std::pin::Pin; use std::rc::Rc; use std::sync::Arc; @@ -42,7 +44,7 @@ struct NeverReady; impl Future for NeverReady { type Output = (); - fn poll(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll { + fn poll(self: Pin<&mut Self>, cx: &mut Context) -> Poll { Poll::Pending } } diff --git a/src/test/ui/async-await/drop-order/drop-order-when-cancelled.rs b/src/test/ui/async-await/drop-order/drop-order-when-cancelled.rs index 84fe79348c601..9e8304935bffc 100644 --- a/src/test/ui/async-await/drop-order/drop-order-when-cancelled.rs +++ b/src/test/ui/async-await/drop-order/drop-order-when-cancelled.rs @@ -6,6 +6,8 @@ // parameters (used or unused) are not dropped until the async fn is cancelled. // This file is mostly copy-pasted from drop-order-for-async-fn-parameters.rs +#![allow(unused_variables)] + extern crate arc_wake; use arc_wake::ArcWake; @@ -43,7 +45,7 @@ struct NeverReady; impl Future for NeverReady { type Output = (); - fn poll(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll { + fn poll(self: Pin<&mut Self>, cx: &mut Context) -> Poll { Poll::Pending } } diff --git a/src/test/ui/async-await/issues/issue-54752-async-block.stderr b/src/test/ui/async-await/issues/issue-54752-async-block.stderr new file mode 100644 index 0000000000000..c3b3392cfc495 --- /dev/null +++ b/src/test/ui/async-await/issues/issue-54752-async-block.stderr @@ -0,0 +1,8 @@ +warning: unnecessary parentheses around assigned value + --> $DIR/issue-54752-async-block.rs:6:22 + | +LL | fn main() { let _a = (async { }); } + | ^^^^^^^^^^^^ help: remove these parentheses + | + = note: `#[warn(unused_parens)]` on by default + diff --git a/src/test/ui/async-await/issues/issue-59972.rs b/src/test/ui/async-await/issues/issue-59972.rs index 154226e8bb88f..c2e24a96b1d93 100644 --- a/src/test/ui/async-await/issues/issue-59972.rs +++ b/src/test/ui/async-await/issues/issue-59972.rs @@ -4,7 +4,7 @@ // run-pass -// compile-flags: --edition=2018 +// compile-flags: --edition=2018 -Aunused pub enum Uninhabited { } diff --git a/src/test/ui/async-await/multiple-lifetimes/hrtb.rs b/src/test/ui/async-await/multiple-lifetimes/hrtb.rs index 31d0736ba63c8..e788ca5ff49c3 100644 --- a/src/test/ui/async-await/multiple-lifetimes/hrtb.rs +++ b/src/test/ui/async-await/multiple-lifetimes/hrtb.rs @@ -1,5 +1,5 @@ // edition:2018 -// run-pass +// check-pass // Test that we can use async fns with multiple arbitrary lifetimes. diff --git a/src/test/ui/borrowck/borrowck-migrate-to-nll.rs b/src/test/ui/borrowck/borrowck-migrate-to-nll.rs index 98fd5682277b3..6587dfdbc03f3 100644 --- a/src/test/ui/borrowck/borrowck-migrate-to-nll.rs +++ b/src/test/ui/borrowck/borrowck-migrate-to-nll.rs @@ -17,7 +17,7 @@ // revisions: zflag edition //[zflag]compile-flags: -Z borrowck=migrate //[edition]edition:2018 -//[zflag] run-pass +//[zflag] check-pass pub struct Block<'a> { current: &'a u8, diff --git a/src/test/ui/borrowck/issue-10876.rs b/src/test/ui/borrowck/issue-10876.rs index 20ab905fec46e..22eaa119f2467 100644 --- a/src/test/ui/borrowck/issue-10876.rs +++ b/src/test/ui/borrowck/issue-10876.rs @@ -1,4 +1,4 @@ -// run-pass +// check-pass enum Nat { S(Box), diff --git a/src/test/ui/borrowck/two-phase-multiple-activations.rs b/src/test/ui/borrowck/two-phase-multiple-activations.rs index a7fa7fac13e73..599138a9ce0f1 100644 --- a/src/test/ui/borrowck/two-phase-multiple-activations.rs +++ b/src/test/ui/borrowck/two-phase-multiple-activations.rs @@ -11,7 +11,7 @@ pub trait FakeRead { } impl FakeRead for Foo { - fn read_to_end(&mut self, buf: &mut Vec) -> Result { + fn read_to_end(&mut self, _buf: &mut Vec) -> Result { Ok(4) } } @@ -19,5 +19,5 @@ impl FakeRead for Foo { fn main() { let mut a = Foo {}; let mut v = Vec::new(); - a.read_to_end(&mut v); + a.read_to_end(&mut v).unwrap(); } diff --git a/src/test/ui/const-generics/apit-with-const-param.rs b/src/test/ui/const-generics/apit-with-const-param.rs index 70e718d889029..7acc50819a6ad 100644 --- a/src/test/ui/const-generics/apit-with-const-param.rs +++ b/src/test/ui/const-generics/apit-with-const-param.rs @@ -1,4 +1,4 @@ -// run-pass +// check-pass #![feature(const_generics)] //~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash diff --git a/src/test/ui/const-generics/array-wrapper-struct-ctor.rs b/src/test/ui/const-generics/array-wrapper-struct-ctor.rs index d83846fcf88d4..2d1a405ebdd80 100644 --- a/src/test/ui/const-generics/array-wrapper-struct-ctor.rs +++ b/src/test/ui/const-generics/array-wrapper-struct-ctor.rs @@ -3,6 +3,8 @@ #![feature(const_generics)] //~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash +#![allow(dead_code)] + struct ArrayStruct { data: [T; N], } diff --git a/src/test/ui/const-generics/const-types.rs b/src/test/ui/const-generics/const-types.rs index 11757cd588dab..bc5188133d7f1 100644 --- a/src/test/ui/const-generics/const-types.rs +++ b/src/test/ui/const-generics/const-types.rs @@ -3,7 +3,7 @@ #![feature(const_generics)] //~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash -#[allow(dead_code)] +#![allow(dead_code, unused_variables)] struct ConstArray { array: [T; LEN], diff --git a/src/test/ui/const-generics/issue-61422.rs b/src/test/ui/const-generics/issue-61422.rs index 68e5a52e0ac5c..45d37b6a2f3c5 100644 --- a/src/test/ui/const-generics/issue-61422.rs +++ b/src/test/ui/const-generics/issue-61422.rs @@ -1,4 +1,4 @@ -// run-pass +// check-pass #![feature(const_generics)] //~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash @@ -8,7 +8,7 @@ use std::mem; fn foo() { let arr: [u8; SIZE] = unsafe { #[allow(deprecated)] - let mut array: [u8; SIZE] = mem::uninitialized(); + let array: [u8; SIZE] = mem::uninitialized(); array }; } diff --git a/src/test/ui/const-generics/unused-const-param.rs b/src/test/ui/const-generics/unused-const-param.rs index ee98e5eb4a01f..8025b3af8f1bf 100644 --- a/src/test/ui/const-generics/unused-const-param.rs +++ b/src/test/ui/const-generics/unused-const-param.rs @@ -1,4 +1,4 @@ -// run-pass +// check-pass #![feature(const_generics)] //~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash diff --git a/src/test/ui/consts/const-eval/const_transmute.rs b/src/test/ui/consts/const-eval/const_transmute.rs index 4a7d8490ef25f..f0e1d8263022b 100644 --- a/src/test/ui/consts/const-eval/const_transmute.rs +++ b/src/test/ui/consts/const-eval/const_transmute.rs @@ -1,6 +1,7 @@ // run-pass #![feature(const_fn_union)] +#![allow(dead_code)] #[repr(C)] union Transmute { diff --git a/src/test/ui/consts/const-labeled-break.rs b/src/test/ui/consts/const-labeled-break.rs index 36e308ade9c54..7cdbb22f92459 100644 --- a/src/test/ui/consts/const-labeled-break.rs +++ b/src/test/ui/consts/const-labeled-break.rs @@ -1,4 +1,4 @@ -// run-pass +// build-pass // Using labeled break in a while loop has caused an illegal instruction being // generated, and an ICE later. diff --git a/src/test/ui/consts/packed_pattern.stderr b/src/test/ui/consts/packed_pattern.stderr new file mode 100644 index 0000000000000..9b7daf2e674fb --- /dev/null +++ b/src/test/ui/consts/packed_pattern.stderr @@ -0,0 +1,8 @@ +warning: unreachable pattern + --> $DIR/packed_pattern.rs:16:9 + | +LL | FOO => unreachable!(), + | ^^^ + | + = note: `#[warn(unreachable_patterns)]` on by default + diff --git a/src/test/ui/consts/packed_pattern2.stderr b/src/test/ui/consts/packed_pattern2.stderr new file mode 100644 index 0000000000000..6cc0225d3043d --- /dev/null +++ b/src/test/ui/consts/packed_pattern2.stderr @@ -0,0 +1,8 @@ +warning: unreachable pattern + --> $DIR/packed_pattern2.rs:24:9 + | +LL | FOO => unreachable!(), + | ^^^ + | + = note: `#[warn(unreachable_patterns)]` on by default + diff --git a/src/test/ui/deprecation/deprecation-in-future.rs b/src/test/ui/deprecation/deprecation-in-future.rs index c4f9fdce74907..464ddcc4cdb94 100644 --- a/src/test/ui/deprecation/deprecation-in-future.rs +++ b/src/test/ui/deprecation/deprecation-in-future.rs @@ -1,4 +1,4 @@ -// run-pass +// check-pass #![deny(deprecated_in_future)] diff --git a/src/test/ui/drop/dynamic-drop-async.rs b/src/test/ui/drop/dynamic-drop-async.rs index 79d09d1817601..91063edf0f6c4 100644 --- a/src/test/ui/drop/dynamic-drop-async.rs +++ b/src/test/ui/drop/dynamic-drop-async.rs @@ -8,6 +8,7 @@ // ignore-wasm32-bare compiled with panic=abort by default #![feature(slice_patterns)] +#![allow(unused)] use std::{ cell::{Cell, RefCell}, diff --git a/src/test/ui/hrtb/issue-57639.rs b/src/test/ui/hrtb/issue-57639.rs index 4bcaef3616bd5..392e7233b567a 100644 --- a/src/test/ui/hrtb/issue-57639.rs +++ b/src/test/ui/hrtb/issue-57639.rs @@ -10,7 +10,7 @@ // // See [this comment on GitHub][c] for more details. // -// run-pass +// check-pass // // [c]: https://github.com/rust-lang/rust/issues/57639#issuecomment-455685861 diff --git a/src/test/ui/if-ret.stderr b/src/test/ui/if-ret.stderr new file mode 100644 index 0000000000000..73402e55a4fd8 --- /dev/null +++ b/src/test/ui/if-ret.stderr @@ -0,0 +1,8 @@ +warning: unreachable block in `if` expression + --> $DIR/if-ret.rs:6:24 + | +LL | fn foo() { if (return) { } } + | ^^^ + | + = note: `#[warn(unreachable_code)]` on by default + diff --git a/src/test/ui/impl-trait/closure-calling-parent-fn.rs b/src/test/ui/impl-trait/closure-calling-parent-fn.rs index 58d7875ccd034..9dab334a217c2 100644 --- a/src/test/ui/impl-trait/closure-calling-parent-fn.rs +++ b/src/test/ui/impl-trait/closure-calling-parent-fn.rs @@ -5,7 +5,7 @@ // `foo` and hence is treated opaquely within the closure body. This // resulted in a failed subtype relationship. // -// run-pass +// check-pass fn foo() -> impl Copy { || foo(); } fn bar() -> impl Copy { || bar(); } diff --git a/src/test/ui/impl-trait/issues/issue-53457.rs b/src/test/ui/impl-trait/issues/issue-53457.rs index de8c579743fc0..3f97502492506 100644 --- a/src/test/ui/impl-trait/issues/issue-53457.rs +++ b/src/test/ui/impl-trait/issues/issue-53457.rs @@ -1,4 +1,4 @@ -// run-pass +// check-pass #![feature(type_alias_impl_trait)] @@ -9,7 +9,7 @@ fn bar(f: F) -> F { } fn foo() -> X { - bar(|x| ()) + bar(|_| ()) } fn main() {} diff --git a/src/test/ui/impl-trait/multiple-lifetimes/inverse-bounds.rs b/src/test/ui/impl-trait/multiple-lifetimes/inverse-bounds.rs index 2da3886bb552b..3911769b0c63d 100644 --- a/src/test/ui/impl-trait/multiple-lifetimes/inverse-bounds.rs +++ b/src/test/ui/impl-trait/multiple-lifetimes/inverse-bounds.rs @@ -1,5 +1,5 @@ // edition:2018 -// run-pass +// check-pass // revisions: migrate mir //[mir]compile-flags: -Z borrowck=mir diff --git a/src/test/ui/impl-trait/needs_least_region_or_bound.rs b/src/test/ui/impl-trait/needs_least_region_or_bound.rs index 52475f65a8353..3c8682bb62aa5 100644 --- a/src/test/ui/impl-trait/needs_least_region_or_bound.rs +++ b/src/test/ui/impl-trait/needs_least_region_or_bound.rs @@ -1,9 +1,7 @@ -// run-pass +// check-pass #![feature(member_constraints)] -use std::fmt::Debug; - trait MultiRegionTrait<'a, 'b> {} impl<'a, 'b> MultiRegionTrait<'a, 'b> for (&'a u32, &'b u32) {} diff --git a/src/test/ui/issues/issue-26448-2.rs b/src/test/ui/issues/issue-26448-2.rs index 17e7c1f977a6d..c60e06c3ceb35 100644 --- a/src/test/ui/issues/issue-26448-2.rs +++ b/src/test/ui/issues/issue-26448-2.rs @@ -1,4 +1,4 @@ -// run-pass +// check-pass pub struct Bar { items: Vec<&'static str>, diff --git a/src/test/ui/issues/issue-26448-3.rs b/src/test/ui/issues/issue-26448-3.rs index e57352e57f4fc..d48022c09fee3 100644 --- a/src/test/ui/issues/issue-26448-3.rs +++ b/src/test/ui/issues/issue-26448-3.rs @@ -1,4 +1,4 @@ -// run-pass +// check-pass pub struct Item { _inner: &'static str, diff --git a/src/test/ui/issues/issue-27697.rs b/src/test/ui/issues/issue-27697.rs index 83070012f5f04..12af8a8e875af 100644 --- a/src/test/ui/issues/issue-27697.rs +++ b/src/test/ui/issues/issue-27697.rs @@ -1,4 +1,4 @@ -// run-pass +// check-pass use std::ops::Deref; diff --git a/src/test/ui/issues/issue-38591.rs b/src/test/ui/issues/issue-38591.rs index 7aa71f8b9eb9b..2f594b48e697f 100644 --- a/src/test/ui/issues/issue-38591.rs +++ b/src/test/ui/issues/issue-38591.rs @@ -1,4 +1,4 @@ -// run-pass +// check-pass struct S { t : T, diff --git a/src/test/ui/issues/issue-43806.rs b/src/test/ui/issues/issue-43806.rs index cbfbfa35afbd9..8c8cccfb2bb82 100644 --- a/src/test/ui/issues/issue-43806.rs +++ b/src/test/ui/issues/issue-43806.rs @@ -1,4 +1,4 @@ -// run-pass +// check-pass #![deny(unused_results)] diff --git a/src/test/ui/issues/issue-48132.rs b/src/test/ui/issues/issue-48132.rs index ea325ea695f66..f564aefe78ced 100644 --- a/src/test/ui/issues/issue-48132.rs +++ b/src/test/ui/issues/issue-48132.rs @@ -3,6 +3,8 @@ // run-pass +#![allow(dead_code)] + struct Inner { iterator: I, item: V, diff --git a/src/test/ui/issues/issue-48179.rs b/src/test/ui/issues/issue-48179.rs index 90e9858d74197..f81203dc41299 100644 --- a/src/test/ui/issues/issue-48179.rs +++ b/src/test/ui/issues/issue-48179.rs @@ -1,7 +1,7 @@ // Regression test for #48132. This was failing due to problems around // the projection caching and dropck type enumeration. -// run-pass +// check-pass pub struct Container { value: Option, diff --git a/src/test/ui/issues/issue-61711-once-caused-rustc-inf-loop.rs b/src/test/ui/issues/issue-61711-once-caused-rustc-inf-loop.rs index 8fc09c89f786b..de7d6a0d80c9e 100644 --- a/src/test/ui/issues/issue-61711-once-caused-rustc-inf-loop.rs +++ b/src/test/ui/issues/issue-61711-once-caused-rustc-inf-loop.rs @@ -5,7 +5,7 @@ // aux-build:xcrate-issue-61711-b.rs // compile-flags:--extern xcrate_issue_61711_b -// run-pass +// build-pass fn f(_: F) { } fn main() { } diff --git a/src/test/ui/lint/empty-lint-attributes.rs b/src/test/ui/lint/empty-lint-attributes.rs index 1f0a9538d88b1..9a0ec253322e4 100644 --- a/src/test/ui/lint/empty-lint-attributes.rs +++ b/src/test/ui/lint/empty-lint-attributes.rs @@ -1,6 +1,6 @@ #![feature(lint_reasons)] -// run-pass +// check-pass // Empty (and reason-only) lint attributes are legal—although we may want to // lint them in the future (Issue #55112). diff --git a/src/test/ui/nll/issue-55288.rs b/src/test/ui/nll/issue-55288.rs index c7b6ac5924837..aab2dc267d594 100644 --- a/src/test/ui/nll/issue-55288.rs +++ b/src/test/ui/nll/issue-55288.rs @@ -1,4 +1,4 @@ -// run-pass +// check-pass struct Slice(&'static [&'static [u8]]); diff --git a/src/test/ui/nll/issue-57960.rs b/src/test/ui/nll/issue-57960.rs index 1399694a79b6a..32e45184a9195 100644 --- a/src/test/ui/nll/issue-57960.rs +++ b/src/test/ui/nll/issue-57960.rs @@ -30,7 +30,6 @@ fn digits(x: u8) -> u32 { OneDigit::FIRST..=OneDigit::LAST => 1, TwoDigits::FIRST..=TwoDigits::LAST => 2, ThreeDigits::FIRST..=ThreeDigits::LAST => 3, - _ => unreachable!(), } } diff --git a/src/test/ui/nll/normalization-bounds.rs b/src/test/ui/nll/normalization-bounds.rs index 5d2825ef2d670..bb6d981e0133f 100644 --- a/src/test/ui/nll/normalization-bounds.rs +++ b/src/test/ui/nll/normalization-bounds.rs @@ -1,6 +1,6 @@ // Check that lifetime bounds get checked the right way around with NLL enabled. -//run-pass +// check-pass trait Visitor<'d> { type Value; diff --git a/src/test/ui/nll/promotable-mutable-zst-doesnt-conflict.rs b/src/test/ui/nll/promotable-mutable-zst-doesnt-conflict.rs index 6d5bdfa4da2f0..3b06b0db37065 100644 --- a/src/test/ui/nll/promotable-mutable-zst-doesnt-conflict.rs +++ b/src/test/ui/nll/promotable-mutable-zst-doesnt-conflict.rs @@ -1,11 +1,11 @@ // Check that mutable promoted length zero arrays don't check for conflicting // access -// run-pass +// check-pass pub fn main() { let mut x: Vec<&[i32; 0]> = Vec::new(); - for i in 0..10 { + for _ in 0..10 { x.push(&[]); } } diff --git a/src/test/ui/nll/user-annotations/issue-55219.rs b/src/test/ui/nll/user-annotations/issue-55219.rs index 4d18e96cc1543..147413663897d 100644 --- a/src/test/ui/nll/user-annotations/issue-55219.rs +++ b/src/test/ui/nll/user-annotations/issue-55219.rs @@ -3,7 +3,7 @@ // The `Self::HASH_LEN` here expands to a "self-type" where `T` is not // known. This unbound inference variable was causing an ICE. // -// run-pass +// check-pass pub struct Foo(T); diff --git a/src/test/ui/nll/user-annotations/normalize-self-ty.rs b/src/test/ui/nll/user-annotations/normalize-self-ty.rs index a06229a02032a..df905c8786a18 100644 --- a/src/test/ui/nll/user-annotations/normalize-self-ty.rs +++ b/src/test/ui/nll/user-annotations/normalize-self-ty.rs @@ -2,7 +2,7 @@ // the inherent impl requires normalization to be equal to the // user-provided type. // -// run-pass +// check-pass trait Mirror { type Me; @@ -15,7 +15,7 @@ impl Mirror for T { struct Foo(A, B); impl Foo::Me> { - fn m(b: A) { } + fn m(_: A) { } } fn main() { diff --git a/src/test/ui/rfc-0107-bind-by-move-pattern-guards/bind-by-move-no-guards.rs b/src/test/ui/rfc-0107-bind-by-move-pattern-guards/bind-by-move-no-guards.rs index e43c8541e6d6d..041e410df85c9 100644 --- a/src/test/ui/rfc-0107-bind-by-move-pattern-guards/bind-by-move-no-guards.rs +++ b/src/test/ui/rfc-0107-bind-by-move-pattern-guards/bind-by-move-no-guards.rs @@ -11,8 +11,8 @@ use std::sync::mpsc::channel; fn main() { let (tx, rx) = channel(); let x = Some(rx); - tx.send(false); - tx.send(false); + tx.send(false).unwrap(); + tx.send(false).unwrap(); match x { Some(z) if z.recv().unwrap() => { panic!() }, Some(z) => { assert!(!z.recv().unwrap()); }, diff --git a/src/test/ui/rfc-2008-non-exhaustive/variants_same_crate.rs b/src/test/ui/rfc-2008-non-exhaustive/variants_same_crate.rs index 470a5ea9833ad..fe7df44590b8d 100644 --- a/src/test/ui/rfc-2008-non-exhaustive/variants_same_crate.rs +++ b/src/test/ui/rfc-2008-non-exhaustive/variants_same_crate.rs @@ -10,11 +10,11 @@ pub enum NonExhaustiveVariants { fn main() { let variant_tuple = NonExhaustiveVariants::Tuple(340); - let variant_struct = NonExhaustiveVariants::Struct { field: 340 }; + let _variant_struct = NonExhaustiveVariants::Struct { field: 340 }; match variant_tuple { NonExhaustiveVariants::Unit => "", - NonExhaustiveVariants::Tuple(fe_tpl) => "", - NonExhaustiveVariants::Struct { field } => "" + NonExhaustiveVariants::Tuple(_fe_tpl) => "", + NonExhaustiveVariants::Struct { field: _ } => "" }; } diff --git a/src/test/ui/rfc-2497-if-let-chains/protect-precedences.rs b/src/test/ui/rfc-2497-if-let-chains/protect-precedences.rs index 1de4e5bcebee9..b95105b59eddb 100644 --- a/src/test/ui/rfc-2497-if-let-chains/protect-precedences.rs +++ b/src/test/ui/rfc-2497-if-let-chains/protect-precedences.rs @@ -2,8 +2,6 @@ #![allow(irrefutable_let_patterns)] -use std::ops::Range; - fn main() { let x: bool; // This should associate as: `(x = (true && false));`. diff --git a/src/test/ui/rfc-2497-if-let-chains/protect-precedences.stderr b/src/test/ui/rfc-2497-if-let-chains/protect-precedences.stderr new file mode 100644 index 0000000000000..be7ef658411e1 --- /dev/null +++ b/src/test/ui/rfc-2497-if-let-chains/protect-precedences.stderr @@ -0,0 +1,8 @@ +warning: unreachable block in `if` expression + --> $DIR/protect-precedences.rs:13:41 + | +LL | if let _ = return true && false {}; + | ^^ + | + = note: `#[warn(unreachable_code)]` on by default + diff --git a/src/test/ui/traits/trait-alias/trait-alias-object-wf.rs b/src/test/ui/traits/trait-alias/trait-alias-object-wf.rs index fb26b7e2df7cb..1440f02df1df8 100644 --- a/src/test/ui/traits/trait-alias/trait-alias-object-wf.rs +++ b/src/test/ui/traits/trait-alias/trait-alias-object-wf.rs @@ -1,4 +1,4 @@ -// run-pass +// check-pass // This test checks that trait objects involving trait aliases are well-formed. diff --git a/src/test/ui/type-alias-enum-variants/enum-variant-generic-args-pass.rs b/src/test/ui/type-alias-enum-variants/enum-variant-generic-args-pass.rs index 0c212096f9234..19fcc78721ab1 100644 --- a/src/test/ui/type-alias-enum-variants/enum-variant-generic-args-pass.rs +++ b/src/test/ui/type-alias-enum-variants/enum-variant-generic-args-pass.rs @@ -9,13 +9,13 @@ #![allow(irrefutable_let_patterns)] -enum Enum { TSVariant(T), SVariant { v: T }, UVariant } +enum Enum { TSVariant(T), SVariant { _v: T }, UVariant } type Alias = Enum; type AliasFixed = Enum<()>; macro_rules! is_variant { (TSVariant, $expr:expr) => (is_variant!(@check TSVariant, (_), $expr)); - (SVariant, $expr:expr) => (is_variant!(@check SVariant, { v: _ }, $expr)); + (SVariant, $expr:expr) => (is_variant!(@check SVariant, { _v: _ }, $expr)); (UVariant, $expr:expr) => (is_variant!(@check UVariant, {}, $expr)); (@check $variant:ident, $matcher:tt, $expr:expr) => ( assert!(if let Enum::$variant::<()> $matcher = $expr { true } else { false }, @@ -37,14 +37,14 @@ fn main() { // Struct variant - is_variant!(SVariant, Enum::SVariant { v: () }); - is_variant!(SVariant, Enum::SVariant::<()> { v: () }); - is_variant!(SVariant, Enum::<()>::SVariant { v: () }); + is_variant!(SVariant, Enum::SVariant { _v: () }); + is_variant!(SVariant, Enum::SVariant::<()> { _v: () }); + is_variant!(SVariant, Enum::<()>::SVariant { _v: () }); - is_variant!(SVariant, Alias::SVariant { v: () }); - is_variant!(SVariant, Alias::<()>::SVariant { v: () }); + is_variant!(SVariant, Alias::SVariant { _v: () }); + is_variant!(SVariant, Alias::<()>::SVariant { _v: () }); - is_variant!(SVariant, AliasFixed::SVariant { v: () }); + is_variant!(SVariant, AliasFixed::SVariant { _v: () }); // Unit variant diff --git a/src/test/ui/while-let.rs b/src/test/ui/while-let.rs index 69f9de9497740..53babefae81c0 100644 --- a/src/test/ui/while-let.rs +++ b/src/test/ui/while-let.rs @@ -1,5 +1,6 @@ // run-pass +#[allow(dead_code)] fn macros() { macro_rules! foo{ ($p:pat, $e:expr, $b:block) => {{ @@ -12,16 +13,16 @@ fn macros() { }} } - foo!(a, 1, { //~ WARN irrefutable while-let + foo!(_a, 1, { //~ WARN irrefutable while-let println!("irrefutable pattern"); }); - bar!(a, 1, { //~ WARN irrefutable while-let + bar!(_a, 1, { //~ WARN irrefutable while-let println!("irrefutable pattern"); }); } pub fn main() { - while let a = 1 { //~ WARN irrefutable while-let + while let _a = 1 { //~ WARN irrefutable while-let println!("irrefutable pattern"); break; } diff --git a/src/test/ui/while-let.stderr b/src/test/ui/while-let.stderr index 348925aa9702c..30307ecaeadf2 100644 --- a/src/test/ui/while-let.stderr +++ b/src/test/ui/while-let.stderr @@ -1,10 +1,10 @@ warning: irrefutable while-let pattern - --> $DIR/while-let.rs:6:13 + --> $DIR/while-let.rs:7:13 | LL | while let $p = $e $b | ^^^^^ ... -LL | / foo!(a, 1, { +LL | / foo!(_a, 1, { LL | | println!("irrefutable pattern"); LL | | }); | |_______- in this macro invocation @@ -12,20 +12,20 @@ LL | | }); = note: `#[warn(irrefutable_let_patterns)]` on by default warning: irrefutable while-let pattern - --> $DIR/while-let.rs:6:13 + --> $DIR/while-let.rs:7:13 | LL | while let $p = $e $b | ^^^^^ ... -LL | / bar!(a, 1, { +LL | / bar!(_a, 1, { LL | | println!("irrefutable pattern"); LL | | }); | |_______- in this macro invocation warning: irrefutable while-let pattern - --> $DIR/while-let.rs:24:5 + --> $DIR/while-let.rs:25:5 | -LL | / while let a = 1 { +LL | / while let _a = 1 { LL | | println!("irrefutable pattern"); LL | | break; LL | | } From 85e09c6531e1d3920065310c275b573bfad412ac Mon Sep 17 00:00:00 2001 From: Guanqun Lu Date: Sun, 8 Sep 2019 16:26:06 +0800 Subject: [PATCH 18/27] use 'get_toml' instead of regular expression --- src/bootstrap/bootstrap.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/bootstrap/bootstrap.py b/src/bootstrap/bootstrap.py index e0e4c076071b6..14bc90700b76e 100644 --- a/src/bootstrap/bootstrap.py +++ b/src/bootstrap/bootstrap.py @@ -523,6 +523,10 @@ def get_toml(self, key, section=None): 'value2' >>> rb.get_toml('key', 'c') is None True + + >>> rb.config_toml = 'key1 = true' + >>> rb.get_toml("key1") + 'true' """ cur_section = None @@ -571,6 +575,12 @@ def get_string(line): >>> RustBuild.get_string(' "devel" ') 'devel' + >>> RustBuild.get_string(" 'devel' ") + 'devel' + >>> RustBuild.get_string('devel') is None + True + >>> RustBuild.get_string(' "devel ') + '' """ start = line.find('"') if start != -1: @@ -822,13 +832,13 @@ def bootstrap(help_triggered): except (OSError, IOError): pass - match = re.search(r'\nverbose = (\d+)', build.config_toml) - if match is not None: - build.verbose = max(build.verbose, int(match.group(1))) + config_verbose = build.get_toml('verbose', 'build') + if config_verbose is not None: + build.verbose = max(build.verbose, int(config_verbose)) - build.use_vendored_sources = '\nvendor = true' in build.config_toml + build.use_vendored_sources = build.get_toml('vendor', 'build') == 'true' - build.use_locked_deps = '\nlocked-deps = true' in build.config_toml + build.use_locked_deps = build.get_toml('locked-deps', 'build') == 'true' build.check_vendored_status() From fc4375a895c899e937892c5666372cf14d35c6df Mon Sep 17 00:00:00 2001 From: V1shvesh <22243137+V1shvesh@users.noreply.github.com> Date: Sun, 8 Sep 2019 22:58:28 +0530 Subject: [PATCH 19/27] Remove extra trailing newline --- src/librustc_errors/lib.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/librustc_errors/lib.rs b/src/librustc_errors/lib.rs index b5341a2b727a5..20338a33ef684 100644 --- a/src/librustc_errors/lib.rs +++ b/src/librustc_errors/lib.rs @@ -852,4 +852,3 @@ macro_rules! pluralise { if $x != 1 { "s" } else { "" } }; } - From 7457ef858026d1858e9a36c7fad7a95773d0632d Mon Sep 17 00:00:00 2001 From: V1shvesh <22243137+V1shvesh@users.noreply.github.com> Date: Sun, 8 Sep 2019 23:01:43 +0530 Subject: [PATCH 20/27] Dedent macro definition --- src/librustc_errors/lib.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/librustc_errors/lib.rs b/src/librustc_errors/lib.rs index 20338a33ef684..c1fba416d6433 100644 --- a/src/librustc_errors/lib.rs +++ b/src/librustc_errors/lib.rs @@ -848,7 +848,7 @@ impl Level { #[macro_export] macro_rules! pluralise { - ($x:expr) => { - if $x != 1 { "s" } else { "" } - }; + ($x:expr) => { + if $x != 1 { "s" } else { "" } + }; } From 19db48ae389ee523c971e52302189606aab45a9b Mon Sep 17 00:00:00 2001 From: Mark Mansi Date: Thu, 5 Sep 2019 17:03:12 -0500 Subject: [PATCH 21/27] update rustc-guide --- src/doc/rustc-guide | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/rustc-guide b/src/doc/rustc-guide index 6e25a3d0d3573..a0c08c27e60e5 160000 --- a/src/doc/rustc-guide +++ b/src/doc/rustc-guide @@ -1 +1 @@ -Subproject commit 6e25a3d0d3573eb42b2e2339f1219e969d1b3dee +Subproject commit a0c08c27e60e52b72244c5241ed494a197bebf28 From 7c2dad292e93fc9bbb16085e0dddc2c57d7db7aa Mon Sep 17 00:00:00 2001 From: mark Date: Fri, 6 Sep 2019 16:01:46 -0500 Subject: [PATCH 22/27] update guide --- src/doc/rustc-guide | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/rustc-guide b/src/doc/rustc-guide index a0c08c27e60e5..941968db2fd9c 160000 --- a/src/doc/rustc-guide +++ b/src/doc/rustc-guide @@ -1 +1 @@ -Subproject commit a0c08c27e60e52b72244c5241ed494a197bebf28 +Subproject commit 941968db2fd9c85788a4f971c8e425d46b4cb734 From 5799fb419c96a9e6a170f7980f67fd9047fd6f96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Fri, 6 Sep 2019 12:00:07 -0700 Subject: [PATCH 23/27] Give method not found a primary span label --- src/librustc_typeck/check/method/suggest.rs | 3 ++ src/test/ui/auto-ref-slice-plus-ref.stderr | 6 +-- src/test/ui/class-cast-to-trait.stderr | 2 +- .../coherence/coherence_inherent.old.stderr | 2 +- .../ui/coherence/coherence_inherent.re.stderr | 2 +- .../coherence_inherent_cc.old.stderr | 2 +- .../coherence/coherence_inherent_cc.re.stderr | 2 +- .../invalid-const-arg-for-type-param.stderr | 2 +- src/test/ui/copy-a-resource.stderr | 2 +- .../derives/derive-assoc-type-not-impl.stderr | 2 +- src/test/ui/error-festival.stderr | 2 +- .../ui/hygiene/no_implicit_prelude.stderr | 2 +- src/test/ui/hygiene/trait_items.stderr | 2 +- src/test/ui/impl-trait/bindings-opaque.stderr | 6 +-- ...e-21659-show-relevant-trait-impls-3.stderr | 2 +- .../method-suggestion-no-duplication.stderr | 2 +- .../no-method-suggested-traits.stderr | 48 +++++++++---------- .../ui/infinite/infinite-autoderef.stderr | 2 +- src/test/ui/issues/issue-10465.stderr | 2 +- src/test/ui/issues/issue-13853.stderr | 2 +- src/test/ui/issues/issue-15207.stderr | 2 +- src/test/ui/issues/issue-1871.stderr | 2 +- src/test/ui/issues/issue-19521.stderr | 2 +- src/test/ui/issues/issue-19692.stderr | 2 +- src/test/ui/issues/issue-2149.stderr | 2 +- src/test/ui/issues/issue-21596.stderr | 2 +- src/test/ui/issues/issue-25385.stderr | 4 +- src/test/ui/issues/issue-2823.stderr | 2 +- src/test/ui/issues/issue-29124.stderr | 4 +- src/test/ui/issues/issue-29181.stderr | 2 +- src/test/ui/issues/issue-31173.stderr | 2 +- src/test/ui/issues/issue-34334.stderr | 2 +- src/test/ui/issues/issue-35677.stderr | 2 +- src/test/ui/issues/issue-39175.stderr | 2 +- src/test/ui/issues/issue-41880.stderr | 2 +- src/test/ui/issues/issue-43189.stderr | 2 +- .../option-as_deref_mut.stderr | 2 +- src/test/ui/issues/issue-5153.stderr | 2 +- src/test/ui/issues/issue-54062.stderr | 2 +- src/test/ui/issues/issue-57362-1.stderr | 2 +- .../macro-backtrace-invalid-internals.stderr | 4 +- .../ui/methods/method-call-err-msg.stderr | 2 +- .../ui/mismatched_types/issue-36053-2.stderr | 2 +- .../method-help-unsatisfied-bound.stderr | 2 +- src/test/ui/non-copyable-void.stderr | 2 +- src/test/ui/noncopyable-class.stderr | 2 +- src/test/ui/object-pointer-types.stderr | 6 +-- .../rust-2018/trait-import-suggestions.stderr | 6 +-- ...point-at-arbitrary-self-type-method.stderr | 2 +- ...at-arbitrary-self-type-trait-method.stderr | 2 +- .../ui/shadowed/shadowed-trait-methods.stderr | 2 +- ...pecialization-trait-not-implemented.stderr | 2 +- ...it-with-missing-trait-bounds-in-arg.stderr | 2 +- src/test/ui/suggestions/issue-21673.stderr | 4 +- .../ui/suggestions/suggest-methods.stderr | 2 +- src/test/ui/traits/trait-impl-1.stderr | 2 +- src/test/ui/traits/trait-item-privacy.stderr | 4 +- .../trivial-bounds/trivial-bounds-leak.stderr | 2 +- ...ed-closures-static-call-wrong-trait.stderr | 2 +- src/test/ui/underscore-imports/shadow.stderr | 2 +- src/test/ui/union/union-derive-clone.stderr | 2 +- src/test/ui/unique-object-noncopyable.stderr | 2 +- src/test/ui/unique-pinned-nocopy.stderr | 2 +- 63 files changed, 101 insertions(+), 98 deletions(-) diff --git a/src/librustc_typeck/check/method/suggest.rs b/src/librustc_typeck/check/method/suggest.rs index 72e6f59715960..3e45b1e98d4ec 100644 --- a/src/librustc_typeck/check/method/suggest.rs +++ b/src/librustc_typeck/check/method/suggest.rs @@ -425,6 +425,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { "private field" }; err.span_label(item_name.span, format!("{}, not a method", field_kind)); + } else if lev_candidate.is_none() && static_sources.is_empty() { + err.span_label(span, format!("{} not found in `{}`", item_kind, ty_str)); + self.tcx.sess.trait_methods_not_found.borrow_mut().insert(orig_span); } } else { err.span_label(span, format!("{} not found in `{}`", item_kind, ty_str)); diff --git a/src/test/ui/auto-ref-slice-plus-ref.stderr b/src/test/ui/auto-ref-slice-plus-ref.stderr index f2e0d379d1b30..3e36f2402a990 100644 --- a/src/test/ui/auto-ref-slice-plus-ref.stderr +++ b/src/test/ui/auto-ref-slice-plus-ref.stderr @@ -12,7 +12,7 @@ error[E0599]: no method named `test` found for type `std::vec::Vec<{integer}>` i --> $DIR/auto-ref-slice-plus-ref.rs:8:7 | LL | a.test(); - | ^^^^ + | ^^^^ method not found in `std::vec::Vec<{integer}>` | = help: items from traits can only be used if the trait is implemented and in scope = note: the following trait defines an item `test`, perhaps you need to implement it: @@ -22,7 +22,7 @@ error[E0599]: no method named `test` found for type `[{integer}; 1]` in the curr --> $DIR/auto-ref-slice-plus-ref.rs:10:11 | LL | ([1]).test(); - | ^^^^ + | ^^^^ method not found in `[{integer}; 1]` | = help: items from traits can only be used if the trait is implemented and in scope = note: the following trait defines an item `test`, perhaps you need to implement it: @@ -32,7 +32,7 @@ error[E0599]: no method named `test` found for type `&[{integer}; 1]` in the cur --> $DIR/auto-ref-slice-plus-ref.rs:11:12 | LL | (&[1]).test(); - | ^^^^ + | ^^^^ method not found in `&[{integer}; 1]` | = help: items from traits can only be used if the trait is implemented and in scope = note: the following trait defines an item `test`, perhaps you need to implement it: diff --git a/src/test/ui/class-cast-to-trait.stderr b/src/test/ui/class-cast-to-trait.stderr index 39f308cdfd490..4cab52e3e974c 100644 --- a/src/test/ui/class-cast-to-trait.stderr +++ b/src/test/ui/class-cast-to-trait.stderr @@ -2,7 +2,7 @@ error[E0599]: no method named `eat` found for type `std::boxed::Box` --> $DIR/class-cast-to-trait.rs:53:8 | LL | nyan.eat(); - | ^^^ + | ^^^ method not found in `std::boxed::Box` error: aborting due to previous error diff --git a/src/test/ui/coherence/coherence_inherent.old.stderr b/src/test/ui/coherence/coherence_inherent.old.stderr index fa564459b2133..750d243480638 100644 --- a/src/test/ui/coherence/coherence_inherent.old.stderr +++ b/src/test/ui/coherence/coherence_inherent.old.stderr @@ -2,7 +2,7 @@ error[E0599]: no method named `the_fn` found for type `&Lib::TheStruct` in the c --> $DIR/coherence_inherent.rs:35:11 | LL | s.the_fn(); - | ^^^^^^ + | ^^^^^^ method not found in `&Lib::TheStruct` | = help: items from traits can only be used if the trait is in scope = note: the following trait is implemented but not in scope, perhaps add a `use` for it: diff --git a/src/test/ui/coherence/coherence_inherent.re.stderr b/src/test/ui/coherence/coherence_inherent.re.stderr index fa564459b2133..750d243480638 100644 --- a/src/test/ui/coherence/coherence_inherent.re.stderr +++ b/src/test/ui/coherence/coherence_inherent.re.stderr @@ -2,7 +2,7 @@ error[E0599]: no method named `the_fn` found for type `&Lib::TheStruct` in the c --> $DIR/coherence_inherent.rs:35:11 | LL | s.the_fn(); - | ^^^^^^ + | ^^^^^^ method not found in `&Lib::TheStruct` | = help: items from traits can only be used if the trait is in scope = note: the following trait is implemented but not in scope, perhaps add a `use` for it: diff --git a/src/test/ui/coherence/coherence_inherent_cc.old.stderr b/src/test/ui/coherence/coherence_inherent_cc.old.stderr index 4d93e699031f3..59166a4609406 100644 --- a/src/test/ui/coherence/coherence_inherent_cc.old.stderr +++ b/src/test/ui/coherence/coherence_inherent_cc.old.stderr @@ -2,7 +2,7 @@ error[E0599]: no method named `the_fn` found for type `&coherence_inherent_cc_li --> $DIR/coherence_inherent_cc.rs:26:11 | LL | s.the_fn(); - | ^^^^^^ + | ^^^^^^ method not found in `&coherence_inherent_cc_lib::TheStruct` | = help: items from traits can only be used if the trait is in scope = note: the following trait is implemented but not in scope, perhaps add a `use` for it: diff --git a/src/test/ui/coherence/coherence_inherent_cc.re.stderr b/src/test/ui/coherence/coherence_inherent_cc.re.stderr index 4d93e699031f3..59166a4609406 100644 --- a/src/test/ui/coherence/coherence_inherent_cc.re.stderr +++ b/src/test/ui/coherence/coherence_inherent_cc.re.stderr @@ -2,7 +2,7 @@ error[E0599]: no method named `the_fn` found for type `&coherence_inherent_cc_li --> $DIR/coherence_inherent_cc.rs:26:11 | LL | s.the_fn(); - | ^^^^^^ + | ^^^^^^ method not found in `&coherence_inherent_cc_lib::TheStruct` | = help: items from traits can only be used if the trait is in scope = note: the following trait is implemented but not in scope, perhaps add a `use` for it: diff --git a/src/test/ui/const-generics/invalid-const-arg-for-type-param.stderr b/src/test/ui/const-generics/invalid-const-arg-for-type-param.stderr index 8f3f91651edfb..47b090cb88678 100644 --- a/src/test/ui/const-generics/invalid-const-arg-for-type-param.stderr +++ b/src/test/ui/const-generics/invalid-const-arg-for-type-param.stderr @@ -11,7 +11,7 @@ LL | struct S; | --------- method `f` not found for this ... LL | S.f::<0>(); - | ^ + | ^ method not found in `S` error[E0107]: wrong number of const arguments: expected 0, found 1 --> $DIR/invalid-const-arg-for-type-param.rs:8:9 diff --git a/src/test/ui/copy-a-resource.stderr b/src/test/ui/copy-a-resource.stderr index cceb9e328b676..054bd0914d31c 100644 --- a/src/test/ui/copy-a-resource.stderr +++ b/src/test/ui/copy-a-resource.stderr @@ -5,7 +5,7 @@ LL | struct Foo { | ---------- method `clone` not found for this ... LL | let _y = x.clone(); - | ^^^^^ + | ^^^^^ method not found in `Foo` | = help: items from traits can only be used if the trait is implemented and in scope = note: the following trait defines an item `clone`, perhaps you need to implement it: diff --git a/src/test/ui/derives/derive-assoc-type-not-impl.stderr b/src/test/ui/derives/derive-assoc-type-not-impl.stderr index b9e175e43d1cf..038de80508ac2 100644 --- a/src/test/ui/derives/derive-assoc-type-not-impl.stderr +++ b/src/test/ui/derives/derive-assoc-type-not-impl.stderr @@ -5,7 +5,7 @@ LL | struct Bar { | ------------------ method `clone` not found for this ... LL | Bar:: { x: 1 }.clone(); - | ^^^^^ + | ^^^^^ method not found in `Bar` | = note: the method `clone` exists but the following trait bounds were not satisfied: `Bar : std::clone::Clone` diff --git a/src/test/ui/error-festival.stderr b/src/test/ui/error-festival.stderr index 8808e95d81b18..73571a375b5f6 100644 --- a/src/test/ui/error-festival.stderr +++ b/src/test/ui/error-festival.stderr @@ -24,7 +24,7 @@ error[E0599]: no method named `z` found for type `&str` in the current scope --> $DIR/error-festival.rs:16:7 | LL | x.z(); - | ^ + | ^ method not found in `&str` error[E0600]: cannot apply unary operator `!` to type `Question` --> $DIR/error-festival.rs:19:5 diff --git a/src/test/ui/hygiene/no_implicit_prelude.stderr b/src/test/ui/hygiene/no_implicit_prelude.stderr index 643f803f62049..8fa55d05bddcb 100644 --- a/src/test/ui/hygiene/no_implicit_prelude.stderr +++ b/src/test/ui/hygiene/no_implicit_prelude.stderr @@ -22,7 +22,7 @@ LL | fn f() { ::bar::m!(); } | ------------ in this macro invocation ... LL | ().clone() - | ^^^^^ + | ^^^^^ method not found in `()` | = help: items from traits can only be used if the trait is in scope = note: the following trait is implemented but not in scope, perhaps add a `use` for it: diff --git a/src/test/ui/hygiene/trait_items.stderr b/src/test/ui/hygiene/trait_items.stderr index 4192b97e75069..39e32522c7a76 100644 --- a/src/test/ui/hygiene/trait_items.stderr +++ b/src/test/ui/hygiene/trait_items.stderr @@ -5,7 +5,7 @@ LL | fn f() { ::baz::m!(); } | ------------ in this macro invocation ... LL | pub macro m() { ().f() } - | ^ + | ^ method not found in `()` | = help: items from traits can only be used if the trait is in scope = note: the following trait is implemented but not in scope, perhaps add a `use` for it: diff --git a/src/test/ui/impl-trait/bindings-opaque.stderr b/src/test/ui/impl-trait/bindings-opaque.stderr index ad108173a7a1e..644d26b34060c 100644 --- a/src/test/ui/impl-trait/bindings-opaque.stderr +++ b/src/test/ui/impl-trait/bindings-opaque.stderr @@ -10,19 +10,19 @@ error[E0599]: no method named `count_ones` found for type `impl std::marker::Cop --> $DIR/bindings-opaque.rs:11:17 | LL | let _ = FOO.count_ones(); - | ^^^^^^^^^^ + | ^^^^^^^^^^ method not found in `impl std::marker::Copy` error[E0599]: no method named `count_ones` found for type `impl std::marker::Copy` in the current scope --> $DIR/bindings-opaque.rs:13:17 | LL | let _ = BAR.count_ones(); - | ^^^^^^^^^^ + | ^^^^^^^^^^ method not found in `impl std::marker::Copy` error[E0599]: no method named `count_ones` found for type `impl std::marker::Copy` in the current scope --> $DIR/bindings-opaque.rs:15:17 | LL | let _ = foo.count_ones(); - | ^^^^^^^^^^ + | ^^^^^^^^^^ method not found in `impl std::marker::Copy` error: aborting due to 3 previous errors diff --git a/src/test/ui/impl-trait/issues/issue-21659-show-relevant-trait-impls-3.stderr b/src/test/ui/impl-trait/issues/issue-21659-show-relevant-trait-impls-3.stderr index 666418f6ee2c1..441191beaf588 100644 --- a/src/test/ui/impl-trait/issues/issue-21659-show-relevant-trait-impls-3.stderr +++ b/src/test/ui/impl-trait/issues/issue-21659-show-relevant-trait-impls-3.stderr @@ -5,7 +5,7 @@ LL | struct Bar; | ----------- method `foo` not found for this ... LL | f1.foo(1usize); - | ^^^ + | ^^^ method not found in `Bar` | = help: items from traits can only be used if the trait is implemented and in scope = note: the following trait defines an item `foo`, perhaps you need to implement it: diff --git a/src/test/ui/impl-trait/method-suggestion-no-duplication.stderr b/src/test/ui/impl-trait/method-suggestion-no-duplication.stderr index afb3376638a96..fb870d6c6f076 100644 --- a/src/test/ui/impl-trait/method-suggestion-no-duplication.stderr +++ b/src/test/ui/impl-trait/method-suggestion-no-duplication.stderr @@ -5,7 +5,7 @@ LL | struct Foo; | ----------- method `is_empty` not found for this ... LL | foo(|s| s.is_empty()); - | ^^^^^^^^ + | ^^^^^^^^ method not found in `Foo` | = help: items from traits can only be used if the trait is implemented and in scope = note: the following trait defines an item `is_empty`, perhaps you need to implement it: diff --git a/src/test/ui/impl-trait/no-method-suggested-traits.stderr b/src/test/ui/impl-trait/no-method-suggested-traits.stderr index 002b60f9f258d..be8f3ab1b72e8 100644 --- a/src/test/ui/impl-trait/no-method-suggested-traits.stderr +++ b/src/test/ui/impl-trait/no-method-suggested-traits.stderr @@ -2,7 +2,7 @@ error[E0599]: no method named `method` found for type `u32` in the current scope --> $DIR/no-method-suggested-traits.rs:23:10 | LL | 1u32.method(); - | ^^^^^^ + | ^^^^^^ method not found in `u32` | = help: items from traits can only be used if the trait is in scope help: the following traits are implemented but not in scope, perhaps add a `use` for one of them: @@ -20,7 +20,7 @@ error[E0599]: no method named `method` found for type `std::rc::Rc<&mut std::box --> $DIR/no-method-suggested-traits.rs:26:44 | LL | std::rc::Rc::new(&mut Box::new(&1u32)).method(); - | ^^^^^^ + | ^^^^^^ method not found in `std::rc::Rc<&mut std::boxed::Box<&u32>>` | = help: items from traits can only be used if the trait is in scope help: the following traits are implemented but not in scope, perhaps add a `use` for one of them: @@ -38,7 +38,7 @@ error[E0599]: no method named `method` found for type `char` in the current scop --> $DIR/no-method-suggested-traits.rs:30:9 | LL | 'a'.method(); - | ^^^^^^ + | ^^^^^^ method not found in `char` | = help: items from traits can only be used if the trait is in scope help: the following trait is implemented but not in scope, perhaps add a `use` for it: @@ -58,7 +58,7 @@ LL | fn method(&self) {} | the method is available for `std::rc::Rc>>` here ... LL | std::rc::Rc::new(&mut Box::new(&'a')).method(); - | ^^^^^^ + | ^^^^^^ method not found in `std::rc::Rc<&mut std::boxed::Box<&char>>` | = help: items from traits can only be used if the trait is in scope help: the following trait is implemented but not in scope, perhaps add a `use` for it: @@ -70,7 +70,7 @@ error[E0599]: no method named `method` found for type `i32` in the current scope --> $DIR/no-method-suggested-traits.rs:35:10 | LL | 1i32.method(); - | ^^^^^^ + | ^^^^^^ method not found in `i32` | = help: items from traits can only be used if the trait is in scope help: the following trait is implemented but not in scope, perhaps add a `use` for it: @@ -82,7 +82,7 @@ error[E0599]: no method named `method` found for type `std::rc::Rc<&mut std::box --> $DIR/no-method-suggested-traits.rs:37:44 | LL | std::rc::Rc::new(&mut Box::new(&1i32)).method(); - | ^^^^^^ + | ^^^^^^ method not found in `std::rc::Rc<&mut std::boxed::Box<&i32>>` | = help: items from traits can only be used if the trait is in scope help: the following trait is implemented but not in scope, perhaps add a `use` for it: @@ -97,7 +97,7 @@ LL | struct Foo; | ----------- method `method` not found for this ... LL | Foo.method(); - | ^^^^^^ + | ^^^^^^ method not found in `Foo` | = help: items from traits can only be used if the trait is implemented and in scope = note: the following traits define an item `method`, perhaps you need to implement one of them: @@ -110,7 +110,7 @@ error[E0599]: no method named `method` found for type `std::rc::Rc<&mut std::box --> $DIR/no-method-suggested-traits.rs:42:43 | LL | std::rc::Rc::new(&mut Box::new(&Foo)).method(); - | ^^^^^^ + | ^^^^^^ method not found in `std::rc::Rc<&mut std::boxed::Box<&Foo>>` | = help: items from traits can only be used if the trait is implemented and in scope = note: the following traits define an item `method`, perhaps you need to implement one of them: @@ -123,7 +123,7 @@ error[E0599]: no method named `method2` found for type `u64` in the current scop --> $DIR/no-method-suggested-traits.rs:45:10 | LL | 1u64.method2(); - | ^^^^^^^ + | ^^^^^^^ method not found in `u64` | = help: items from traits can only be used if the trait is implemented and in scope = note: the following trait defines an item `method2`, perhaps you need to implement it: @@ -133,7 +133,7 @@ error[E0599]: no method named `method2` found for type `std::rc::Rc<&mut std::bo --> $DIR/no-method-suggested-traits.rs:47:44 | LL | std::rc::Rc::new(&mut Box::new(&1u64)).method2(); - | ^^^^^^^ + | ^^^^^^^ method not found in `std::rc::Rc<&mut std::boxed::Box<&u64>>` | = help: items from traits can only be used if the trait is implemented and in scope = note: the following trait defines an item `method2`, perhaps you need to implement it: @@ -143,7 +143,7 @@ error[E0599]: no method named `method2` found for type `no_method_suggested_trai --> $DIR/no-method-suggested-traits.rs:50:37 | LL | no_method_suggested_traits::Foo.method2(); - | ^^^^^^^ + | ^^^^^^^ method not found in `no_method_suggested_traits::Foo` | = help: items from traits can only be used if the trait is implemented and in scope = note: the following trait defines an item `method2`, perhaps you need to implement it: @@ -153,7 +153,7 @@ error[E0599]: no method named `method2` found for type `std::rc::Rc<&mut std::bo --> $DIR/no-method-suggested-traits.rs:52:71 | LL | std::rc::Rc::new(&mut Box::new(&no_method_suggested_traits::Foo)).method2(); - | ^^^^^^^ + | ^^^^^^^ method not found in `std::rc::Rc<&mut std::boxed::Box<&no_method_suggested_traits::Foo>>` | = help: items from traits can only be used if the trait is implemented and in scope = note: the following trait defines an item `method2`, perhaps you need to implement it: @@ -163,7 +163,7 @@ error[E0599]: no method named `method2` found for type `no_method_suggested_trai --> $DIR/no-method-suggested-traits.rs:54:40 | LL | no_method_suggested_traits::Bar::X.method2(); - | ^^^^^^^ + | ^^^^^^^ method not found in `no_method_suggested_traits::Bar` | = help: items from traits can only be used if the trait is implemented and in scope = note: the following trait defines an item `method2`, perhaps you need to implement it: @@ -173,7 +173,7 @@ error[E0599]: no method named `method2` found for type `std::rc::Rc<&mut std::bo --> $DIR/no-method-suggested-traits.rs:56:74 | LL | std::rc::Rc::new(&mut Box::new(&no_method_suggested_traits::Bar::X)).method2(); - | ^^^^^^^ + | ^^^^^^^ method not found in `std::rc::Rc<&mut std::boxed::Box<&no_method_suggested_traits::Bar>>` | = help: items from traits can only be used if the trait is implemented and in scope = note: the following trait defines an item `method2`, perhaps you need to implement it: @@ -186,7 +186,7 @@ LL | struct Foo; | ----------- method `method3` not found for this ... LL | Foo.method3(); - | ^^^^^^^ + | ^^^^^^^ method not found in `Foo` | = help: items from traits can only be used if the trait is implemented and in scope = note: the following trait defines an item `method3`, perhaps you need to implement it: @@ -196,7 +196,7 @@ error[E0599]: no method named `method3` found for type `std::rc::Rc<&mut std::bo --> $DIR/no-method-suggested-traits.rs:61:43 | LL | std::rc::Rc::new(&mut Box::new(&Foo)).method3(); - | ^^^^^^^ + | ^^^^^^^ method not found in `std::rc::Rc<&mut std::boxed::Box<&Foo>>` | = help: items from traits can only be used if the trait is implemented and in scope = note: the following trait defines an item `method3`, perhaps you need to implement it: @@ -209,7 +209,7 @@ LL | enum Bar { X } | -------- method `method3` not found for this ... LL | Bar::X.method3(); - | ^^^^^^^ + | ^^^^^^^ method not found in `Bar` | = help: items from traits can only be used if the trait is implemented and in scope = note: the following trait defines an item `method3`, perhaps you need to implement it: @@ -219,7 +219,7 @@ error[E0599]: no method named `method3` found for type `std::rc::Rc<&mut std::bo --> $DIR/no-method-suggested-traits.rs:65:46 | LL | std::rc::Rc::new(&mut Box::new(&Bar::X)).method3(); - | ^^^^^^^ + | ^^^^^^^ method not found in `std::rc::Rc<&mut std::boxed::Box<&Bar>>` | = help: items from traits can only be used if the trait is implemented and in scope = note: the following trait defines an item `method3`, perhaps you need to implement it: @@ -229,37 +229,37 @@ error[E0599]: no method named `method3` found for type `usize` in the current sc --> $DIR/no-method-suggested-traits.rs:69:13 | LL | 1_usize.method3(); - | ^^^^^^^ + | ^^^^^^^ method not found in `usize` error[E0599]: no method named `method3` found for type `std::rc::Rc<&mut std::boxed::Box<&usize>>` in the current scope --> $DIR/no-method-suggested-traits.rs:70:47 | LL | std::rc::Rc::new(&mut Box::new(&1_usize)).method3(); - | ^^^^^^^ + | ^^^^^^^ method not found in `std::rc::Rc<&mut std::boxed::Box<&usize>>` error[E0599]: no method named `method3` found for type `no_method_suggested_traits::Foo` in the current scope --> $DIR/no-method-suggested-traits.rs:71:37 | LL | no_method_suggested_traits::Foo.method3(); - | ^^^^^^^ + | ^^^^^^^ method not found in `no_method_suggested_traits::Foo` error[E0599]: no method named `method3` found for type `std::rc::Rc<&mut std::boxed::Box<&no_method_suggested_traits::Foo>>` in the current scope --> $DIR/no-method-suggested-traits.rs:72:71 | LL | std::rc::Rc::new(&mut Box::new(&no_method_suggested_traits::Foo)).method3(); - | ^^^^^^^ + | ^^^^^^^ method not found in `std::rc::Rc<&mut std::boxed::Box<&no_method_suggested_traits::Foo>>` error[E0599]: no method named `method3` found for type `no_method_suggested_traits::Bar` in the current scope --> $DIR/no-method-suggested-traits.rs:74:40 | LL | no_method_suggested_traits::Bar::X.method3(); - | ^^^^^^^ + | ^^^^^^^ method not found in `no_method_suggested_traits::Bar` error[E0599]: no method named `method3` found for type `std::rc::Rc<&mut std::boxed::Box<&no_method_suggested_traits::Bar>>` in the current scope --> $DIR/no-method-suggested-traits.rs:75:74 | LL | std::rc::Rc::new(&mut Box::new(&no_method_suggested_traits::Bar::X)).method3(); - | ^^^^^^^ + | ^^^^^^^ method not found in `std::rc::Rc<&mut std::boxed::Box<&no_method_suggested_traits::Bar>>` error: aborting due to 24 previous errors diff --git a/src/test/ui/infinite/infinite-autoderef.stderr b/src/test/ui/infinite/infinite-autoderef.stderr index 3159a4b67dae5..a2ad58a7e46fc 100644 --- a/src/test/ui/infinite/infinite-autoderef.stderr +++ b/src/test/ui/infinite/infinite-autoderef.stderr @@ -44,7 +44,7 @@ LL | struct Foo; | ----------- method `bar` not found for this ... LL | Foo.bar(); - | ^^^ + | ^^^ method not found in `Foo` error: aborting due to 6 previous errors diff --git a/src/test/ui/issues/issue-10465.stderr b/src/test/ui/issues/issue-10465.stderr index 6efbd8e40ef64..413daa6db6787 100644 --- a/src/test/ui/issues/issue-10465.stderr +++ b/src/test/ui/issues/issue-10465.stderr @@ -2,7 +2,7 @@ error[E0599]: no method named `foo` found for type `&b::B` in the current scope --> $DIR/issue-10465.rs:17:15 | LL | b.foo(); - | ^^^ + | ^^^ method not found in `&b::B` | = help: items from traits can only be used if the trait is in scope = note: the following trait is implemented but not in scope, perhaps add a `use` for it: diff --git a/src/test/ui/issues/issue-13853.stderr b/src/test/ui/issues/issue-13853.stderr index 9026845b4ed86..c57ca3e25d99f 100644 --- a/src/test/ui/issues/issue-13853.stderr +++ b/src/test/ui/issues/issue-13853.stderr @@ -14,7 +14,7 @@ error[E0599]: no method named `iter` found for type `&G` in the current scope --> $DIR/issue-13853.rs:27:23 | LL | for node in graph.iter() { - | ^^^^ + | ^^^^ method not found in `&G` error[E0308]: mismatched types --> $DIR/issue-13853.rs:37:13 diff --git a/src/test/ui/issues/issue-15207.stderr b/src/test/ui/issues/issue-15207.stderr index 2d90eb80fc54c..25ce7cb5cc069 100644 --- a/src/test/ui/issues/issue-15207.stderr +++ b/src/test/ui/issues/issue-15207.stderr @@ -2,7 +2,7 @@ error[E0599]: no method named `push` found for type `!` in the current scope --> $DIR/issue-15207.rs:3:15 | LL | break.push(1) - | ^^^^ + | ^^^^ method not found in `!` error: aborting due to previous error diff --git a/src/test/ui/issues/issue-1871.stderr b/src/test/ui/issues/issue-1871.stderr index fecd689251b32..b774ca22dd72a 100644 --- a/src/test/ui/issues/issue-1871.stderr +++ b/src/test/ui/issues/issue-1871.stderr @@ -2,7 +2,7 @@ error[E0599]: no method named `honk` found for type `{integer}` in the current s --> $DIR/issue-1871.rs:7:9 | LL | f.honk() - | ^^^^ + | ^^^^ method not found in `{integer}` error: aborting due to previous error diff --git a/src/test/ui/issues/issue-19521.stderr b/src/test/ui/issues/issue-19521.stderr index a43368be58339..c15c5392fac25 100644 --- a/src/test/ui/issues/issue-19521.stderr +++ b/src/test/ui/issues/issue-19521.stderr @@ -2,7 +2,7 @@ error[E0599]: no method named `homura` found for type `&'static str` in the curr --> $DIR/issue-19521.rs:2:8 | LL | "".homura()(); - | ^^^^^^ + | ^^^^^^ method not found in `&'static str` error: aborting due to previous error diff --git a/src/test/ui/issues/issue-19692.stderr b/src/test/ui/issues/issue-19692.stderr index 5e576f11583eb..fe920c1693982 100644 --- a/src/test/ui/issues/issue-19692.stderr +++ b/src/test/ui/issues/issue-19692.stderr @@ -5,7 +5,7 @@ LL | struct Homura; | -------------- method `kaname` not found for this ... LL | let Some(ref madoka) = Some(homura.kaname()); - | ^^^^^^ + | ^^^^^^ method not found in `Homura` error: aborting due to previous error diff --git a/src/test/ui/issues/issue-2149.stderr b/src/test/ui/issues/issue-2149.stderr index 1df32aafa79c8..8ce2ba033321e 100644 --- a/src/test/ui/issues/issue-2149.stderr +++ b/src/test/ui/issues/issue-2149.stderr @@ -10,7 +10,7 @@ error[E0599]: no method named `bind` found for type `[&str; 1]` in the current s --> $DIR/issue-2149.rs:13:12 | LL | ["hi"].bind(|x| [x] ); - | ^^^^ + | ^^^^ method not found in `[&str; 1]` | = help: items from traits can only be used if the trait is implemented and in scope = note: the following trait defines an item `bind`, perhaps you need to implement it: diff --git a/src/test/ui/issues/issue-21596.stderr b/src/test/ui/issues/issue-21596.stderr index 8e4e09b13a9bd..4e5cace525787 100644 --- a/src/test/ui/issues/issue-21596.stderr +++ b/src/test/ui/issues/issue-21596.stderr @@ -2,7 +2,7 @@ error[E0599]: no method named `to_string` found for type `*const u8` in the curr --> $DIR/issue-21596.rs:4:22 | LL | println!("{}", z.to_string()); - | ^^^^^^^^^ + | ^^^^^^^^^ method not found in `*const u8` | = note: try using `<*const T>::as_ref()` to get a reference to the type behind the pointer: https://doc.rust-lang.org/std/primitive.pointer.html#method.as_ref = note: using `<*const T>::as_ref()` on a pointer which is unaligned or points to invalid or uninitialized memory is undefined behavior diff --git a/src/test/ui/issues/issue-25385.stderr b/src/test/ui/issues/issue-25385.stderr index e170a9d383b0e..ab4db7e42a4b9 100644 --- a/src/test/ui/issues/issue-25385.stderr +++ b/src/test/ui/issues/issue-25385.stderr @@ -2,7 +2,7 @@ error[E0599]: no method named `foo` found for type `i32` in the current scope --> $DIR/issue-25385.rs:2:23 | LL | ($e:expr) => { $e.foo() } - | ^^^ + | ^^^ method not found in `i32` ... LL | foo!(a); | -------- in this macro invocation @@ -11,7 +11,7 @@ error[E0599]: no method named `foo` found for type `i32` in the current scope --> $DIR/issue-25385.rs:10:15 | LL | foo!(1i32.foo()); - | ^^^ + | ^^^ method not found in `i32` error: aborting due to 2 previous errors diff --git a/src/test/ui/issues/issue-2823.stderr b/src/test/ui/issues/issue-2823.stderr index 4c1dfb8501a91..c9ede03003434 100644 --- a/src/test/ui/issues/issue-2823.stderr +++ b/src/test/ui/issues/issue-2823.stderr @@ -5,7 +5,7 @@ LL | struct C { | -------- method `clone` not found for this ... LL | let _d = c.clone(); - | ^^^^^ + | ^^^^^ method not found in `C` | = help: items from traits can only be used if the trait is implemented and in scope = note: the following trait defines an item `clone`, perhaps you need to implement it: diff --git a/src/test/ui/issues/issue-29124.stderr b/src/test/ui/issues/issue-29124.stderr index 3beb728978884..c537c6118f3a8 100644 --- a/src/test/ui/issues/issue-29124.stderr +++ b/src/test/ui/issues/issue-29124.stderr @@ -2,7 +2,7 @@ error[E0599]: no method named `x` found for type `fn() -> Ret {Obj::func}` in th --> $DIR/issue-29124.rs:15:15 | LL | Obj::func.x(); - | ^ + | ^ method not found in `fn() -> Ret {Obj::func}` | = note: Obj::func is a function, perhaps you wish to call it @@ -10,7 +10,7 @@ error[E0599]: no method named `x` found for type `fn() -> Ret {func}` in the cur --> $DIR/issue-29124.rs:17:10 | LL | func.x(); - | ^ + | ^ method not found in `fn() -> Ret {func}` | = note: func is a function, perhaps you wish to call it diff --git a/src/test/ui/issues/issue-29181.stderr b/src/test/ui/issues/issue-29181.stderr index 092014281546f..250b158ab8e33 100644 --- a/src/test/ui/issues/issue-29181.stderr +++ b/src/test/ui/issues/issue-29181.stderr @@ -2,7 +2,7 @@ error[E0599]: no method named `homura` found for type `{integer}` in the current --> $DIR/issue-29181.rs:6:7 | LL | 0.homura(); - | ^^^^^^ + | ^^^^^^ method not found in `{integer}` error: aborting due to previous error diff --git a/src/test/ui/issues/issue-31173.stderr b/src/test/ui/issues/issue-31173.stderr index 3ca8338882681..6d03b7810939a 100644 --- a/src/test/ui/issues/issue-31173.stderr +++ b/src/test/ui/issues/issue-31173.stderr @@ -11,7 +11,7 @@ error[E0599]: no method named `collect` found for type `std::iter::Cloned $DIR/issue-31173.rs:14:10 | LL | .collect(); - | ^^^^^^^ + | ^^^^^^^ method not found in `std::iter::Cloned, [closure@$DIR/issue-31173.rs:6:39: 9:6 found_e:_]>>` | = note: the method `collect` exists but the following trait bounds were not satisfied: `&mut std::iter::Cloned, [closure@$DIR/issue-31173.rs:6:39: 9:6 found_e:_]>> : std::iter::Iterator` diff --git a/src/test/ui/issues/issue-34334.stderr b/src/test/ui/issues/issue-34334.stderr index 7f89caf92abe1..8d52e08374ac7 100644 --- a/src/test/ui/issues/issue-34334.stderr +++ b/src/test/ui/issues/issue-34334.stderr @@ -45,7 +45,7 @@ error[E0599]: no method named `iter` found for type `()` in the current scope --> $DIR/issue-34334.rs:9:36 | LL | let sr2: Vec<(u32, _, _)> = sr.iter().map(|(faction, th_sender, th_receiver)| {}).collect(); - | ^^^^ + | ^^^^ method not found in `()` error: aborting due to 7 previous errors diff --git a/src/test/ui/issues/issue-35677.stderr b/src/test/ui/issues/issue-35677.stderr index 99d99db93f3e3..b381203856e92 100644 --- a/src/test/ui/issues/issue-35677.stderr +++ b/src/test/ui/issues/issue-35677.stderr @@ -2,7 +2,7 @@ error[E0599]: no method named `is_subset` found for type `&std::collections::Has --> $DIR/issue-35677.rs:4:10 | LL | this.is_subset(other) - | ^^^^^^^^^ + | ^^^^^^^^^ method not found in `&std::collections::HashSet` | = note: the method `is_subset` exists but the following trait bounds were not satisfied: `T : std::cmp::Eq` diff --git a/src/test/ui/issues/issue-39175.stderr b/src/test/ui/issues/issue-39175.stderr index 108c969cdadde..66680b9936e68 100644 --- a/src/test/ui/issues/issue-39175.stderr +++ b/src/test/ui/issues/issue-39175.stderr @@ -2,7 +2,7 @@ error[E0599]: no method named `exec` found for type `&mut std::process::Command` --> $DIR/issue-39175.rs:15:39 | LL | Command::new("echo").arg("hello").exec(); - | ^^^^ + | ^^^^ method not found in `&mut std::process::Command` | = help: items from traits can only be used if the trait is in scope help: the following trait is implemented but not in scope, perhaps add a `use` for it: diff --git a/src/test/ui/issues/issue-41880.stderr b/src/test/ui/issues/issue-41880.stderr index 359a2340240a7..0e1d55c339eb4 100644 --- a/src/test/ui/issues/issue-41880.stderr +++ b/src/test/ui/issues/issue-41880.stderr @@ -5,7 +5,7 @@ LL | pub struct Iterate { | ------------------------ method `iter` not found for this ... LL | println!("{:?}", a.iter().take(10).collect::>()); - | ^^^^ + | ^^^^ method not found in `Iterate<{integer}, [closure@$DIR/issue-41880.rs:26:24: 26:31]>` error: aborting due to previous error diff --git a/src/test/ui/issues/issue-43189.stderr b/src/test/ui/issues/issue-43189.stderr index e364650da40a1..33c3f18650a80 100644 --- a/src/test/ui/issues/issue-43189.stderr +++ b/src/test/ui/issues/issue-43189.stderr @@ -2,7 +2,7 @@ error[E0599]: no method named `a` found for type `()` in the current scope --> $DIR/issue-43189.rs:10:8 | LL | ().a(); - | ^ + | ^ method not found in `()` | = help: items from traits can only be used if the trait is in scope help: the following trait is implemented but not in scope, perhaps add a `use` for it: diff --git a/src/test/ui/issues/issue-50264-inner-deref-trait/option-as_deref_mut.stderr b/src/test/ui/issues/issue-50264-inner-deref-trait/option-as_deref_mut.stderr index 2c3a18be67c8f..29fd15fb396e9 100644 --- a/src/test/ui/issues/issue-50264-inner-deref-trait/option-as_deref_mut.stderr +++ b/src/test/ui/issues/issue-50264-inner-deref-trait/option-as_deref_mut.stderr @@ -2,7 +2,7 @@ error[E0599]: no method named `as_deref_mut` found for type `std::option::Option --> $DIR/option-as_deref_mut.rs:4:33 | LL | let _result = &mut Some(42).as_deref_mut(); - | ^^^^^^^^^^^^ + | ^^^^^^^^^^^^ method not found in `std::option::Option<{integer}>` | = note: the method `as_deref_mut` exists but the following trait bounds were not satisfied: `{integer} : std::ops::DerefMut` diff --git a/src/test/ui/issues/issue-5153.stderr b/src/test/ui/issues/issue-5153.stderr index 97214fbdc52d4..5034e6d538e3e 100644 --- a/src/test/ui/issues/issue-5153.stderr +++ b/src/test/ui/issues/issue-5153.stderr @@ -2,7 +2,7 @@ error[E0599]: no method named `foo` found for type `&dyn Foo` in the current sco --> $DIR/issue-5153.rs:10:27 | LL | (&5isize as &dyn Foo).foo(); - | ^^^ + | ^^^ method not found in `&dyn Foo` | = help: items from traits can only be used if the trait is implemented and in scope = note: the following trait defines an item `foo`, perhaps you need to implement it: diff --git a/src/test/ui/issues/issue-54062.stderr b/src/test/ui/issues/issue-54062.stderr index 082ac91edb1c4..3830ad4b1e3ae 100644 --- a/src/test/ui/issues/issue-54062.stderr +++ b/src/test/ui/issues/issue-54062.stderr @@ -8,7 +8,7 @@ error[E0599]: no method named `unwrap` found for type `std::sys_common::mutex::M --> $DIR/issue-54062.rs:10:37 | LL | let _ = test.comps.inner.lock().unwrap(); - | ^^^^^^ + | ^^^^^^ method not found in `std::sys_common::mutex::MutexGuard<'_>` error: aborting due to 2 previous errors diff --git a/src/test/ui/issues/issue-57362-1.stderr b/src/test/ui/issues/issue-57362-1.stderr index 1d2ff7669c093..c4000c8a9d41e 100644 --- a/src/test/ui/issues/issue-57362-1.stderr +++ b/src/test/ui/issues/issue-57362-1.stderr @@ -2,7 +2,7 @@ error[E0599]: no method named `f` found for type `fn(&u8)` in the current scope --> $DIR/issue-57362-1.rs:20:7 | LL | a.f(); - | ^ + | ^ method not found in `fn(&u8)` | = note: a is a function, perhaps you wish to call it = help: items from traits can only be used if the trait is implemented and in scope diff --git a/src/test/ui/macros/macro-backtrace-invalid-internals.stderr b/src/test/ui/macros/macro-backtrace-invalid-internals.stderr index 015e05ed9bf61..96054de801c1f 100644 --- a/src/test/ui/macros/macro-backtrace-invalid-internals.stderr +++ b/src/test/ui/macros/macro-backtrace-invalid-internals.stderr @@ -2,7 +2,7 @@ error[E0599]: no method named `fake` found for type `{integer}` in the current s --> $DIR/macro-backtrace-invalid-internals.rs:5:13 | LL | 1.fake() - | ^^^^ + | ^^^^ method not found in `{integer}` ... LL | fake_method_stmt!(); | -------------------- in this macro invocation @@ -42,7 +42,7 @@ error[E0599]: no method named `fake` found for type `{integer}` in the current s --> $DIR/macro-backtrace-invalid-internals.rs:23:13 | LL | 1.fake() - | ^^^^ + | ^^^^ method not found in `{integer}` ... LL | let _ = fake_method_expr!(); | ------------------- in this macro invocation diff --git a/src/test/ui/methods/method-call-err-msg.stderr b/src/test/ui/methods/method-call-err-msg.stderr index b8ae4c34dc155..94c27b7d17865 100644 --- a/src/test/ui/methods/method-call-err-msg.stderr +++ b/src/test/ui/methods/method-call-err-msg.stderr @@ -32,7 +32,7 @@ LL | pub struct Foo; | --------------- method `take` not found for this ... LL | .take() - | ^^^^ + | ^^^^ method not found in `Foo` | = note: the method `take` exists but the following trait bounds were not satisfied: `&mut Foo : std::iter::Iterator` diff --git a/src/test/ui/mismatched_types/issue-36053-2.stderr b/src/test/ui/mismatched_types/issue-36053-2.stderr index 3f87ef74b8ea3..89c7b0981158a 100644 --- a/src/test/ui/mismatched_types/issue-36053-2.stderr +++ b/src/test/ui/mismatched_types/issue-36053-2.stderr @@ -2,7 +2,7 @@ error[E0599]: no method named `count` found for type `std::iter::Filter $DIR/issue-36053-2.rs:7:55 | LL | once::<&str>("str").fuse().filter(|a: &str| true).count(); - | ^^^^^ + | ^^^^^ method not found in `std::iter::Filter>, [closure@$DIR/issue-36053-2.rs:7:39: 7:53]>` | = note: the method `count` exists but the following trait bounds were not satisfied: `&mut std::iter::Filter>, [closure@$DIR/issue-36053-2.rs:7:39: 7:53]> : std::iter::Iterator` diff --git a/src/test/ui/mismatched_types/method-help-unsatisfied-bound.stderr b/src/test/ui/mismatched_types/method-help-unsatisfied-bound.stderr index 9721dc8ba4e6c..865092e4e9ccc 100644 --- a/src/test/ui/mismatched_types/method-help-unsatisfied-bound.stderr +++ b/src/test/ui/mismatched_types/method-help-unsatisfied-bound.stderr @@ -2,7 +2,7 @@ error[E0599]: no method named `unwrap` found for type `std::result::Result<(), F --> $DIR/method-help-unsatisfied-bound.rs:5:7 | LL | a.unwrap(); - | ^^^^^^ + | ^^^^^^ method not found in `std::result::Result<(), Foo>` | = note: the method `unwrap` exists but the following trait bounds were not satisfied: `Foo : std::fmt::Debug` diff --git a/src/test/ui/non-copyable-void.stderr b/src/test/ui/non-copyable-void.stderr index 4041e1935dcb7..b05c29c0d4036 100644 --- a/src/test/ui/non-copyable-void.stderr +++ b/src/test/ui/non-copyable-void.stderr @@ -2,7 +2,7 @@ error[E0599]: no method named `clone` found for type `libc::c_void` in the curre --> $DIR/non-copyable-void.rs:11:23 | LL | let _z = (*y).clone(); - | ^^^^^ + | ^^^^^ method not found in `libc::c_void` error: aborting due to previous error diff --git a/src/test/ui/noncopyable-class.stderr b/src/test/ui/noncopyable-class.stderr index eb47a33a7292b..c1c5021138189 100644 --- a/src/test/ui/noncopyable-class.stderr +++ b/src/test/ui/noncopyable-class.stderr @@ -5,7 +5,7 @@ LL | struct Foo { | ---------- method `clone` not found for this ... LL | let _y = x.clone(); - | ^^^^^ + | ^^^^^ method not found in `Foo` | = help: items from traits can only be used if the trait is implemented and in scope = note: the following trait defines an item `clone`, perhaps you need to implement it: diff --git a/src/test/ui/object-pointer-types.stderr b/src/test/ui/object-pointer-types.stderr index 0c7e4e991a51d..2df628ecf8e50 100644 --- a/src/test/ui/object-pointer-types.stderr +++ b/src/test/ui/object-pointer-types.stderr @@ -2,7 +2,7 @@ error[E0599]: no method named `owned` found for type `&dyn Foo` in the current s --> $DIR/object-pointer-types.rs:11:7 | LL | x.owned(); - | ^^^^^ + | ^^^^^ method not found in `&dyn Foo` | = help: items from traits can only be used if the trait is implemented and in scope = note: the following trait defines an item `owned`, perhaps you need to implement it: @@ -12,7 +12,7 @@ error[E0599]: no method named `owned` found for type `&mut dyn Foo` in the curre --> $DIR/object-pointer-types.rs:17:7 | LL | x.owned(); - | ^^^^^ + | ^^^^^ method not found in `&mut dyn Foo` | = help: items from traits can only be used if the trait is implemented and in scope = note: the following trait defines an item `owned`, perhaps you need to implement it: @@ -22,7 +22,7 @@ error[E0599]: no method named `managed` found for type `std::boxed::Box<(dyn Foo --> $DIR/object-pointer-types.rs:23:7 | LL | x.managed(); - | ^^^^^^^ + | ^^^^^^^ method not found in `std::boxed::Box<(dyn Foo + 'static)>` error: aborting due to 3 previous errors diff --git a/src/test/ui/rust-2018/trait-import-suggestions.stderr b/src/test/ui/rust-2018/trait-import-suggestions.stderr index a81181228dfda..19f758fd8da77 100644 --- a/src/test/ui/rust-2018/trait-import-suggestions.stderr +++ b/src/test/ui/rust-2018/trait-import-suggestions.stderr @@ -2,7 +2,7 @@ error[E0599]: no method named `foobar` found for type `u32` in the current scope --> $DIR/trait-import-suggestions.rs:22:11 | LL | x.foobar(); - | ^^^^^^ + | ^^^^^^ method not found in `u32` | = help: items from traits can only be used if the trait is in scope = note: the following trait is implemented but not in scope, perhaps add a `use` for it: @@ -12,7 +12,7 @@ error[E0599]: no method named `bar` found for type `u32` in the current scope --> $DIR/trait-import-suggestions.rs:28:7 | LL | x.bar(); - | ^^^ + | ^^^ method not found in `u32` | = help: items from traits can only be used if the trait is in scope help: the following trait is implemented but not in scope, perhaps add a `use` for it: @@ -24,7 +24,7 @@ error[E0599]: no method named `baz` found for type `u32` in the current scope --> $DIR/trait-import-suggestions.rs:29:7 | LL | x.baz(); - | ^^^ + | ^^^ method not found in `u32` error[E0599]: no function or associated item named `from_str` found for type `u32` in the current scope --> $DIR/trait-import-suggestions.rs:30:18 diff --git a/src/test/ui/self/point-at-arbitrary-self-type-method.stderr b/src/test/ui/self/point-at-arbitrary-self-type-method.stderr index 06dad7caa6735..dec5809f1539b 100644 --- a/src/test/ui/self/point-at-arbitrary-self-type-method.stderr +++ b/src/test/ui/self/point-at-arbitrary-self-type-method.stderr @@ -8,7 +8,7 @@ LL | fn foo(self: Box) {} | --- the method is available for `std::boxed::Box` here ... LL | A.foo(); - | ^^^ + | ^^^ method not found in `A` error: aborting due to previous error diff --git a/src/test/ui/self/point-at-arbitrary-self-type-trait-method.stderr b/src/test/ui/self/point-at-arbitrary-self-type-trait-method.stderr index 90cd3b8074580..e93c4da9dfc85 100644 --- a/src/test/ui/self/point-at-arbitrary-self-type-trait-method.stderr +++ b/src/test/ui/self/point-at-arbitrary-self-type-trait-method.stderr @@ -7,7 +7,7 @@ LL | struct A; | --------- method `foo` not found for this ... LL | A.foo() - | ^^^ + | ^^^ method not found in `A` | = help: items from traits can only be used if the trait is implemented and in scope = note: the following trait defines an item `foo`, perhaps you need to implement it: diff --git a/src/test/ui/shadowed/shadowed-trait-methods.stderr b/src/test/ui/shadowed/shadowed-trait-methods.stderr index e05da17983f83..190159ec7b88d 100644 --- a/src/test/ui/shadowed/shadowed-trait-methods.stderr +++ b/src/test/ui/shadowed/shadowed-trait-methods.stderr @@ -2,7 +2,7 @@ error[E0599]: no method named `f` found for type `()` in the current scope --> $DIR/shadowed-trait-methods.rs:13:8 | LL | ().f() - | ^ + | ^ method not found in `()` | = help: items from traits can only be used if the trait is in scope help: the following trait is implemented but not in scope, perhaps add a `use` for it: diff --git a/src/test/ui/specialization/defaultimpl/specialization-trait-not-implemented.stderr b/src/test/ui/specialization/defaultimpl/specialization-trait-not-implemented.stderr index c14fc04f631fc..bbfe4c3d59dcf 100644 --- a/src/test/ui/specialization/defaultimpl/specialization-trait-not-implemented.stderr +++ b/src/test/ui/specialization/defaultimpl/specialization-trait-not-implemented.stderr @@ -5,7 +5,7 @@ LL | struct MyStruct; | ---------------- method `foo_one` not found for this ... LL | println!("{}", MyStruct.foo_one()); - | ^^^^^^^ + | ^^^^^^^ method not found in `MyStruct` | = note: the method `foo_one` exists but the following trait bounds were not satisfied: `MyStruct : Foo` diff --git a/src/test/ui/suggestions/impl-trait-with-missing-trait-bounds-in-arg.stderr b/src/test/ui/suggestions/impl-trait-with-missing-trait-bounds-in-arg.stderr index 48c2503e8eb32..4aec72006eef0 100644 --- a/src/test/ui/suggestions/impl-trait-with-missing-trait-bounds-in-arg.stderr +++ b/src/test/ui/suggestions/impl-trait-with-missing-trait-bounds-in-arg.stderr @@ -2,7 +2,7 @@ error[E0599]: no method named `hello` found for type `impl Foo` in the current s --> $DIR/impl-trait-with-missing-trait-bounds-in-arg.rs:15:9 | LL | foo.hello(); - | ^^^^^ + | ^^^^^ method not found in `impl Foo` | = help: items from traits can only be used if the type parameter is bounded by the trait help: the following trait defines an item `hello`, perhaps you need to restrict type parameter `impl Foo` with it: diff --git a/src/test/ui/suggestions/issue-21673.stderr b/src/test/ui/suggestions/issue-21673.stderr index 6cf71c8b7c53b..f2496f696d698 100644 --- a/src/test/ui/suggestions/issue-21673.stderr +++ b/src/test/ui/suggestions/issue-21673.stderr @@ -2,7 +2,7 @@ error[E0599]: no method named `method` found for type `&T` in the current scope --> $DIR/issue-21673.rs:6:7 | LL | x.method() - | ^^^^^^ + | ^^^^^^ method not found in `&T` | = help: items from traits can only be used if the type parameter is bounded by the trait help: the following trait defines an item `method`, perhaps you need to restrict type parameter `T` with it: @@ -14,7 +14,7 @@ error[E0599]: no method named `method` found for type `T` in the current scope --> $DIR/issue-21673.rs:10:7 | LL | x.method() - | ^^^^^^ + | ^^^^^^ method not found in `T` | = help: items from traits can only be used if the type parameter is bounded by the trait help: the following trait defines an item `method`, perhaps you need to restrict type parameter `T` with it: diff --git a/src/test/ui/suggestions/suggest-methods.stderr b/src/test/ui/suggestions/suggest-methods.stderr index ad4a4deb5a886..4678410eb4859 100644 --- a/src/test/ui/suggestions/suggest-methods.stderr +++ b/src/test/ui/suggestions/suggest-methods.stderr @@ -23,7 +23,7 @@ error[E0599]: no method named `count_o` found for type `u32` in the current scop --> $DIR/suggest-methods.rs:28:19 | LL | let _ = 63u32.count_o(); - | ^^^^^^^ + | ^^^^^^^ method not found in `u32` error: aborting due to 4 previous errors diff --git a/src/test/ui/traits/trait-impl-1.stderr b/src/test/ui/traits/trait-impl-1.stderr index 71d5cc26bf141..0d61c3ed00d90 100644 --- a/src/test/ui/traits/trait-impl-1.stderr +++ b/src/test/ui/traits/trait-impl-1.stderr @@ -2,7 +2,7 @@ error[E0599]: no method named `foo` found for type `&i32` in the current scope --> $DIR/trait-impl-1.rs:15:7 | LL | x.foo(); - | ^^^ + | ^^^ method not found in `&i32` error: aborting due to previous error diff --git a/src/test/ui/traits/trait-item-privacy.stderr b/src/test/ui/traits/trait-item-privacy.stderr index 16ea7bdb0807d..39cc66d275c24 100644 --- a/src/test/ui/traits/trait-item-privacy.stderr +++ b/src/test/ui/traits/trait-item-privacy.stderr @@ -5,7 +5,7 @@ LL | struct S; | --------- method `a` not found for this ... LL | S.a(); - | ^ + | ^ method not found in `S` | = help: items from traits can only be used if the trait is implemented and in scope = note: the following trait defines an item `a`, perhaps you need to implement it: @@ -25,7 +25,7 @@ LL | fn b(&self) { } | the method is available for `std::rc::Rc` here ... LL | S.b(); - | ^ + | ^ method not found in `S` | = help: items from traits can only be used if the trait is in scope help: the following trait is implemented but not in scope, perhaps add a `use` for it: diff --git a/src/test/ui/trivial-bounds/trivial-bounds-leak.stderr b/src/test/ui/trivial-bounds/trivial-bounds-leak.stderr index f0f048159ec73..d172d5ecc4b70 100644 --- a/src/test/ui/trivial-bounds/trivial-bounds-leak.stderr +++ b/src/test/ui/trivial-bounds/trivial-bounds-leak.stderr @@ -12,7 +12,7 @@ error[E0599]: no method named `test` found for type `i32` in the current scope --> $DIR/trivial-bounds-leak.rs:24:10 | LL | 3i32.test(); - | ^^^^ + | ^^^^ method not found in `i32` | = help: items from traits can only be used if the trait is implemented and in scope = note: the following trait defines an item `test`, perhaps you need to implement it: diff --git a/src/test/ui/unboxed-closures/unboxed-closures-static-call-wrong-trait.stderr b/src/test/ui/unboxed-closures/unboxed-closures-static-call-wrong-trait.stderr index 2e1845888a2f7..18276d5710cf8 100644 --- a/src/test/ui/unboxed-closures/unboxed-closures-static-call-wrong-trait.stderr +++ b/src/test/ui/unboxed-closures/unboxed-closures-static-call-wrong-trait.stderr @@ -2,7 +2,7 @@ error[E0599]: no method named `call` found for type `[closure@$DIR/unboxed-closu --> $DIR/unboxed-closures-static-call-wrong-trait.rs:7:10 | LL | mut_.call((0, )); - | ^^^^ + | ^^^^ method not found in `[closure@$DIR/unboxed-closures-static-call-wrong-trait.rs:6:26: 6:31]` | = note: mut_ is a function, perhaps you wish to call it diff --git a/src/test/ui/underscore-imports/shadow.stderr b/src/test/ui/underscore-imports/shadow.stderr index 92adca2c70490..63262d0dc326d 100644 --- a/src/test/ui/underscore-imports/shadow.stderr +++ b/src/test/ui/underscore-imports/shadow.stderr @@ -2,7 +2,7 @@ error[E0599]: no method named `deref` found for type `&()` in the current scope --> $DIR/shadow.rs:19:11 | LL | x.deref(); - | ^^^^^ + | ^^^^^ method not found in `&()` | = help: items from traits can only be used if the trait is in scope = note: the following trait is implemented but not in scope, perhaps add a `use` for it: diff --git a/src/test/ui/union/union-derive-clone.stderr b/src/test/ui/union/union-derive-clone.stderr index 37a0093784048..4f4c779b12bb3 100644 --- a/src/test/ui/union/union-derive-clone.stderr +++ b/src/test/ui/union/union-derive-clone.stderr @@ -13,7 +13,7 @@ LL | union U4 { | ----------- method `clone` not found for this ... LL | let w = u.clone(); - | ^^^^^ + | ^^^^^ method not found in `U4` | = note: the method `clone` exists but the following trait bounds were not satisfied: `U4 : std::clone::Clone` diff --git a/src/test/ui/unique-object-noncopyable.stderr b/src/test/ui/unique-object-noncopyable.stderr index 407905f52e750..cd46878c19be4 100644 --- a/src/test/ui/unique-object-noncopyable.stderr +++ b/src/test/ui/unique-object-noncopyable.stderr @@ -2,7 +2,7 @@ error[E0599]: no method named `clone` found for type `std::boxed::Box` --> $DIR/unique-object-noncopyable.rs:24:16 | LL | let _z = y.clone(); - | ^^^^^ + | ^^^^^ method not found in `std::boxed::Box` | = note: the method `clone` exists but the following trait bounds were not satisfied: `std::boxed::Box : std::clone::Clone` diff --git a/src/test/ui/unique-pinned-nocopy.stderr b/src/test/ui/unique-pinned-nocopy.stderr index 0f6ba90afacf4..19ef2b21c2685 100644 --- a/src/test/ui/unique-pinned-nocopy.stderr +++ b/src/test/ui/unique-pinned-nocopy.stderr @@ -2,7 +2,7 @@ error[E0599]: no method named `clone` found for type `std::boxed::Box` in the --> $DIR/unique-pinned-nocopy.rs:12:16 | LL | let _j = i.clone(); - | ^^^^^ + | ^^^^^ method not found in `std::boxed::Box` | = note: the method `clone` exists but the following trait bounds were not satisfied: `std::boxed::Box : std::clone::Clone` From 4c62950d4fb98f71dae08d724c45e55835b80b51 Mon Sep 17 00:00:00 2001 From: Lukas Date: Mon, 9 Sep 2019 12:18:07 +0000 Subject: [PATCH 24/27] Fix typo in config.toml.example --- config.toml.example | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.toml.example b/config.toml.example index 30e2ee1b9babf..848147c2974c1 100644 --- a/config.toml.example +++ b/config.toml.example @@ -184,7 +184,7 @@ # default. #extended = false -# Installs chosen set of extended tools if enables. By default builds all. +# Installs chosen set of extended tools if enabled. By default builds all. # If chosen tool failed to build the installation fails. #tools = ["cargo", "rls", "clippy", "rustfmt", "analysis", "src"] From 63a5f399aef46f94a24e0d0a3b03eb7f66a33800 Mon Sep 17 00:00:00 2001 From: Caio Date: Mon, 9 Sep 2019 09:26:25 -0300 Subject: [PATCH 25/27] Resolve attributes in several places Arm, Field, FieldPat, GenericParam, Param, StructField and Variant --- src/librustc/hir/map/def_collector.rs | 58 ++++- src/librustc_resolve/build_reduced_graph.rs | 139 ++++++++---- src/librustc_resolve/lib.rs | 5 + src/librustc_resolve/macros.rs | 22 +- src/librustc_typeck/collect.rs | 6 +- src/libsyntax/ast.rs | 10 +- src/libsyntax/ext/base.rs | 140 ++++++++++++ src/libsyntax/ext/build.rs | 9 +- src/libsyntax/ext/expand.rs | 199 +++++++++++++++++- src/libsyntax/ext/placeholders.rs | 145 +++++++++++++ src/libsyntax/ext/proc_macro.rs | 8 + src/libsyntax/mut_visit.rs | 13 +- src/libsyntax/parse/diagnostics.rs | 9 +- src/libsyntax/parse/parser.rs | 9 +- src/libsyntax/parse/parser/expr.rs | 6 +- src/libsyntax/parse/parser/generics.rs | 7 +- src/libsyntax/parse/parser/item.rs | 3 + src/libsyntax/parse/parser/pat.rs | 1 + src/libsyntax/print/pprust/tests.rs | 1 + src/libsyntax_ext/deriving/generic/mod.rs | 1 + src/test/ui/attrs-resolution-errors.rs | 40 ++++ src/test/ui/attrs-resolution-errors.stderr | 32 +++ src/test/ui/attrs-resolution.rs | 37 ++++ .../cfg-generic-params.rs | 12 +- .../cfg-generic-params.stderr | 52 ++--- .../feature-gate-custom_attribute2.rs | 34 +-- .../feature-gate-custom_attribute2.stderr | 186 ++++++---------- src/test/ui/issues/issue-49934-errors.rs | 13 ++ src/test/ui/issues/issue-49934-errors.stderr | 26 +++ src/test/ui/issues/issue-49934.rs | 9 +- src/test/ui/issues/issue-49934.stderr | 26 +-- src/test/ui/proc-macro/proc-macro-gates2.rs | 4 +- .../ui/proc-macro/proc-macro-gates2.stderr | 11 +- .../param-attrs-builtin-attrs.rs | 16 +- .../param-attrs-builtin-attrs.stderr | 121 +++++------ .../proc-macro-cannot-be-used.rs | 50 ++--- .../proc-macro-cannot-be-used.stderr | 126 +++-------- 37 files changed, 1097 insertions(+), 489 deletions(-) create mode 100644 src/test/ui/attrs-resolution-errors.rs create mode 100644 src/test/ui/attrs-resolution-errors.stderr create mode 100644 src/test/ui/attrs-resolution.rs create mode 100644 src/test/ui/issues/issue-49934-errors.rs create mode 100644 src/test/ui/issues/issue-49934-errors.stderr diff --git a/src/librustc/hir/map/def_collector.rs b/src/librustc/hir/map/def_collector.rs index 17bcb1d085968..bffb4df836e3b 100644 --- a/src/librustc/hir/map/def_collector.rs +++ b/src/librustc/hir/map/def_collector.rs @@ -155,6 +155,9 @@ impl<'a> visit::Visitor<'a> for DefCollector<'a> { } fn visit_variant(&mut self, v: &'a Variant) { + if v.is_placeholder { + return self.visit_macro_invoc(v.id); + } let def = self.create_def(v.id, DefPathData::TypeNs(v.ident.as_interned_str()), v.span); @@ -168,16 +171,24 @@ impl<'a> visit::Visitor<'a> for DefCollector<'a> { fn visit_variant_data(&mut self, data: &'a VariantData) { for (index, field) in data.fields().iter().enumerate() { + if field.is_placeholder { + self.visit_macro_invoc(field.id); + continue; + } let name = field.ident.map(|ident| ident.name) .unwrap_or_else(|| sym::integer(index)); let def = self.create_def(field.id, DefPathData::ValueNs(name.as_interned_str()), field.span); - self.with_parent(def, |this| this.visit_struct_field(field)); + self.with_parent(def, |this| visit::walk_struct_field(this, field)); } } fn visit_generic_param(&mut self, param: &'a GenericParam) { + if param.is_placeholder { + self.visit_macro_invoc(param.id); + return; + } let name = param.ident.as_interned_str(); let def_path_data = match param.kind { GenericParamKind::Lifetime { .. } => DefPathData::LifetimeNs(name), @@ -294,4 +305,49 @@ impl<'a> visit::Visitor<'a> for DefCollector<'a> { } } } + + fn visit_arm(&mut self, arm: &'a Arm) { + if arm.is_placeholder { + self.visit_macro_invoc(arm.id) + } else { + visit::walk_arm(self, arm) + } + } + + fn visit_field(&mut self, f: &'a Field) { + if f.is_placeholder { + self.visit_macro_invoc(f.id) + } else { + visit::walk_field(self, f) + } + } + + fn visit_field_pattern(&mut self, fp: &'a FieldPat) { + if fp.is_placeholder { + self.visit_macro_invoc(fp.id) + } else { + visit::walk_field_pattern(self, fp) + } + } + + fn visit_param(&mut self, p: &'a Param) { + if p.is_placeholder { + self.visit_macro_invoc(p.id) + } else { + visit::walk_param(self, p) + } + } + + fn visit_struct_field(&mut self, sf: &'a StructField) { + if sf.is_placeholder { + self.visit_macro_invoc(sf.id) + } else { + let name = sf.ident.map(|ident| ident.name) + .unwrap_or_else(|| panic!("don't know the field number in this context")); + let def = self.create_def(sf.id, + DefPathData::ValueNs(name.as_interned_str()), + sf.span); + self.with_parent(def, |this| visit::walk_struct_field(this, sf)); + } + } } diff --git a/src/librustc_resolve/build_reduced_graph.rs b/src/librustc_resolve/build_reduced_graph.rs index 333509e18504d..11dcf5b4b0019 100644 --- a/src/librustc_resolve/build_reduced_graph.rs +++ b/src/librustc_resolve/build_reduced_graph.rs @@ -31,7 +31,7 @@ use syntax::ast::{Name, Ident}; use syntax::attr; use syntax::ast::{self, Block, ForeignItem, ForeignItemKind, Item, ItemKind, NodeId}; -use syntax::ast::{MetaItemKind, StmtKind, TraitItem, TraitItemKind, Variant}; +use syntax::ast::{MetaItemKind, StmtKind, TraitItem, TraitItemKind}; use syntax::ext::base::{MacroKind, SyntaxExtension}; use syntax::ext::expand::AstFragment; use syntax::ext::hygiene::ExpnId; @@ -580,7 +580,7 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> { } /// Constructs the reduced graph for one item. - fn build_reduced_graph_for_item(&mut self, item: &Item) { + fn build_reduced_graph_for_item(&mut self, item: &'b Item) { let parent_scope = &self.parent_scope; let parent = parent_scope.module; let expansion = parent_scope.expansion; @@ -716,12 +716,10 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> { self.r.define(parent, ident, TypeNS, (res, vis, sp, expansion)); } - ItemKind::Enum(ref enum_definition, _) => { - let module_kind = ModuleKind::Def( - DefKind::Enum, - self.r.definitions.local_def_id(item.id), - ident.name, - ); + ItemKind::Enum(_, _) => { + let def_id = self.r.definitions.local_def_id(item.id); + self.r.variant_vis.insert(def_id, vis); + let module_kind = ModuleKind::Def(DefKind::Enum, def_id, ident.name); let module = self.r.new_module(parent, module_kind, parent.normal_ancestor_id, @@ -729,10 +727,6 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> { item.span); self.r.define(parent, ident, TypeNS, (module, vis, sp, expansion)); self.parent_scope.module = module; - - for variant in &(*enum_definition).variants { - self.build_reduced_graph_for_variant(variant, vis); - } } ItemKind::TraitAlias(..) => { @@ -817,38 +811,6 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> { } } - // Constructs the reduced graph for one variant. Variants exist in the - // type and value namespaces. - fn build_reduced_graph_for_variant(&mut self, variant: &Variant, vis: ty::Visibility) { - let parent = self.parent_scope.module; - let expn_id = self.parent_scope.expansion; - let ident = variant.ident; - - // Define a name in the type namespace. - let def_id = self.r.definitions.local_def_id(variant.id); - let res = Res::Def(DefKind::Variant, def_id); - self.r.define(parent, ident, TypeNS, (res, vis, variant.span, expn_id)); - - // If the variant is marked as non_exhaustive then lower the visibility to within the - // crate. - let mut ctor_vis = vis; - let has_non_exhaustive = attr::contains_name(&variant.attrs, sym::non_exhaustive); - if has_non_exhaustive && vis == ty::Visibility::Public { - ctor_vis = ty::Visibility::Restricted(DefId::local(CRATE_DEF_INDEX)); - } - - // Define a constructor name in the value namespace. - // Braced variants, unlike structs, generate unusable names in - // value namespace, they are reserved for possible future use. - // It's ok to use the variant's id as a ctor id since an - // error will be reported on any use of such resolution anyway. - let ctor_node_id = variant.data.ctor_id().unwrap_or(variant.id); - let ctor_def_id = self.r.definitions.local_def_id(ctor_node_id); - let ctor_kind = CtorKind::from_ast(&variant.data); - let ctor_res = Res::Def(DefKind::Ctor(CtorOf::Variant, ctor_kind), ctor_def_id); - self.r.define(parent, ident, ValueNS, (ctor_res, ctor_vis, variant.span, expn_id)); - } - /// Constructs the reduced graph for one foreign item. fn build_reduced_graph_for_foreign_item(&mut self, item: &ForeignItem) { let (res, ns) = match item.node { @@ -1188,7 +1150,6 @@ impl<'a, 'b> Visitor<'b> for BuildReducedGraphVisitor<'a, 'b> { ItemKind::Mod(..) => self.contains_macro_use(&item.attrs), _ => false, }; - let orig_current_module = self.parent_scope.module; let orig_current_legacy_scope = self.parent_scope.legacy; self.build_reduced_graph_for_item(item); @@ -1271,4 +1232,92 @@ impl<'a, 'b> Visitor<'b> for BuildReducedGraphVisitor<'a, 'b> { } visit::walk_attribute(self, attr); } + + fn visit_arm(&mut self, arm: &'b ast::Arm) { + if arm.is_placeholder { + self.visit_invoc(arm.id); + } else { + visit::walk_arm(self, arm); + } + } + + fn visit_field(&mut self, f: &'b ast::Field) { + if f.is_placeholder { + self.visit_invoc(f.id); + } else { + visit::walk_field(self, f); + } + } + + fn visit_field_pattern(&mut self, fp: &'b ast::FieldPat) { + if fp.is_placeholder { + self.visit_invoc(fp.id); + } else { + visit::walk_field_pattern(self, fp); + } + } + + fn visit_generic_param(&mut self, param: &'b ast::GenericParam) { + if param.is_placeholder { + self.visit_invoc(param.id); + } else { + visit::walk_generic_param(self, param); + } + } + + fn visit_param(&mut self, p: &'b ast::Param) { + if p.is_placeholder { + self.visit_invoc(p.id); + } else { + visit::walk_param(self, p); + } + } + + fn visit_struct_field(&mut self, sf: &'b ast::StructField) { + if sf.is_placeholder { + self.visit_invoc(sf.id); + } else { + visit::walk_struct_field(self, sf); + } + } + + // Constructs the reduced graph for one variant. Variants exist in the + // type and value namespaces. + fn visit_variant(&mut self, variant: &'b ast::Variant) { + if variant.is_placeholder { + self.visit_invoc(variant.id); + return; + } + + let parent = self.parent_scope.module; + let vis = self.r.variant_vis[&parent.def_id().expect("enum without def-id")]; + let expn_id = self.parent_scope.expansion; + let ident = variant.ident; + + // Define a name in the type namespace. + let def_id = self.r.definitions.local_def_id(variant.id); + let res = Res::Def(DefKind::Variant, def_id); + self.r.define(parent, ident, TypeNS, (res, vis, variant.span, expn_id)); + + // If the variant is marked as non_exhaustive then lower the visibility to within the + // crate. + let mut ctor_vis = vis; + let has_non_exhaustive = attr::contains_name(&variant.attrs, sym::non_exhaustive); + if has_non_exhaustive && vis == ty::Visibility::Public { + ctor_vis = ty::Visibility::Restricted(DefId::local(CRATE_DEF_INDEX)); + } + + // Define a constructor name in the value namespace. + // Braced variants, unlike structs, generate unusable names in + // value namespace, they are reserved for possible future use. + // It's ok to use the variant's id as a ctor id since an + // error will be reported on any use of such resolution anyway. + let ctor_node_id = variant.data.ctor_id().unwrap_or(variant.id); + let ctor_def_id = self.r.definitions.local_def_id(ctor_node_id); + let ctor_kind = CtorKind::from_ast(&variant.data); + let ctor_res = Res::Def(DefKind::Ctor(CtorOf::Variant, ctor_kind), ctor_def_id); + self.r.define(parent, ident, ValueNS, (ctor_res, ctor_vis, variant.span, expn_id)); + + visit::walk_variant(self, variant); + } } diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index 6e131c04722a9..f97fcb0a035a2 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -952,6 +952,10 @@ pub struct Resolver<'a> { /// Features enabled for this crate. active_features: FxHashSet, + + /// Stores enum visibilities to properly build a reduced graph + /// when visiting the correspondent variants. + variant_vis: DefIdMap, } /// Nothing really interesting here; it just provides memory for the rest of the crate. @@ -1214,6 +1218,7 @@ impl<'a> Resolver<'a> { features.declared_lib_features.iter().map(|(feat, ..)| *feat) .chain(features.declared_lang_features.iter().map(|(feat, ..)| *feat)) .collect(), + variant_vis: Default::default() } } diff --git a/src/librustc_resolve/macros.rs b/src/librustc_resolve/macros.rs index 87439440463b3..bd8b5e13c6205 100644 --- a/src/librustc_resolve/macros.rs +++ b/src/librustc_resolve/macros.rs @@ -16,7 +16,7 @@ use syntax::attr::StabilityLevel; use syntax::edition::Edition; use syntax::ext::base::{self, InvocationRes, Indeterminate, SpecialDerives}; use syntax::ext::base::{MacroKind, SyntaxExtension}; -use syntax::ext::expand::{AstFragment, Invocation, InvocationKind}; +use syntax::ext::expand::{AstFragment, AstFragmentKind, Invocation, InvocationKind}; use syntax::ext::hygiene::{self, ExpnId, ExpnData, ExpnKind}; use syntax::ext::tt::macro_rules; use syntax::feature_gate::{emit_feature_err, is_builtin_attr_name}; @@ -225,6 +225,26 @@ impl<'a> base::Resolver for Resolver<'a> { self.definitions.add_parent_module_of_macro_def(invoc_id, normal_module_def_id); } + match invoc.fragment_kind { + AstFragmentKind::Arms + | AstFragmentKind::Fields + | AstFragmentKind::FieldPats + | AstFragmentKind::GenericParams + | AstFragmentKind::Params + | AstFragmentKind::StructFields + | AstFragmentKind::Variants => + { + if let Res::Def(..) = res { + self.session.span_err( + span, + "expected an inert attribute, found an attribute macro" + ); + return Ok(InvocationRes::Single(self.dummy_ext(kind))); + } + }, + _ => {} + } + Ok(InvocationRes::Single(ext)) } diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs index 312a598af02bf..d2e9203779cc8 100644 --- a/src/librustc_typeck/collect.rs +++ b/src/librustc_typeck/collect.rs @@ -519,15 +519,15 @@ fn convert_variant_ctor(tcx: TyCtxt<'_>, ctor_id: hir::HirId) { tcx.predicates_of(def_id); } -fn convert_enum_variant_types<'tcx>( - tcx: TyCtxt<'tcx>, +fn convert_enum_variant_types( + tcx: TyCtxt<'_>, def_id: DefId, variants: &[hir::Variant] ) { let def = tcx.adt_def(def_id); let repr_type = def.repr.discr_type(); let initial = repr_type.initial_discriminant(tcx); - let mut prev_discr = None::>; + let mut prev_discr = None::>; // fill the discriminant values and field types for variant in variants { diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index bfb2db9596363..bcbc0a19ce768 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -352,7 +352,7 @@ pub struct GenericParam { pub ident: Ident, pub attrs: ThinVec, pub bounds: GenericBounds, - + pub is_placeholder: bool, pub kind: GenericParamKind, } @@ -613,6 +613,7 @@ pub struct FieldPat { pub attrs: ThinVec, pub id: NodeId, pub span: Span, + pub is_placeholder: bool, } #[derive(Clone, PartialEq, RustcEncodable, RustcDecodable, Debug, Copy)] @@ -935,6 +936,7 @@ pub struct Arm { pub body: P, pub span: Span, pub id: NodeId, + pub is_placeholder: bool, } #[derive(Clone, RustcEncodable, RustcDecodable, Debug)] @@ -945,6 +947,7 @@ pub struct Field { pub is_shorthand: bool, pub attrs: ThinVec, pub id: NodeId, + pub is_placeholder: bool, } #[derive(Clone, PartialEq, RustcEncodable, RustcDecodable, Debug, Copy)] @@ -1798,6 +1801,7 @@ pub struct Param { pub pat: P, pub id: NodeId, pub span: Span, + pub is_placeholder: bool, } /// Alternative representation for `Arg`s describing `self` parameter of methods. @@ -1859,6 +1863,7 @@ impl Param { span, ty, id: DUMMY_NODE_ID, + is_placeholder: false }; match eself.node { SelfKind::Explicit(ty, mutbl) => param(mutbl, ty), @@ -2054,6 +2059,8 @@ pub struct Variant { pub disr_expr: Option, /// Span pub span: Span, + /// Is a macro placeholder + pub is_placeholder: bool, } /// Part of `use` item to the right of its prefix. @@ -2216,6 +2223,7 @@ pub struct StructField { pub id: NodeId, pub ty: P, pub attrs: Vec, + pub is_placeholder: bool, } /// Fields and constructor ids of enum variants and structs. diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs index c4569b3fba1be..7759a985d6134 100644 --- a/src/libsyntax/ext/base.rs +++ b/src/libsyntax/ext/base.rs @@ -35,6 +35,13 @@ pub enum Annotatable { ForeignItem(P), Stmt(P), Expr(P), + Arm(ast::Arm), + Field(ast::Field), + FieldPat(ast::FieldPat), + GenericParam(ast::GenericParam), + Param(ast::Param), + StructField(ast::StructField), + Variant(ast::Variant), } impl HasAttrs for Annotatable { @@ -46,6 +53,13 @@ impl HasAttrs for Annotatable { Annotatable::ForeignItem(ref foreign_item) => &foreign_item.attrs, Annotatable::Stmt(ref stmt) => stmt.attrs(), Annotatable::Expr(ref expr) => &expr.attrs, + Annotatable::Arm(ref arm) => &arm.attrs, + Annotatable::Field(ref field) => &field.attrs, + Annotatable::FieldPat(ref fp) => &fp.attrs, + Annotatable::GenericParam(ref gp) => &gp.attrs, + Annotatable::Param(ref p) => &p.attrs, + Annotatable::StructField(ref sf) => &sf.attrs, + Annotatable::Variant(ref v) => &v.attrs(), } } @@ -57,6 +71,13 @@ impl HasAttrs for Annotatable { Annotatable::ForeignItem(foreign_item) => foreign_item.visit_attrs(f), Annotatable::Stmt(stmt) => stmt.visit_attrs(f), Annotatable::Expr(expr) => expr.visit_attrs(f), + Annotatable::Arm(arm) => arm.visit_attrs(f), + Annotatable::Field(field) => field.visit_attrs(f), + Annotatable::FieldPat(fp) => fp.visit_attrs(f), + Annotatable::GenericParam(gp) => gp.visit_attrs(f), + Annotatable::Param(p) => p.visit_attrs(f), + Annotatable::StructField(sf) => sf.visit_attrs(f), + Annotatable::Variant(v) => v.visit_attrs(f), } } } @@ -70,6 +91,13 @@ impl Annotatable { Annotatable::ForeignItem(ref foreign_item) => foreign_item.span, Annotatable::Stmt(ref stmt) => stmt.span, Annotatable::Expr(ref expr) => expr.span, + Annotatable::Arm(ref arm) => arm.span, + Annotatable::Field(ref field) => field.span, + Annotatable::FieldPat(ref fp) => fp.pat.span, + Annotatable::GenericParam(ref gp) => gp.ident.span, + Annotatable::Param(ref p) => p.span, + Annotatable::StructField(ref sf) => sf.span, + Annotatable::Variant(ref v) => v.span, } } @@ -81,6 +109,13 @@ impl Annotatable { Annotatable::ForeignItem(foreign_item) => visitor.visit_foreign_item(foreign_item), Annotatable::Stmt(stmt) => visitor.visit_stmt(stmt), Annotatable::Expr(expr) => visitor.visit_expr(expr), + Annotatable::Arm(arm) => visitor.visit_arm(arm), + Annotatable::Field(field) => visitor.visit_field(field), + Annotatable::FieldPat(fp) => visitor.visit_field_pattern(fp), + Annotatable::GenericParam(gp) => visitor.visit_generic_param(gp), + Annotatable::Param(p) => visitor.visit_param(p), + Annotatable::StructField(sf) =>visitor.visit_struct_field(sf), + Annotatable::Variant(v) => visitor.visit_variant(v), } } @@ -136,6 +171,55 @@ impl Annotatable { } } + pub fn expect_arm(self) -> ast::Arm { + match self { + Annotatable::Arm(arm) => arm, + _ => panic!("expected match arm") + } + } + + pub fn expect_field(self) -> ast::Field { + match self { + Annotatable::Field(field) => field, + _ => panic!("expected field") + } + } + + pub fn expect_field_pattern(self) -> ast::FieldPat { + match self { + Annotatable::FieldPat(fp) => fp, + _ => panic!("expected field pattern") + } + } + + pub fn expect_generic_param(self) -> ast::GenericParam { + match self { + Annotatable::GenericParam(gp) => gp, + _ => panic!("expected generic parameter") + } + } + + pub fn expect_param(self) -> ast::Param { + match self { + Annotatable::Param(param) => param, + _ => panic!("expected parameter") + } + } + + pub fn expect_struct_field(self) -> ast::StructField { + match self { + Annotatable::StructField(sf) => sf, + _ => panic!("expected struct field") + } + } + + pub fn expect_variant(self) -> ast::Variant { + match self { + Annotatable::Variant(v) => v, + _ => panic!("expected variant") + } + } + pub fn derive_allowed(&self) -> bool { match *self { Annotatable::Item(ref item) => match item.node { @@ -325,6 +409,34 @@ pub trait MacResult { fn make_ty(self: Box) -> Option> { None } + + fn make_arms(self: Box) -> Option> { + None + } + + fn make_fields(self: Box) -> Option> { + None + } + + fn make_field_patterns(self: Box) -> Option> { + None + } + + fn make_generic_params(self: Box) -> Option> { + None + } + + fn make_params(self: Box) -> Option> { + None + } + + fn make_struct_fields(self: Box) -> Option> { + None + } + + fn make_variants(self: Box) -> Option> { + None + } } macro_rules! make_MacEager { @@ -498,6 +610,34 @@ impl MacResult for DummyResult { fn make_ty(self: Box) -> Option> { Some(DummyResult::raw_ty(self.span, self.is_error)) } + + fn make_arms(self: Box) -> Option> { + Some(SmallVec::new()) + } + + fn make_fields(self: Box) -> Option> { + Some(SmallVec::new()) + } + + fn make_field_patterns(self: Box) -> Option> { + Some(SmallVec::new()) + } + + fn make_generic_params(self: Box) -> Option> { + Some(SmallVec::new()) + } + + fn make_params(self: Box) -> Option> { + Some(SmallVec::new()) + } + + fn make_struct_fields(self: Box) -> Option> { + Some(SmallVec::new()) + } + + fn make_variants(self: Box) -> Option> { + Some(SmallVec::new()) + } } /// A syntax extension kind. diff --git a/src/libsyntax/ext/build.rs b/src/libsyntax/ext/build.rs index dc6cbfcf6ad5c..06a55316f31d6 100644 --- a/src/libsyntax/ext/build.rs +++ b/src/libsyntax/ext/build.rs @@ -166,7 +166,8 @@ impl<'a> ExtCtxt<'a> { bounds, kind: ast::GenericParamKind::Type { default, - } + }, + is_placeholder: false } } @@ -207,6 +208,7 @@ impl<'a> ExtCtxt<'a> { attrs: attrs.into(), bounds, kind: ast::GenericParamKind::Lifetime, + is_placeholder: false } } @@ -404,6 +406,7 @@ impl<'a> ExtCtxt<'a> { is_shorthand: false, attrs: ThinVec::new(), id: ast::DUMMY_NODE_ID, + is_placeholder: false, } } pub fn expr_struct( @@ -614,6 +617,7 @@ impl<'a> ExtCtxt<'a> { body: expr, span, id: ast::DUMMY_NODE_ID, + is_placeholder: false, } } @@ -701,6 +705,7 @@ impl<'a> ExtCtxt<'a> { pat: arg_pat, span, ty, + is_placeholder: false, } } @@ -774,6 +779,7 @@ impl<'a> ExtCtxt<'a> { vis: respan(span.shrink_to_lo(), ast::VisibilityKind::Inherited), attrs: Vec::new(), id: ast::DUMMY_NODE_ID, + is_placeholder: false, } }).collect(); @@ -790,6 +796,7 @@ impl<'a> ExtCtxt<'a> { id: ast::DUMMY_NODE_ID, ident, span, + is_placeholder: false, } } diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index 4fd0c367288bf..87e2d721f89a0 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -141,7 +141,40 @@ ast_fragments! { "impl item"; many fn flat_map_impl_item; fn visit_impl_item; fn make_impl_items; } ForeignItems(SmallVec<[ast::ForeignItem; 1]>) { - "foreign item"; many fn flat_map_foreign_item; fn visit_foreign_item; fn make_foreign_items; + "foreign item"; + many fn flat_map_foreign_item; + fn visit_foreign_item; + fn make_foreign_items; + } + Arms(SmallVec<[ast::Arm; 1]>) { + "match arm"; many fn flat_map_arm; fn visit_arm; fn make_arms; + } + Fields(SmallVec<[ast::Field; 1]>) { + "field expression"; many fn flat_map_field; fn visit_field; fn make_fields; + } + FieldPats(SmallVec<[ast::FieldPat; 1]>) { + "field pattern"; + many fn flat_map_field_pattern; + fn visit_field_pattern; + fn make_field_patterns; + } + GenericParams(SmallVec<[ast::GenericParam; 1]>) { + "generic parameter"; + many fn flat_map_generic_param; + fn visit_generic_param; + fn make_generic_params; + } + Params(SmallVec<[ast::Param; 1]>) { + "function parameter"; many fn flat_map_param; fn visit_param; fn make_params; + } + StructFields(SmallVec<[ast::StructField; 1]>) { + "field"; + many fn flat_map_struct_field; + fn visit_struct_field; + fn make_struct_fields; + } + Variants(SmallVec<[ast::Variant; 1]>) { + "variant"; many fn flat_map_variant; fn visit_variant; fn make_variants; } } @@ -154,6 +187,21 @@ impl AstFragmentKind { -> AstFragment { let mut items = items.into_iter(); match self { + AstFragmentKind::Arms => + AstFragment::Arms(items.map(Annotatable::expect_arm).collect()), + AstFragmentKind::Fields => + AstFragment::Fields(items.map(Annotatable::expect_field).collect()), + AstFragmentKind::FieldPats => + AstFragment::FieldPats(items.map(Annotatable::expect_field_pattern).collect()), + AstFragmentKind::GenericParams => + AstFragment::GenericParams(items.map(Annotatable::expect_generic_param).collect()), + AstFragmentKind::Params => + AstFragment::Params(items.map(Annotatable::expect_param).collect()), + AstFragmentKind::StructFields => AstFragment::StructFields( + items.map(Annotatable::expect_struct_field).collect() + ), + AstFragmentKind::Variants => + AstFragment::Variants(items.map(Annotatable::expect_variant).collect()), AstFragmentKind::Items => AstFragment::Items(items.map(Annotatable::expect_item).collect()), AstFragmentKind::ImplItems => @@ -177,7 +225,7 @@ impl AstFragmentKind { pub struct Invocation { pub kind: InvocationKind, - fragment_kind: AstFragmentKind, + pub fragment_kind: AstFragmentKind, pub expansion_data: ExpansionData, } @@ -482,6 +530,27 @@ impl<'a, 'b> MacroExpander<'a, 'b> { Annotatable::Expr(mut expr) => { Annotatable::Expr({ cfg.visit_expr(&mut expr); expr }) } + Annotatable::Arm(arm) => { + Annotatable::Arm(cfg.flat_map_arm(arm).pop().unwrap()) + } + Annotatable::Field(field) => { + Annotatable::Field(cfg.flat_map_field(field).pop().unwrap()) + } + Annotatable::FieldPat(fp) => { + Annotatable::FieldPat(cfg.flat_map_field_pattern(fp).pop().unwrap()) + } + Annotatable::GenericParam(param) => { + Annotatable::GenericParam(cfg.flat_map_generic_param(param).pop().unwrap()) + } + Annotatable::Param(param) => { + Annotatable::Param(cfg.flat_map_param(param).pop().unwrap()) + } + Annotatable::StructField(sf) => { + Annotatable::StructField(cfg.flat_map_struct_field(sf).pop().unwrap()) + } + Annotatable::Variant(v) => { + Annotatable::Variant(cfg.flat_map_variant(v).pop().unwrap()) + } } } @@ -547,6 +616,14 @@ impl<'a, 'b> MacroExpander<'a, 'b> { Annotatable::ForeignItem(item) => token::NtForeignItem(item.into_inner()), Annotatable::Stmt(stmt) => token::NtStmt(stmt.into_inner()), Annotatable::Expr(expr) => token::NtExpr(expr), + Annotatable::Arm(..) + | Annotatable::Field(..) + | Annotatable::FieldPat(..) + | Annotatable::GenericParam(..) + | Annotatable::Param(..) + | Annotatable::StructField(..) + | Annotatable::Variant(..) + => panic!("unexpected annotatable"), })), DUMMY_SP).into(); let input = self.extract_proc_macro_attr_input(attr.tokens, span); let tok_result = expander.expand(self.cx, span, input, item_tok); @@ -625,6 +702,14 @@ impl<'a, 'b> MacroExpander<'a, 'b> { Annotatable::Expr(_) if self.cx.ecfg.proc_macro_hygiene() => return, Annotatable::Stmt(_) => ("statements", sym::proc_macro_hygiene), Annotatable::Expr(_) => ("expressions", sym::proc_macro_hygiene), + Annotatable::Arm(..) + | Annotatable::Field(..) + | Annotatable::FieldPat(..) + | Annotatable::GenericParam(..) + | Annotatable::Param(..) + | Annotatable::StructField(..) + | Annotatable::Variant(..) + => panic!("unexpected annotatable"), }; emit_feature_err( self.cx.parse_sess, @@ -681,6 +766,14 @@ impl<'a, 'b> MacroExpander<'a, 'b> { AstFragmentKind::TraitItems => return, AstFragmentKind::ImplItems => return, AstFragmentKind::ForeignItems => return, + AstFragmentKind::Arms + | AstFragmentKind::Fields + | AstFragmentKind::FieldPats + | AstFragmentKind::GenericParams + | AstFragmentKind::Params + | AstFragmentKind::StructFields + | AstFragmentKind::Variants + => panic!("unexpected AST fragment kind"), }; if self.cx.ecfg.proc_macro_hygiene() { return @@ -771,6 +864,14 @@ impl<'a> Parser<'a> { }, AstFragmentKind::Ty => AstFragment::Ty(self.parse_ty()?), AstFragmentKind::Pat => AstFragment::Pat(self.parse_pat(None)?), + AstFragmentKind::Arms + | AstFragmentKind::Fields + | AstFragmentKind::FieldPats + | AstFragmentKind::GenericParams + | AstFragmentKind::Params + | AstFragmentKind::StructFields + | AstFragmentKind::Variants + => panic!("unexpected AST fragment kind"), }) } @@ -972,6 +1073,84 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> { }); } + fn flat_map_arm(&mut self, arm: ast::Arm) -> SmallVec<[ast::Arm; 1]> { + let mut arm = configure!(self, arm); + + let (attr, traits, after_derive) = self.classify_item(&mut arm); + if attr.is_some() || !traits.is_empty() { + return self.collect_attr(attr, traits, Annotatable::Arm(arm), + AstFragmentKind::Arms, after_derive) + .make_arms(); + } + + noop_flat_map_arm(arm, self) + } + + fn flat_map_field(&mut self, field: ast::Field) -> SmallVec<[ast::Field; 1]> { + let mut field = configure!(self, field); + + let (attr, traits, after_derive) = self.classify_item(&mut field); + if attr.is_some() || !traits.is_empty() { + return self.collect_attr(attr, traits, Annotatable::Field(field), + AstFragmentKind::Fields, after_derive) + .make_fields(); + } + + noop_flat_map_field(field, self) + } + + fn flat_map_field_pattern(&mut self, fp: ast::FieldPat) -> SmallVec<[ast::FieldPat; 1]> { + let mut fp = configure!(self, fp); + + let (attr, traits, after_derive) = self.classify_item(&mut fp); + if attr.is_some() || !traits.is_empty() { + return self.collect_attr(attr, traits, Annotatable::FieldPat(fp), + AstFragmentKind::FieldPats, after_derive) + .make_field_patterns(); + } + + noop_flat_map_field_pattern(fp, self) + } + + fn flat_map_param(&mut self, p: ast::Param) -> SmallVec<[ast::Param; 1]> { + let mut p = configure!(self, p); + + let (attr, traits, after_derive) = self.classify_item(&mut p); + if attr.is_some() || !traits.is_empty() { + return self.collect_attr(attr, traits, Annotatable::Param(p), + AstFragmentKind::Params, after_derive) + .make_params(); + } + + noop_flat_map_param(p, self) + } + + fn flat_map_struct_field(&mut self, sf: ast::StructField) -> SmallVec<[ast::StructField; 1]> { + let mut sf = configure!(self, sf); + + let (attr, traits, after_derive) = self.classify_item(&mut sf); + if attr.is_some() || !traits.is_empty() { + return self.collect_attr(attr, traits, Annotatable::StructField(sf), + AstFragmentKind::StructFields, after_derive) + .make_struct_fields(); + } + + noop_flat_map_struct_field(sf, self) + } + + fn flat_map_variant(&mut self, variant: ast::Variant) -> SmallVec<[ast::Variant; 1]> { + let mut variant = configure!(self, variant); + + let (attr, traits, after_derive) = self.classify_item(&mut variant); + if attr.is_some() || !traits.is_empty() { + return self.collect_attr(attr, traits, Annotatable::Variant(variant), + AstFragmentKind::Variants, after_derive) + .make_variants(); + } + + noop_flat_map_variant(variant, self) + } + fn filter_map_expr(&mut self, expr: P) -> Option> { let expr = configure!(self, expr); expr.filter_map(|mut expr| { @@ -1227,12 +1406,20 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> { } } - fn flat_map_generic_param( - &mut self, - param: ast::GenericParam + fn flat_map_generic_param( + &mut self, + param: ast::GenericParam ) -> SmallVec<[ast::GenericParam; 1]> { - let param = configure!(self, param); + let mut param = configure!(self, param); + + let (attr, traits, after_derive) = self.classify_item(&mut param); + if attr.is_some() || !traits.is_empty() { + return self.collect_attr(attr, traits, Annotatable::GenericParam(param), + AstFragmentKind::GenericParams, after_derive) + .make_generic_params(); + } + noop_flat_map_generic_param(param, self) } diff --git a/src/libsyntax/ext/placeholders.rs b/src/libsyntax/ext/placeholders.rs index d800cfedcfb4b..52a0f95bce7ff 100644 --- a/src/libsyntax/ext/placeholders.rs +++ b/src/libsyntax/ext/placeholders.rs @@ -32,6 +32,16 @@ pub fn placeholder(kind: AstFragmentKind, id: ast::NodeId) -> AstFragment { attrs: ThinVec::new(), node: ast::ExprKind::Mac(mac_placeholder()), }); + let ty = P(ast::Ty { + id, + node: ast::TyKind::Mac(mac_placeholder()), + span, + }); + let pat = P(ast::Pat { + id, + node: ast::PatKind::Mac(mac_placeholder()), + span, + }); match kind { AstFragmentKind::Expr => AstFragment::Expr(expr_placeholder()), @@ -67,6 +77,81 @@ pub fn placeholder(kind: AstFragmentKind, id: ast::NodeId) -> AstFragment { let mac = P((mac_placeholder(), ast::MacStmtStyle::Braces, ThinVec::new())); ast::Stmt { id, span, node: ast::StmtKind::Mac(mac) } }]), + AstFragmentKind::Arms => AstFragment::Arms(smallvec![ + ast::Arm { + attrs: Default::default(), + body: expr_placeholder(), + guard: None, + id, + pat, + span, + is_placeholder: true, + } + ]), + AstFragmentKind::Fields => AstFragment::Fields(smallvec![ + ast::Field { + attrs: Default::default(), + expr: expr_placeholder(), + id, + ident, + is_shorthand: false, + span, + is_placeholder: true, + } + ]), + AstFragmentKind::FieldPats => AstFragment::FieldPats(smallvec![ + ast::FieldPat { + attrs: Default::default(), + id, + ident, + is_shorthand: false, + pat, + span, + is_placeholder: true, + } + ]), + AstFragmentKind::GenericParams => AstFragment::GenericParams(smallvec![{ + ast::GenericParam { + attrs: Default::default(), + bounds: Default::default(), + id, + ident, + is_placeholder: true, + kind: ast::GenericParamKind::Lifetime, + } + }]), + AstFragmentKind::Params => AstFragment::Params(smallvec![ + ast::Param { + attrs: Default::default(), + id, + pat, + span, + ty, + is_placeholder: true, + } + ]), + AstFragmentKind::StructFields => AstFragment::StructFields(smallvec![ + ast::StructField { + attrs: Default::default(), + id, + ident: None, + span, + ty, + vis, + is_placeholder: true, + } + ]), + AstFragmentKind::Variants => AstFragment::Variants(smallvec![ + ast::Variant { + attrs: Default::default(), + data: ast::VariantData::Struct(Default::default(), false), + disr_expr: None, + id, + ident, + span, + is_placeholder: true, + } + ]) } } @@ -105,6 +190,66 @@ impl<'a, 'b> PlaceholderExpander<'a, 'b> { } impl<'a, 'b> MutVisitor for PlaceholderExpander<'a, 'b> { + fn flat_map_arm(&mut self, arm: ast::Arm) -> SmallVec<[ast::Arm; 1]> { + if arm.is_placeholder { + self.remove(arm.id).make_arms() + } else { + noop_flat_map_arm(arm, self) + } + } + + fn flat_map_field(&mut self, field: ast::Field) -> SmallVec<[ast::Field; 1]> { + if field.is_placeholder { + self.remove(field.id).make_fields() + } else { + noop_flat_map_field(field, self) + } + } + + fn flat_map_field_pattern(&mut self, fp: ast::FieldPat) -> SmallVec<[ast::FieldPat; 1]> { + if fp.is_placeholder { + self.remove(fp.id).make_field_patterns() + } else { + noop_flat_map_field_pattern(fp, self) + } + } + + fn flat_map_generic_param( + &mut self, + param: ast::GenericParam + ) -> SmallVec<[ast::GenericParam; 1]> + { + if param.is_placeholder { + self.remove(param.id).make_generic_params() + } else { + noop_flat_map_generic_param(param, self) + } + } + + fn flat_map_param(&mut self, p: ast::Param) -> SmallVec<[ast::Param; 1]> { + if p.is_placeholder { + self.remove(p.id).make_params() + } else { + noop_flat_map_param(p, self) + } + } + + fn flat_map_struct_field(&mut self, sf: ast::StructField) -> SmallVec<[ast::StructField; 1]> { + if sf.is_placeholder { + self.remove(sf.id).make_struct_fields() + } else { + noop_flat_map_struct_field(sf, self) + } + } + + fn flat_map_variant(&mut self, variant: ast::Variant) -> SmallVec<[ast::Variant; 1]> { + if variant.is_placeholder { + self.remove(variant.id).make_variants() + } else { + noop_flat_map_variant(variant, self) + } + } + fn flat_map_item(&mut self, item: P) -> SmallVec<[P; 1]> { match item.node { ast::ItemKind::Mac(_) => return self.remove(item.id).make_items(), diff --git a/src/libsyntax/ext/proc_macro.rs b/src/libsyntax/ext/proc_macro.rs index 4a44c9a9f1f31..47b17ced8163e 100644 --- a/src/libsyntax/ext/proc_macro.rs +++ b/src/libsyntax/ext/proc_macro.rs @@ -88,6 +88,14 @@ impl MultiItemModifier for ProcMacroDerive { item: Annotatable) -> Vec { let item = match item { + Annotatable::Arm(..) | + Annotatable::Field(..) | + Annotatable::FieldPat(..) | + Annotatable::GenericParam(..) | + Annotatable::Param(..) | + Annotatable::StructField(..) | + Annotatable::Variant(..) + => panic!("unexpected annotatable"), Annotatable::Item(item) => item, Annotatable::ImplItem(_) | Annotatable::TraitItem(_) | diff --git a/src/libsyntax/mut_visit.rs b/src/libsyntax/mut_visit.rs index 1c35688666836..5a37222ee5590 100644 --- a/src/libsyntax/mut_visit.rs +++ b/src/libsyntax/mut_visit.rs @@ -370,6 +370,7 @@ pub fn noop_flat_map_field_pattern( attrs, id, ident, + is_placeholder: _, is_shorthand: _, pat, span, @@ -403,7 +404,7 @@ pub fn noop_visit_use_tree(use_tree: &mut UseTree, vis: &mut T) { } pub fn noop_flat_map_arm(mut arm: Arm, vis: &mut T) -> SmallVec<[Arm; 1]> { - let Arm { attrs, pat, guard, body, span, id } = &mut arm; + let Arm { attrs, pat, guard, body, span, id, is_placeholder: _ } = &mut arm; visit_attrs(attrs, vis); vis.visit_id(id); vis.visit_pat(pat); @@ -477,7 +478,7 @@ pub fn noop_visit_foreign_mod(foreign_mod: &mut ForeignMod, vis: pub fn noop_flat_map_variant(mut variant: Variant, vis: &mut T) -> SmallVec<[Variant; 1]> { - let Variant { ident, attrs, id, data, disr_expr, span } = &mut variant; + let Variant { ident, attrs, id, data, disr_expr, span, is_placeholder: _ } = &mut variant; vis.visit_ident(ident); visit_attrs(attrs, vis); vis.visit_id(id); @@ -585,7 +586,7 @@ pub fn noop_visit_meta_item(mi: &mut MetaItem, vis: &mut T) { } pub fn noop_flat_map_param(mut param: Param, vis: &mut T) -> SmallVec<[Param; 1]> { - let Param { attrs, id, pat, span, ty } = &mut param; + let Param { attrs, id, pat, span, ty, is_placeholder: _ } = &mut param; vis.visit_id(id); visit_thin_attrs(attrs, vis); vis.visit_pat(pat); @@ -736,7 +737,7 @@ pub fn noop_flat_map_generic_param( vis: &mut T ) -> SmallVec<[GenericParam; 1]> { - let GenericParam { id, ident, attrs, bounds, kind } = &mut param; + let GenericParam { id, ident, attrs, bounds, kind, is_placeholder: _ } = &mut param; vis.visit_id(id); vis.visit_ident(ident); visit_thin_attrs(attrs, vis); @@ -828,7 +829,7 @@ pub fn noop_visit_poly_trait_ref(p: &mut PolyTraitRef, vis: &mut pub fn noop_flat_map_struct_field(mut sf: StructField, visitor: &mut T) -> SmallVec<[StructField; 1]> { - let StructField { span, ident, vis, id, ty, attrs } = &mut sf; + let StructField { span, ident, vis, id, ty, attrs, is_placeholder: _ } = &mut sf; visitor.visit_span(span); visit_opt(ident, |ident| visitor.visit_ident(ident)); visitor.visit_vis(vis); @@ -839,7 +840,7 @@ pub fn noop_flat_map_struct_field(mut sf: StructField, visitor: & } pub fn noop_flat_map_field(mut f: Field, vis: &mut T) -> SmallVec<[Field; 1]> { - let Field { ident, expr, span, is_shorthand: _, attrs, id } = &mut f; + let Field { ident, expr, span, is_shorthand: _, attrs, id, is_placeholder: _ } = &mut f; vis.visit_ident(ident); vis.visit_expr(expr); vis.visit_id(id); diff --git a/src/libsyntax/parse/diagnostics.rs b/src/libsyntax/parse/diagnostics.rs index 3120d0e35173d..b74f2492c351f 100644 --- a/src/libsyntax/parse/diagnostics.rs +++ b/src/libsyntax/parse/diagnostics.rs @@ -29,7 +29,14 @@ crate fn dummy_arg(ident: Ident) -> Param { span: ident.span, id: ast::DUMMY_NODE_ID }; - Param { attrs: ThinVec::default(), id: ast::DUMMY_NODE_ID, pat, span: ident.span, ty: P(ty) } + Param { + attrs: ThinVec::default(), + id: ast::DUMMY_NODE_ID, + pat, + span: ident.span, + ty: P(ty), + is_placeholder: false, + } } pub enum Error { diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index fcaf5065dac78..fcebfa2996233 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -1040,7 +1040,14 @@ impl<'a> Parser<'a> { let span = lo.to(self.token.span); - Ok(Param { attrs: attrs.into(), id: DUMMY_NODE_ID, pat, span, ty }) + Ok(Param { + attrs: attrs.into(), + id: ast::DUMMY_NODE_ID, + is_placeholder: false, + pat, + span, + ty, + }) } /// Parses mutability (`mut` or nothing). diff --git a/src/libsyntax/parse/parser/expr.rs b/src/libsyntax/parse/parser/expr.rs index 4dbb5ff75eb21..31b28443abbc3 100644 --- a/src/libsyntax/parse/parser/expr.rs +++ b/src/libsyntax/parse/parser/expr.rs @@ -1193,7 +1193,8 @@ impl<'a> Parser<'a> { ty: t, pat, span, - id: DUMMY_NODE_ID + id: DUMMY_NODE_ID, + is_placeholder: false, }) } @@ -1455,6 +1456,7 @@ impl<'a> Parser<'a> { body: expr, span: lo.to(hi), id: DUMMY_NODE_ID, + is_placeholder: false, }) } @@ -1611,6 +1613,7 @@ impl<'a> Parser<'a> { is_shorthand: false, attrs: ThinVec::new(), id: DUMMY_NODE_ID, + is_placeholder: false, }); } } @@ -1697,6 +1700,7 @@ impl<'a> Parser<'a> { is_shorthand, attrs: attrs.into(), id: DUMMY_NODE_ID, + is_placeholder: false, }) } diff --git a/src/libsyntax/parse/parser/generics.rs b/src/libsyntax/parse/parser/generics.rs index 54f24f8ef2b21..3e6118ad86f47 100644 --- a/src/libsyntax/parse/parser/generics.rs +++ b/src/libsyntax/parse/parser/generics.rs @@ -49,7 +49,8 @@ impl<'a> Parser<'a> { bounds, kind: GenericParamKind::Type { default, - } + }, + is_placeholder: false }) } @@ -66,7 +67,8 @@ impl<'a> Parser<'a> { bounds: Vec::new(), kind: GenericParamKind::Const { ty, - } + }, + is_placeholder: false }) } @@ -90,6 +92,7 @@ impl<'a> Parser<'a> { attrs: attrs.into(), bounds, kind: ast::GenericParamKind::Lifetime, + is_placeholder: false }); } else if self.check_keyword(kw::Const) { // Parse const parameter. diff --git a/src/libsyntax/parse/parser/item.rs b/src/libsyntax/parse/parser/item.rs index be7fc48fdaf66..baae6155f3478 100644 --- a/src/libsyntax/parse/parser/item.rs +++ b/src/libsyntax/parse/parser/item.rs @@ -1575,6 +1575,7 @@ impl<'a> Parser<'a> { data: struct_def, disr_expr, span: vlo.to(self.prev_span), + is_placeholder: false, }; variants.push(vr); @@ -1730,6 +1731,7 @@ impl<'a> Parser<'a> { id: DUMMY_NODE_ID, ty, attrs, + is_placeholder: false, }) }).map(|(r, _)| r) } @@ -1821,6 +1823,7 @@ impl<'a> Parser<'a> { id: DUMMY_NODE_ID, ty, attrs, + is_placeholder: false, }) } diff --git a/src/libsyntax/parse/parser/pat.rs b/src/libsyntax/parse/parser/pat.rs index 49f8d58c6a762..08ee3a6bd86d4 100644 --- a/src/libsyntax/parse/parser/pat.rs +++ b/src/libsyntax/parse/parser/pat.rs @@ -882,6 +882,7 @@ impl<'a> Parser<'a> { attrs: attrs.into(), id: ast::DUMMY_NODE_ID, span: lo.to(hi), + is_placeholder: false, }) } diff --git a/src/libsyntax/print/pprust/tests.rs b/src/libsyntax/print/pprust/tests.rs index afd1726adf36b..05d78cdd87ec6 100644 --- a/src/libsyntax/print/pprust/tests.rs +++ b/src/libsyntax/print/pprust/tests.rs @@ -61,6 +61,7 @@ fn test_variant_to_string() { data: ast::VariantData::Unit(ast::DUMMY_NODE_ID), disr_expr: None, span: syntax_pos::DUMMY_SP, + is_placeholder: false, }; let varstr = variant_to_string(&var); diff --git a/src/libsyntax_ext/deriving/generic/mod.rs b/src/libsyntax_ext/deriving/generic/mod.rs index 893d89f06a168..c53fa7dc706e7 100644 --- a/src/libsyntax_ext/deriving/generic/mod.rs +++ b/src/libsyntax_ext/deriving/generic/mod.rs @@ -1620,6 +1620,7 @@ impl<'a> TraitDef<'a> { id: ast::DUMMY_NODE_ID, span: pat.span.with_ctxt(self.span.ctxt()), pat, + is_placeholder: false } }) .collect(); diff --git a/src/test/ui/attrs-resolution-errors.rs b/src/test/ui/attrs-resolution-errors.rs new file mode 100644 index 0000000000000..a38b3cfa6665e --- /dev/null +++ b/src/test/ui/attrs-resolution-errors.rs @@ -0,0 +1,40 @@ +enum FooEnum { + #[test] + //~^ ERROR expected an inert attribute, found an attribute macro + Bar(i32), +} + +struct FooStruct { + #[test] + //~^ ERROR expected an inert attribute, found an attribute macro + bar: i32, +} + +fn main() { + let foo_enum_bar = FooEnum::Bar(1); + match foo_enum_bar { + FooEnum::Bar(x) => {}, + _ => {} + } + + let foo_struct = FooStruct { bar: 1 }; + match foo_struct { + FooStruct { + #[test] bar + //~^ ERROR expected an inert attribute, found an attribute macro + } => {} + } + + match 1 { + 0 => {} + #[test] + //~^ ERROR expected an inert attribute, found an attribute macro + _ => {} + } + + let _another_foo_strunct = FooStruct { + #[test] + //~^ ERROR expected an inert attribute, found an attribute macro + bar: 1, + }; +} diff --git a/src/test/ui/attrs-resolution-errors.stderr b/src/test/ui/attrs-resolution-errors.stderr new file mode 100644 index 0000000000000..31f2a74edb333 --- /dev/null +++ b/src/test/ui/attrs-resolution-errors.stderr @@ -0,0 +1,32 @@ +error: expected an inert attribute, found an attribute macro + --> $DIR/attrs-resolution-errors.rs:2:5 + | +LL | #[test] + | ^^^^^^^ + +error: expected an inert attribute, found an attribute macro + --> $DIR/attrs-resolution-errors.rs:8:5 + | +LL | #[test] + | ^^^^^^^ + +error: expected an inert attribute, found an attribute macro + --> $DIR/attrs-resolution-errors.rs:23:13 + | +LL | #[test] bar + | ^^^^^^^ + +error: expected an inert attribute, found an attribute macro + --> $DIR/attrs-resolution-errors.rs:30:9 + | +LL | #[test] + | ^^^^^^^ + +error: expected an inert attribute, found an attribute macro + --> $DIR/attrs-resolution-errors.rs:36:9 + | +LL | #[test] + | ^^^^^^^ + +error: aborting due to 5 previous errors + diff --git a/src/test/ui/attrs-resolution.rs b/src/test/ui/attrs-resolution.rs new file mode 100644 index 0000000000000..6809773237d2c --- /dev/null +++ b/src/test/ui/attrs-resolution.rs @@ -0,0 +1,37 @@ +// check-pass + +enum FooEnum { + #[rustfmt::skip] + Bar(i32), +} + +struct FooStruct { + #[rustfmt::skip] + bar: i32, +} + +fn main() { + let foo_enum_bar = FooEnum::Bar(1); + match foo_enum_bar { + FooEnum::Bar(x) => {} + _ => {} + } + + let foo_struct = FooStruct { bar: 1 }; + match foo_struct { + FooStruct { + #[rustfmt::skip] bar + } => {} + } + + match 1 { + 0 => {} + #[rustfmt::skip] + _ => {} + } + + let _another_foo_strunct = FooStruct { + #[rustfmt::skip] + bar: 1, + }; +} diff --git a/src/test/ui/conditional-compilation/cfg-generic-params.rs b/src/test/ui/conditional-compilation/cfg-generic-params.rs index d80d3ea7b7fe9..faf01957c7e4f 100644 --- a/src/test/ui/conditional-compilation/cfg-generic-params.rs +++ b/src/test/ui/conditional-compilation/cfg-generic-params.rs @@ -16,21 +16,23 @@ struct WhereBad where for<#[cfg(no)] 'a, #[cfg(yes)] T> u8: Copy; //~^ ERROR only lifetime parameters can be used in this context fn f_lt_no<#[cfg_attr(no, unknown)] 'a>() {} // OK -fn f_lt_yes<#[cfg_attr(yes, unknown)] 'a>() {} //~ ERROR attribute `unknown` is currently unknown +fn f_lt_yes<#[cfg_attr(yes, unknown)] 'a>() {} +//~^ ERROR cannot find attribute macro `unknown` in this scope fn f_ty_no<#[cfg_attr(no, unknown)] T>() {} // OK -fn f_ty_yes<#[cfg_attr(yes, unknown)] T>() {} //~ ERROR attribute `unknown` is currently unknown +fn f_ty_yes<#[cfg_attr(yes, unknown)] T>() {} +//~^ ERROR cannot find attribute macro `unknown` in this scope type FnNo = for<#[cfg_attr(no, unknown)] 'a> fn(); // OK type FnYes = for<#[cfg_attr(yes, unknown)] 'a> fn(); -//~^ ERROR attribute `unknown` is currently unknown +//~^ ERROR cannot find attribute macro `unknown` in this scope type PolyNo = dyn for<#[cfg_attr(no, unknown)] 'a> Copy; // OK type PolyYes = dyn for<#[cfg_attr(yes, unknown)] 'a> Copy; -//~^ ERROR attribute `unknown` is currently unknown +//~^ ERROR cannot find attribute macro `unknown` in this scope struct WhereNo where for<#[cfg_attr(no, unknown)] 'a> u8: Copy; // OK struct WhereYes where for<#[cfg_attr(yes, unknown)] 'a> u8: Copy; -//~^ ERROR attribute `unknown` is currently unknown +//~^ ERROR cannot find attribute macro `unknown` in this scope fn main() { f_lt::<'static>(); diff --git a/src/test/ui/conditional-compilation/cfg-generic-params.stderr b/src/test/ui/conditional-compilation/cfg-generic-params.stderr index 1f9731fcfbefb..f6e5732916b91 100644 --- a/src/test/ui/conditional-compilation/cfg-generic-params.stderr +++ b/src/test/ui/conditional-compilation/cfg-generic-params.stderr @@ -16,51 +16,35 @@ error: only lifetime parameters can be used in this context LL | struct WhereBad where for<#[cfg(no)] 'a, #[cfg(yes)] T> u8: Copy; | ^ -error[E0658]: the attribute `unknown` is currently unknown to the compiler and may have meaning added to it in the future - --> $DIR/cfg-generic-params.rs:19:29 - | -LL | fn f_lt_yes<#[cfg_attr(yes, unknown)] 'a>() {} - | ^^^^^^^ +error: cannot find attribute macro `unknown` in this scope + --> $DIR/cfg-generic-params.rs:34:43 | - = note: for more information, see https://github.com/rust-lang/rust/issues/29642 - = help: add `#![feature(custom_attribute)]` to the crate attributes to enable +LL | struct WhereYes where for<#[cfg_attr(yes, unknown)] 'a> u8: Copy; + | ^^^^^^^ -error[E0658]: the attribute `unknown` is currently unknown to the compiler and may have meaning added to it in the future - --> $DIR/cfg-generic-params.rs:21:29 +error: cannot find attribute macro `unknown` in this scope + --> $DIR/cfg-generic-params.rs:30:40 | -LL | fn f_ty_yes<#[cfg_attr(yes, unknown)] T>() {} - | ^^^^^^^ - | - = note: for more information, see https://github.com/rust-lang/rust/issues/29642 - = help: add `#![feature(custom_attribute)]` to the crate attributes to enable +LL | type PolyYes = dyn for<#[cfg_attr(yes, unknown)] 'a> Copy; + | ^^^^^^^ -error[E0658]: the attribute `unknown` is currently unknown to the compiler and may have meaning added to it in the future - --> $DIR/cfg-generic-params.rs:24:34 +error: cannot find attribute macro `unknown` in this scope + --> $DIR/cfg-generic-params.rs:26:34 | LL | type FnYes = for<#[cfg_attr(yes, unknown)] 'a> fn(); | ^^^^^^^ - | - = note: for more information, see https://github.com/rust-lang/rust/issues/29642 - = help: add `#![feature(custom_attribute)]` to the crate attributes to enable -error[E0658]: the attribute `unknown` is currently unknown to the compiler and may have meaning added to it in the future - --> $DIR/cfg-generic-params.rs:28:40 +error: cannot find attribute macro `unknown` in this scope + --> $DIR/cfg-generic-params.rs:22:29 | -LL | type PolyYes = dyn for<#[cfg_attr(yes, unknown)] 'a> Copy; - | ^^^^^^^ - | - = note: for more information, see https://github.com/rust-lang/rust/issues/29642 - = help: add `#![feature(custom_attribute)]` to the crate attributes to enable +LL | fn f_ty_yes<#[cfg_attr(yes, unknown)] T>() {} + | ^^^^^^^ -error[E0658]: the attribute `unknown` is currently unknown to the compiler and may have meaning added to it in the future - --> $DIR/cfg-generic-params.rs:32:43 - | -LL | struct WhereYes where for<#[cfg_attr(yes, unknown)] 'a> u8: Copy; - | ^^^^^^^ +error: cannot find attribute macro `unknown` in this scope + --> $DIR/cfg-generic-params.rs:19:29 | - = note: for more information, see https://github.com/rust-lang/rust/issues/29642 - = help: add `#![feature(custom_attribute)]` to the crate attributes to enable +LL | fn f_lt_yes<#[cfg_attr(yes, unknown)] 'a>() {} + | ^^^^^^^ error: aborting due to 8 previous errors -For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/feature-gates/feature-gate-custom_attribute2.rs b/src/test/ui/feature-gates/feature-gate-custom_attribute2.rs index 8fe11cb02a021..51b5bf5387b5f 100644 --- a/src/test/ui/feature-gates/feature-gate-custom_attribute2.rs +++ b/src/test/ui/feature-gates/feature-gate-custom_attribute2.rs @@ -4,54 +4,54 @@ // gate-test-custom_attribute struct StLt<#[lt_struct] 'a>(&'a u32); -//~^ ERROR the attribute `lt_struct` is currently unknown to the compiler +//~^ ERROR cannot find attribute macro `lt_struct` in this scope struct StTy<#[ty_struct] I>(I); -//~^ ERROR the attribute `ty_struct` is currently unknown to the compiler +//~^ ERROR cannot find attribute macro `ty_struct` in this scope enum EnLt<#[lt_enum] 'b> { A(&'b u32), B } -//~^ ERROR the attribute `lt_enum` is currently unknown to the compiler +//~^ ERROR cannot find attribute macro `lt_enum` in this scope enum EnTy<#[ty_enum] J> { A(J), B } -//~^ ERROR the attribute `ty_enum` is currently unknown to the compiler +//~^ ERROR cannot find attribute macro `ty_enum` in this scope trait TrLt<#[lt_trait] 'c> { fn foo(&self, _: &'c [u32]) -> &'c u32; } -//~^ ERROR the attribute `lt_trait` is currently unknown to the compiler +//~^ ERROR cannot find attribute macro `lt_trait` in this scope trait TrTy<#[ty_trait] K> { fn foo(&self, _: K); } -//~^ ERROR the attribute `ty_trait` is currently unknown to the compiler +//~^ ERROR cannot find attribute macro `ty_trait` in this scope type TyLt<#[lt_type] 'd> = &'d u32; -//~^ ERROR the attribute `lt_type` is currently unknown to the compiler +//~^ ERROR cannot find attribute macro `lt_type` in this scope type TyTy<#[ty_type] L> = (L, ); -//~^ ERROR the attribute `ty_type` is currently unknown to the compiler +//~^ ERROR cannot find attribute macro `ty_type` in this scope impl<#[lt_inherent] 'e> StLt<'e> { } -//~^ ERROR the attribute `lt_inherent` is currently unknown to the compiler +//~^ ERROR cannot find attribute macro `lt_inherent` in this scope impl<#[ty_inherent] M> StTy { } -//~^ ERROR the attribute `ty_inherent` is currently unknown to the compiler +//~^ ERROR cannot find attribute macro `ty_inherent` in this scope impl<#[lt_impl_for] 'f> TrLt<'f> for StLt<'f> { - //~^ ERROR the attribute `lt_impl_for` is currently unknown to the compiler + //~^ ERROR cannot find attribute macro `lt_impl_for` in this scope fn foo(&self, _: &'f [u32]) -> &'f u32 { loop { } } } impl<#[ty_impl_for] N> TrTy for StTy { - //~^ ERROR the attribute `ty_impl_for` is currently unknown to the compiler + //~^ ERROR cannot find attribute macro `ty_impl_for` in this scope fn foo(&self, _: N) { } } fn f_lt<#[lt_fn] 'g>(_: &'g [u32]) -> &'g u32 { loop { } } -//~^ ERROR the attribute `lt_fn` is currently unknown to the compiler +//~^ ERROR cannot find attribute macro `lt_fn` in this scope fn f_ty<#[ty_fn] O>(_: O) { } -//~^ ERROR the attribute `ty_fn` is currently unknown to the compiler +//~^ ERROR cannot find attribute macro `ty_fn` in this scope impl StTy { fn m_lt<#[lt_meth] 'h>(_: &'h [u32]) -> &'h u32 { loop { } } - //~^ ERROR the attribute `lt_meth` is currently unknown to the compiler + //~^ ERROR cannot find attribute macro `lt_meth` in this scope fn m_ty<#[ty_meth] P>(_: P) { } - //~^ ERROR the attribute `ty_meth` is currently unknown to the compiler + //~^ ERROR cannot find attribute macro `ty_meth` in this scope } fn hof_lt(_: Q) where Q: for <#[lt_hof] 'i> Fn(&'i [u32]) -> &'i u32 - //~^ ERROR the attribute `lt_hof` is currently unknown to the compiler + //~^ ERROR cannot find attribute macro `lt_hof` in this scope { } diff --git a/src/test/ui/feature-gates/feature-gate-custom_attribute2.stderr b/src/test/ui/feature-gates/feature-gate-custom_attribute2.stderr index 15e0c41b90637..9250616127f3d 100644 --- a/src/test/ui/feature-gates/feature-gate-custom_attribute2.stderr +++ b/src/test/ui/feature-gates/feature-gate-custom_attribute2.stderr @@ -1,156 +1,104 @@ -error[E0658]: the attribute `lt_struct` is currently unknown to the compiler and may have meaning added to it in the future - --> $DIR/feature-gate-custom_attribute2.rs:6:13 +error: cannot find attribute macro `lt_hof` in this scope + --> $DIR/feature-gate-custom_attribute2.rs:53:21 | -LL | struct StLt<#[lt_struct] 'a>(&'a u32); - | ^^^^^^^^^^^^ - | - = note: for more information, see https://github.com/rust-lang/rust/issues/29642 - = help: add `#![feature(custom_attribute)]` to the crate attributes to enable +LL | where Q: for <#[lt_hof] 'i> Fn(&'i [u32]) -> &'i u32 + | ^^^^^^ -error[E0658]: the attribute `ty_struct` is currently unknown to the compiler and may have meaning added to it in the future - --> $DIR/feature-gate-custom_attribute2.rs:8:13 +error: cannot find attribute macro `ty_meth` in this scope + --> $DIR/feature-gate-custom_attribute2.rs:48:15 | -LL | struct StTy<#[ty_struct] I>(I); - | ^^^^^^^^^^^^ - | - = note: for more information, see https://github.com/rust-lang/rust/issues/29642 - = help: add `#![feature(custom_attribute)]` to the crate attributes to enable +LL | fn m_ty<#[ty_meth] P>(_: P) { } + | ^^^^^^^ -error[E0658]: the attribute `lt_enum` is currently unknown to the compiler and may have meaning added to it in the future - --> $DIR/feature-gate-custom_attribute2.rs:11:11 +error: cannot find attribute macro `lt_meth` in this scope + --> $DIR/feature-gate-custom_attribute2.rs:46:15 | -LL | enum EnLt<#[lt_enum] 'b> { A(&'b u32), B } - | ^^^^^^^^^^ - | - = note: for more information, see https://github.com/rust-lang/rust/issues/29642 - = help: add `#![feature(custom_attribute)]` to the crate attributes to enable +LL | fn m_lt<#[lt_meth] 'h>(_: &'h [u32]) -> &'h u32 { loop { } } + | ^^^^^^^ -error[E0658]: the attribute `ty_enum` is currently unknown to the compiler and may have meaning added to it in the future - --> $DIR/feature-gate-custom_attribute2.rs:13:11 - | -LL | enum EnTy<#[ty_enum] J> { A(J), B } - | ^^^^^^^^^^ +error: cannot find attribute macro `ty_fn` in this scope + --> $DIR/feature-gate-custom_attribute2.rs:42:11 | - = note: for more information, see https://github.com/rust-lang/rust/issues/29642 - = help: add `#![feature(custom_attribute)]` to the crate attributes to enable +LL | fn f_ty<#[ty_fn] O>(_: O) { } + | ^^^^^ -error[E0658]: the attribute `lt_trait` is currently unknown to the compiler and may have meaning added to it in the future - --> $DIR/feature-gate-custom_attribute2.rs:16:12 +error: cannot find attribute macro `lt_fn` in this scope + --> $DIR/feature-gate-custom_attribute2.rs:40:11 | -LL | trait TrLt<#[lt_trait] 'c> { fn foo(&self, _: &'c [u32]) -> &'c u32; } - | ^^^^^^^^^^^ - | - = note: for more information, see https://github.com/rust-lang/rust/issues/29642 - = help: add `#![feature(custom_attribute)]` to the crate attributes to enable +LL | fn f_lt<#[lt_fn] 'g>(_: &'g [u32]) -> &'g u32 { loop { } } + | ^^^^^ -error[E0658]: the attribute `ty_trait` is currently unknown to the compiler and may have meaning added to it in the future - --> $DIR/feature-gate-custom_attribute2.rs:18:12 - | -LL | trait TrTy<#[ty_trait] K> { fn foo(&self, _: K); } - | ^^^^^^^^^^^ +error: cannot find attribute macro `ty_impl_for` in this scope + --> $DIR/feature-gate-custom_attribute2.rs:35:8 | - = note: for more information, see https://github.com/rust-lang/rust/issues/29642 - = help: add `#![feature(custom_attribute)]` to the crate attributes to enable +LL | impl<#[ty_impl_for] N> TrTy for StTy { + | ^^^^^^^^^^^ -error[E0658]: the attribute `lt_type` is currently unknown to the compiler and may have meaning added to it in the future - --> $DIR/feature-gate-custom_attribute2.rs:21:11 - | -LL | type TyLt<#[lt_type] 'd> = &'d u32; - | ^^^^^^^^^^ +error: cannot find attribute macro `lt_impl_for` in this scope + --> $DIR/feature-gate-custom_attribute2.rs:31:8 | - = note: for more information, see https://github.com/rust-lang/rust/issues/29642 - = help: add `#![feature(custom_attribute)]` to the crate attributes to enable +LL | impl<#[lt_impl_for] 'f> TrLt<'f> for StLt<'f> { + | ^^^^^^^^^^^ -error[E0658]: the attribute `ty_type` is currently unknown to the compiler and may have meaning added to it in the future - --> $DIR/feature-gate-custom_attribute2.rs:23:11 - | -LL | type TyTy<#[ty_type] L> = (L, ); - | ^^^^^^^^^^ +error: cannot find attribute macro `ty_inherent` in this scope + --> $DIR/feature-gate-custom_attribute2.rs:28:8 | - = note: for more information, see https://github.com/rust-lang/rust/issues/29642 - = help: add `#![feature(custom_attribute)]` to the crate attributes to enable +LL | impl<#[ty_inherent] M> StTy { } + | ^^^^^^^^^^^ -error[E0658]: the attribute `lt_inherent` is currently unknown to the compiler and may have meaning added to it in the future - --> $DIR/feature-gate-custom_attribute2.rs:26:6 +error: cannot find attribute macro `lt_inherent` in this scope + --> $DIR/feature-gate-custom_attribute2.rs:26:8 | LL | impl<#[lt_inherent] 'e> StLt<'e> { } - | ^^^^^^^^^^^^^^ - | - = note: for more information, see https://github.com/rust-lang/rust/issues/29642 - = help: add `#![feature(custom_attribute)]` to the crate attributes to enable + | ^^^^^^^^^^^ -error[E0658]: the attribute `ty_inherent` is currently unknown to the compiler and may have meaning added to it in the future - --> $DIR/feature-gate-custom_attribute2.rs:28:6 +error: cannot find attribute macro `ty_type` in this scope + --> $DIR/feature-gate-custom_attribute2.rs:23:13 | -LL | impl<#[ty_inherent] M> StTy { } - | ^^^^^^^^^^^^^^ - | - = note: for more information, see https://github.com/rust-lang/rust/issues/29642 - = help: add `#![feature(custom_attribute)]` to the crate attributes to enable +LL | type TyTy<#[ty_type] L> = (L, ); + | ^^^^^^^ -error[E0658]: the attribute `lt_impl_for` is currently unknown to the compiler and may have meaning added to it in the future - --> $DIR/feature-gate-custom_attribute2.rs:31:6 +error: cannot find attribute macro `lt_type` in this scope + --> $DIR/feature-gate-custom_attribute2.rs:21:13 | -LL | impl<#[lt_impl_for] 'f> TrLt<'f> for StLt<'f> { - | ^^^^^^^^^^^^^^ - | - = note: for more information, see https://github.com/rust-lang/rust/issues/29642 - = help: add `#![feature(custom_attribute)]` to the crate attributes to enable +LL | type TyLt<#[lt_type] 'd> = &'d u32; + | ^^^^^^^ -error[E0658]: the attribute `ty_impl_for` is currently unknown to the compiler and may have meaning added to it in the future - --> $DIR/feature-gate-custom_attribute2.rs:35:6 +error: cannot find attribute macro `ty_trait` in this scope + --> $DIR/feature-gate-custom_attribute2.rs:18:14 | -LL | impl<#[ty_impl_for] N> TrTy for StTy { - | ^^^^^^^^^^^^^^ - | - = note: for more information, see https://github.com/rust-lang/rust/issues/29642 - = help: add `#![feature(custom_attribute)]` to the crate attributes to enable +LL | trait TrTy<#[ty_trait] K> { fn foo(&self, _: K); } + | ^^^^^^^^ -error[E0658]: the attribute `lt_fn` is currently unknown to the compiler and may have meaning added to it in the future - --> $DIR/feature-gate-custom_attribute2.rs:40:9 +error: cannot find attribute macro `lt_trait` in this scope + --> $DIR/feature-gate-custom_attribute2.rs:16:14 | -LL | fn f_lt<#[lt_fn] 'g>(_: &'g [u32]) -> &'g u32 { loop { } } - | ^^^^^^^^ - | - = note: for more information, see https://github.com/rust-lang/rust/issues/29642 - = help: add `#![feature(custom_attribute)]` to the crate attributes to enable +LL | trait TrLt<#[lt_trait] 'c> { fn foo(&self, _: &'c [u32]) -> &'c u32; } + | ^^^^^^^^ -error[E0658]: the attribute `ty_fn` is currently unknown to the compiler and may have meaning added to it in the future - --> $DIR/feature-gate-custom_attribute2.rs:42:9 +error: cannot find attribute macro `ty_enum` in this scope + --> $DIR/feature-gate-custom_attribute2.rs:13:13 | -LL | fn f_ty<#[ty_fn] O>(_: O) { } - | ^^^^^^^^ - | - = note: for more information, see https://github.com/rust-lang/rust/issues/29642 - = help: add `#![feature(custom_attribute)]` to the crate attributes to enable +LL | enum EnTy<#[ty_enum] J> { A(J), B } + | ^^^^^^^ -error[E0658]: the attribute `lt_meth` is currently unknown to the compiler and may have meaning added to it in the future - --> $DIR/feature-gate-custom_attribute2.rs:46:13 +error: cannot find attribute macro `lt_enum` in this scope + --> $DIR/feature-gate-custom_attribute2.rs:11:13 | -LL | fn m_lt<#[lt_meth] 'h>(_: &'h [u32]) -> &'h u32 { loop { } } - | ^^^^^^^^^^ - | - = note: for more information, see https://github.com/rust-lang/rust/issues/29642 - = help: add `#![feature(custom_attribute)]` to the crate attributes to enable +LL | enum EnLt<#[lt_enum] 'b> { A(&'b u32), B } + | ^^^^^^^ -error[E0658]: the attribute `ty_meth` is currently unknown to the compiler and may have meaning added to it in the future - --> $DIR/feature-gate-custom_attribute2.rs:48:13 +error: cannot find attribute macro `ty_struct` in this scope + --> $DIR/feature-gate-custom_attribute2.rs:8:15 | -LL | fn m_ty<#[ty_meth] P>(_: P) { } - | ^^^^^^^^^^ - | - = note: for more information, see https://github.com/rust-lang/rust/issues/29642 - = help: add `#![feature(custom_attribute)]` to the crate attributes to enable +LL | struct StTy<#[ty_struct] I>(I); + | ^^^^^^^^^ -error[E0658]: the attribute `lt_hof` is currently unknown to the compiler and may have meaning added to it in the future - --> $DIR/feature-gate-custom_attribute2.rs:53:19 +error: cannot find attribute macro `lt_struct` in this scope + --> $DIR/feature-gate-custom_attribute2.rs:6:15 | -LL | where Q: for <#[lt_hof] 'i> Fn(&'i [u32]) -> &'i u32 - | ^^^^^^^^^ - | - = note: for more information, see https://github.com/rust-lang/rust/issues/29642 - = help: add `#![feature(custom_attribute)]` to the crate attributes to enable +LL | struct StLt<#[lt_struct] 'a>(&'a u32); + | ^^^^^^^^^ error: aborting due to 17 previous errors -For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/issues/issue-49934-errors.rs b/src/test/ui/issues/issue-49934-errors.rs new file mode 100644 index 0000000000000..58f64d137b9f9 --- /dev/null +++ b/src/test/ui/issues/issue-49934-errors.rs @@ -0,0 +1,13 @@ +fn foo<#[derive(Debug)] T>() { +//~^ ERROR `derive` may only be applied to structs, enums and unions +//~| ERROR expected an inert attribute, found an attribute macro + match 0 { + #[derive(Debug)] + //~^ ERROR `derive` may only be applied to structs, enums and unions + //~| ERROR expected an inert attribute, found an attribute macro + _ => (), + } +} + +fn main() { +} diff --git a/src/test/ui/issues/issue-49934-errors.stderr b/src/test/ui/issues/issue-49934-errors.stderr new file mode 100644 index 0000000000000..fce1f65881266 --- /dev/null +++ b/src/test/ui/issues/issue-49934-errors.stderr @@ -0,0 +1,26 @@ +error: `derive` may only be applied to structs, enums and unions + --> $DIR/issue-49934-errors.rs:1:8 + | +LL | fn foo<#[derive(Debug)] T>() { + | ^^^^^^^^^^^^^^^^ + +error: expected an inert attribute, found an attribute macro + --> $DIR/issue-49934-errors.rs:1:17 + | +LL | fn foo<#[derive(Debug)] T>() { + | ^^^^^ + +error: `derive` may only be applied to structs, enums and unions + --> $DIR/issue-49934-errors.rs:5:9 + | +LL | #[derive(Debug)] + | ^^^^^^^^^^^^^^^^ + +error: expected an inert attribute, found an attribute macro + --> $DIR/issue-49934-errors.rs:5:18 + | +LL | #[derive(Debug)] + | ^^^^^ + +error: aborting due to 4 previous errors + diff --git a/src/test/ui/issues/issue-49934.rs b/src/test/ui/issues/issue-49934.rs index e75381afae9ae..262f4931d42d4 100644 --- a/src/test/ui/issues/issue-49934.rs +++ b/src/test/ui/issues/issue-49934.rs @@ -1,15 +1,8 @@ -// build-pass (FIXME(62277): could be check-pass?) +// check-pass #![feature(stmt_expr_attributes)] #![warn(unused_attributes)] //~ NOTE lint level defined here -fn foo<#[derive(Debug)] T>() { //~ WARN unused attribute - match 0 { - #[derive(Debug)] //~ WARN unused attribute - _ => (), - } -} - fn main() { // fold_stmt (Item) #[allow(dead_code)] diff --git a/src/test/ui/issues/issue-49934.stderr b/src/test/ui/issues/issue-49934.stderr index 6ca751a47c47d..dbec379e3c55b 100644 --- a/src/test/ui/issues/issue-49934.stderr +++ b/src/test/ui/issues/issue-49934.stderr @@ -1,5 +1,5 @@ warning: `#[derive]` does nothing on macro invocations - --> $DIR/issue-49934.rs:20:5 + --> $DIR/issue-49934.rs:13:5 | LL | #[derive(Debug)] | ^^^^^^^^^^^^^^^^ @@ -7,10 +7,10 @@ LL | #[derive(Debug)] = note: this may become a hard error in a future release warning: unused attribute - --> $DIR/issue-49934.rs:6:8 + --> $DIR/issue-49934.rs:19:5 | -LL | fn foo<#[derive(Debug)] T>() { - | ^^^^^^^^^^^^^^^^ +LL | #[derive(Debug)] + | ^^^^^^^^^^^^^^^^ | note: lint level defined here --> $DIR/issue-49934.rs:4:9 @@ -19,31 +19,19 @@ LL | #![warn(unused_attributes)] | ^^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-49934.rs:8:9 - | -LL | #[derive(Debug)] - | ^^^^^^^^^^^^^^^^ - -warning: unused attribute - --> $DIR/issue-49934.rs:26:5 - | -LL | #[derive(Debug)] - | ^^^^^^^^^^^^^^^^ - -warning: unused attribute - --> $DIR/issue-49934.rs:30:5 + --> $DIR/issue-49934.rs:23:5 | LL | #[derive(Debug)] | ^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-49934.rs:34:13 + --> $DIR/issue-49934.rs:27:13 | LL | let _ = #[derive(Debug)] "Hello, world!"; | ^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-49934.rs:39:9 + --> $DIR/issue-49934.rs:32:9 | LL | #[derive(Debug)] | ^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/proc-macro/proc-macro-gates2.rs b/src/test/ui/proc-macro/proc-macro-gates2.rs index 35d7fc8042a3d..2fd5efd71f041 100644 --- a/src/test/ui/proc-macro/proc-macro-gates2.rs +++ b/src/test/ui/proc-macro/proc-macro-gates2.rs @@ -10,11 +10,11 @@ extern crate test_macros; // should either require a feature gate or not be allowed on stable. fn _test6<#[empty_attr] T>() {} -//~^ ERROR: unknown to the compiler +//~^ ERROR: expected an inert attribute, found an attribute macro fn _test7() { match 1 { - #[empty_attr] //~ ERROR: unknown to the compiler + #[empty_attr] //~ ERROR: expected an inert attribute, found an attribute macro 0 => {} _ => {} } diff --git a/src/test/ui/proc-macro/proc-macro-gates2.stderr b/src/test/ui/proc-macro/proc-macro-gates2.stderr index a7f6f8bfb13d6..fd271da61553a 100644 --- a/src/test/ui/proc-macro/proc-macro-gates2.stderr +++ b/src/test/ui/proc-macro/proc-macro-gates2.stderr @@ -1,21 +1,14 @@ -error[E0658]: the attribute `empty_attr` is currently unknown to the compiler and may have meaning added to it in the future +error: expected an inert attribute, found an attribute macro --> $DIR/proc-macro-gates2.rs:12:11 | LL | fn _test6<#[empty_attr] T>() {} | ^^^^^^^^^^^^^ - | - = note: for more information, see https://github.com/rust-lang/rust/issues/29642 - = help: add `#![feature(custom_attribute)]` to the crate attributes to enable -error[E0658]: the attribute `empty_attr` is currently unknown to the compiler and may have meaning added to it in the future +error: expected an inert attribute, found an attribute macro --> $DIR/proc-macro-gates2.rs:17:9 | LL | #[empty_attr] | ^^^^^^^^^^^^^ - | - = note: for more information, see https://github.com/rust-lang/rust/issues/29642 - = help: add `#![feature(custom_attribute)]` to the crate attributes to enable error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/rfc-2565-param-attrs/param-attrs-builtin-attrs.rs b/src/test/ui/rfc-2565-param-attrs/param-attrs-builtin-attrs.rs index b957c673a41f1..a8fe5d6c1f60e 100644 --- a/src/test/ui/rfc-2565-param-attrs/param-attrs-builtin-attrs.rs +++ b/src/test/ui/rfc-2565-param-attrs/param-attrs-builtin-attrs.rs @@ -5,7 +5,7 @@ extern "C" { /// Foo //~^ ERROR documentation comments cannot be applied to function #[test] a: i32, - //~^ ERROR the attribute `test` is currently unknown to the compiler and may have + //~^ ERROR expected an inert attribute, found an attribute macro /// Bar //~^ ERROR documentation comments cannot be applied to function #[must_use] @@ -21,7 +21,7 @@ type FnType = fn( /// Foo //~^ ERROR documentation comments cannot be applied to function #[test] a: u32, - //~^ ERROR the attribute `test` is currently unknown to the compiler and may have + //~^ ERROR expected an inert attribute, found an attribute macro /// Bar //~^ ERROR documentation comments cannot be applied to function #[must_use] @@ -36,7 +36,7 @@ pub fn foo( /// Foo //~^ ERROR documentation comments cannot be applied to function #[test] a: u32, - //~^ ERROR the attribute `test` is currently unknown to the compiler and may have + //~^ ERROR expected an inert attribute, found an attribute macro /// Bar //~^ ERROR documentation comments cannot be applied to function #[must_use] @@ -56,7 +56,7 @@ impl SelfStruct { /// Bar //~^ ERROR documentation comments cannot be applied to function #[test] a: i32, - //~^ ERROR the attribute `test` is currently unknown to the compiler and may have + //~^ ERROR expected an inert attribute, found an attribute macro /// Baz //~^ ERROR documentation comments cannot be applied to function #[must_use] @@ -77,7 +77,7 @@ impl RefStruct { /// Bar //~^ ERROR documentation comments cannot be applied to function #[test] a: i32, - //~^ ERROR the attribute `test` is currently unknown to the compiler and may have + //~^ ERROR expected an inert attribute, found an attribute macro /// Baz //~^ ERROR documentation comments cannot be applied to function #[must_use] @@ -96,7 +96,7 @@ trait RefTrait { /// Bar //~^ ERROR documentation comments cannot be applied to function #[test] a: i32, - //~^ ERROR the attribute `test` is currently unknown to the compiler and may have + //~^ ERROR expected an inert attribute, found an attribute macro /// Baz //~^ ERROR documentation comments cannot be applied to function #[must_use] @@ -115,7 +115,7 @@ impl RefTrait for RefStruct { /// Bar //~^ ERROR documentation comments cannot be applied to function #[test] a: i32, - //~^ ERROR the attribute `test` is currently unknown to the compiler and may have + //~^ ERROR expected an inert attribute, found an attribute macro /// Baz //~^ ERROR documentation comments cannot be applied to function #[must_use] @@ -132,7 +132,7 @@ fn main() { /// Foo //~^ ERROR documentation comments cannot be applied to function #[test] a: u32, - //~^ ERROR the attribute `test` is currently unknown to the compiler and may have + //~^ ERROR expected an inert attribute, found an attribute macro /// Bar //~^ ERROR documentation comments cannot be applied to function #[must_use] diff --git a/src/test/ui/rfc-2565-param-attrs/param-attrs-builtin-attrs.stderr b/src/test/ui/rfc-2565-param-attrs/param-attrs-builtin-attrs.stderr index a57572abb3513..8ab3fc39a0ccb 100644 --- a/src/test/ui/rfc-2565-param-attrs/param-attrs-builtin-attrs.stderr +++ b/src/test/ui/rfc-2565-param-attrs/param-attrs-builtin-attrs.stderr @@ -1,3 +1,51 @@ +error: expected an inert attribute, found an attribute macro + --> $DIR/param-attrs-builtin-attrs.rs:7:9 + | +LL | #[test] a: i32, + | ^^^^^^^ + +error: expected an inert attribute, found an attribute macro + --> $DIR/param-attrs-builtin-attrs.rs:23:5 + | +LL | #[test] a: u32, + | ^^^^^^^ + +error: expected an inert attribute, found an attribute macro + --> $DIR/param-attrs-builtin-attrs.rs:38:5 + | +LL | #[test] a: u32, + | ^^^^^^^ + +error: expected an inert attribute, found an attribute macro + --> $DIR/param-attrs-builtin-attrs.rs:58:9 + | +LL | #[test] a: i32, + | ^^^^^^^ + +error: expected an inert attribute, found an attribute macro + --> $DIR/param-attrs-builtin-attrs.rs:79:9 + | +LL | #[test] a: i32, + | ^^^^^^^ + +error: expected an inert attribute, found an attribute macro + --> $DIR/param-attrs-builtin-attrs.rs:98:9 + | +LL | #[test] a: i32, + | ^^^^^^^ + +error: expected an inert attribute, found an attribute macro + --> $DIR/param-attrs-builtin-attrs.rs:117:9 + | +LL | #[test] a: i32, + | ^^^^^^^ + +error: expected an inert attribute, found an attribute macro + --> $DIR/param-attrs-builtin-attrs.rs:134:9 + | +LL | #[test] a: u32, + | ^^^^^^^ + error: documentation comments cannot be applied to function parameters --> $DIR/param-attrs-builtin-attrs.rs:5:9 | @@ -262,78 +310,5 @@ error: allow, cfg, cfg_attr, deny, forbid, and warn are the only allowed built-i LL | #[no_mangle] b: i32 | ^^^^^^^^^^^^ -error[E0658]: the attribute `test` is currently unknown to the compiler and may have meaning added to it in the future - --> $DIR/param-attrs-builtin-attrs.rs:7:9 - | -LL | #[test] a: i32, - | ^^^^^^^ - | - = note: for more information, see https://github.com/rust-lang/rust/issues/29642 - = help: add `#![feature(custom_attribute)]` to the crate attributes to enable - -error[E0658]: the attribute `test` is currently unknown to the compiler and may have meaning added to it in the future - --> $DIR/param-attrs-builtin-attrs.rs:23:5 - | -LL | #[test] a: u32, - | ^^^^^^^ - | - = note: for more information, see https://github.com/rust-lang/rust/issues/29642 - = help: add `#![feature(custom_attribute)]` to the crate attributes to enable - -error[E0658]: the attribute `test` is currently unknown to the compiler and may have meaning added to it in the future - --> $DIR/param-attrs-builtin-attrs.rs:38:5 - | -LL | #[test] a: u32, - | ^^^^^^^ - | - = note: for more information, see https://github.com/rust-lang/rust/issues/29642 - = help: add `#![feature(custom_attribute)]` to the crate attributes to enable - -error[E0658]: the attribute `test` is currently unknown to the compiler and may have meaning added to it in the future - --> $DIR/param-attrs-builtin-attrs.rs:58:9 - | -LL | #[test] a: i32, - | ^^^^^^^ - | - = note: for more information, see https://github.com/rust-lang/rust/issues/29642 - = help: add `#![feature(custom_attribute)]` to the crate attributes to enable - -error[E0658]: the attribute `test` is currently unknown to the compiler and may have meaning added to it in the future - --> $DIR/param-attrs-builtin-attrs.rs:79:9 - | -LL | #[test] a: i32, - | ^^^^^^^ - | - = note: for more information, see https://github.com/rust-lang/rust/issues/29642 - = help: add `#![feature(custom_attribute)]` to the crate attributes to enable - -error[E0658]: the attribute `test` is currently unknown to the compiler and may have meaning added to it in the future - --> $DIR/param-attrs-builtin-attrs.rs:98:9 - | -LL | #[test] a: i32, - | ^^^^^^^ - | - = note: for more information, see https://github.com/rust-lang/rust/issues/29642 - = help: add `#![feature(custom_attribute)]` to the crate attributes to enable - -error[E0658]: the attribute `test` is currently unknown to the compiler and may have meaning added to it in the future - --> $DIR/param-attrs-builtin-attrs.rs:117:9 - | -LL | #[test] a: i32, - | ^^^^^^^ - | - = note: for more information, see https://github.com/rust-lang/rust/issues/29642 - = help: add `#![feature(custom_attribute)]` to the crate attributes to enable - -error[E0658]: the attribute `test` is currently unknown to the compiler and may have meaning added to it in the future - --> $DIR/param-attrs-builtin-attrs.rs:134:9 - | -LL | #[test] a: u32, - | ^^^^^^^ - | - = note: for more information, see https://github.com/rust-lang/rust/issues/29642 - = help: add `#![feature(custom_attribute)]` to the crate attributes to enable - error: aborting due to 52 previous errors -For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/rfc-2565-param-attrs/proc-macro-cannot-be-used.rs b/src/test/ui/rfc-2565-param-attrs/proc-macro-cannot-be-used.rs index 8defa26e48d8d..7f00308925442 100644 --- a/src/test/ui/rfc-2565-param-attrs/proc-macro-cannot-be-used.rs +++ b/src/test/ui/rfc-2565-param-attrs/proc-macro-cannot-be-used.rs @@ -9,52 +9,52 @@ use ident_mac::id; struct W(u8); extern "C" { fn ffi(#[id] arg1: i32, #[id] ...); } -//~^ ERROR the attribute `id` is currently unknown to the compiler -//~| ERROR the attribute `id` is currently unknown to the compiler +//~^ ERROR expected an inert attribute, found an attribute macro +//~| ERROR expected an inert attribute, found an attribute macro unsafe extern "C" fn cvar(arg1: i32, #[id] mut args: ...) {} -//~^ ERROR the attribute `id` is currently unknown to the compiler +//~^ ERROR expected an inert attribute, found an attribute macro type Alias = extern "C" fn(#[id] u8, #[id] ...); - //~^ ERROR the attribute `id` is currently unknown to the compiler - //~| ERROR the attribute `id` is currently unknown to the compiler + //~^ ERROR expected an inert attribute, found an attribute macro + //~| ERROR expected an inert attribute, found an attribute macro fn free(#[id] arg1: u8) { - //~^ ERROR the attribute `id` is currently unknown to the compiler + //~^ ERROR expected an inert attribute, found an attribute macro let lam = |#[id] W(x), #[id] y| (); - //~^ ERROR the attribute `id` is currently unknown to the compiler - //~| ERROR the attribute `id` is currently unknown to the compiler + //~^ ERROR expected an inert attribute, found an attribute macro + //~| ERROR expected an inert attribute, found an attribute macro } impl W { fn inherent1(#[id] self, #[id] arg1: u8) {} - //~^ ERROR the attribute `id` is currently unknown to the compiler - //~| ERROR the attribute `id` is currently unknown to the compiler + //~^ ERROR expected an inert attribute, found an attribute macro + //~| ERROR expected an inert attribute, found an attribute macro fn inherent2(#[id] &self, #[id] arg1: u8) {} - //~^ ERROR the attribute `id` is currently unknown to the compiler - //~| ERROR the attribute `id` is currently unknown to the compiler + //~^ ERROR expected an inert attribute, found an attribute macro + //~| ERROR expected an inert attribute, found an attribute macro fn inherent3<'a>(#[id] &'a mut self, #[id] arg1: u8) {} - //~^ ERROR the attribute `id` is currently unknown to the compiler - //~| ERROR the attribute `id` is currently unknown to the compiler + //~^ ERROR expected an inert attribute, found an attribute macro + //~| ERROR expected an inert attribute, found an attribute macro fn inherent4<'a>(#[id] self: Box, #[id] arg1: u8) {} - //~^ ERROR the attribute `id` is currently unknown to the compiler - //~| ERROR the attribute `id` is currently unknown to the compiler + //~^ ERROR expected an inert attribute, found an attribute macro + //~| ERROR expected an inert attribute, found an attribute macro } trait A { fn trait1(#[id] self, #[id] arg1: u8); - //~^ ERROR the attribute `id` is currently unknown to the compiler - //~| ERROR the attribute `id` is currently unknown to the compiler + //~^ ERROR expected an inert attribute, found an attribute macro + //~| ERROR expected an inert attribute, found an attribute macro fn trait2(#[id] &self, #[id] arg1: u8); - //~^ ERROR the attribute `id` is currently unknown to the compiler - //~| ERROR the attribute `id` is currently unknown to the compiler + //~^ ERROR expected an inert attribute, found an attribute macro + //~| ERROR expected an inert attribute, found an attribute macro fn trait3<'a>(#[id] &'a mut self, #[id] arg1: u8); - //~^ ERROR the attribute `id` is currently unknown to the compiler - //~| ERROR the attribute `id` is currently unknown to the compiler + //~^ ERROR expected an inert attribute, found an attribute macro + //~| ERROR expected an inert attribute, found an attribute macro fn trait4<'a>(#[id] self: Box, #[id] arg1: u8, #[id] Vec); - //~^ ERROR the attribute `id` is currently unknown to the compiler - //~| ERROR the attribute `id` is currently unknown to the compiler - //~| ERROR the attribute `id` is currently unknown to the compiler + //~^ ERROR expected an inert attribute, found an attribute macro + //~| ERROR expected an inert attribute, found an attribute macro + //~| ERROR expected an inert attribute, found an attribute macro } fn main() {} diff --git a/src/test/ui/rfc-2565-param-attrs/proc-macro-cannot-be-used.stderr b/src/test/ui/rfc-2565-param-attrs/proc-macro-cannot-be-used.stderr index 69b9a46b3d502..3b72e8ab4bdf9 100644 --- a/src/test/ui/rfc-2565-param-attrs/proc-macro-cannot-be-used.stderr +++ b/src/test/ui/rfc-2565-param-attrs/proc-macro-cannot-be-used.stderr @@ -1,228 +1,152 @@ -error[E0658]: the attribute `id` is currently unknown to the compiler and may have meaning added to it in the future +error: expected an inert attribute, found an attribute macro --> $DIR/proc-macro-cannot-be-used.rs:11:21 | LL | extern "C" { fn ffi(#[id] arg1: i32, #[id] ...); } | ^^^^^ - | - = note: for more information, see https://github.com/rust-lang/rust/issues/29642 - = help: add `#![feature(custom_attribute)]` to the crate attributes to enable -error[E0658]: the attribute `id` is currently unknown to the compiler and may have meaning added to it in the future +error: expected an inert attribute, found an attribute macro --> $DIR/proc-macro-cannot-be-used.rs:11:38 | LL | extern "C" { fn ffi(#[id] arg1: i32, #[id] ...); } | ^^^^^ - | - = note: for more information, see https://github.com/rust-lang/rust/issues/29642 - = help: add `#![feature(custom_attribute)]` to the crate attributes to enable -error[E0658]: the attribute `id` is currently unknown to the compiler and may have meaning added to it in the future +error: expected an inert attribute, found an attribute macro --> $DIR/proc-macro-cannot-be-used.rs:15:38 | LL | unsafe extern "C" fn cvar(arg1: i32, #[id] mut args: ...) {} | ^^^^^ - | - = note: for more information, see https://github.com/rust-lang/rust/issues/29642 - = help: add `#![feature(custom_attribute)]` to the crate attributes to enable -error[E0658]: the attribute `id` is currently unknown to the compiler and may have meaning added to it in the future +error: expected an inert attribute, found an attribute macro --> $DIR/proc-macro-cannot-be-used.rs:18:28 | LL | type Alias = extern "C" fn(#[id] u8, #[id] ...); | ^^^^^ - | - = note: for more information, see https://github.com/rust-lang/rust/issues/29642 - = help: add `#![feature(custom_attribute)]` to the crate attributes to enable -error[E0658]: the attribute `id` is currently unknown to the compiler and may have meaning added to it in the future +error: expected an inert attribute, found an attribute macro --> $DIR/proc-macro-cannot-be-used.rs:18:38 | LL | type Alias = extern "C" fn(#[id] u8, #[id] ...); | ^^^^^ - | - = note: for more information, see https://github.com/rust-lang/rust/issues/29642 - = help: add `#![feature(custom_attribute)]` to the crate attributes to enable -error[E0658]: the attribute `id` is currently unknown to the compiler and may have meaning added to it in the future +error: expected an inert attribute, found an attribute macro --> $DIR/proc-macro-cannot-be-used.rs:22:9 | LL | fn free(#[id] arg1: u8) { | ^^^^^ - | - = note: for more information, see https://github.com/rust-lang/rust/issues/29642 - = help: add `#![feature(custom_attribute)]` to the crate attributes to enable -error[E0658]: the attribute `id` is currently unknown to the compiler and may have meaning added to it in the future +error: expected an inert attribute, found an attribute macro --> $DIR/proc-macro-cannot-be-used.rs:24:16 | LL | let lam = |#[id] W(x), #[id] y| (); | ^^^^^ - | - = note: for more information, see https://github.com/rust-lang/rust/issues/29642 - = help: add `#![feature(custom_attribute)]` to the crate attributes to enable -error[E0658]: the attribute `id` is currently unknown to the compiler and may have meaning added to it in the future +error: expected an inert attribute, found an attribute macro --> $DIR/proc-macro-cannot-be-used.rs:24:28 | LL | let lam = |#[id] W(x), #[id] y| (); | ^^^^^ - | - = note: for more information, see https://github.com/rust-lang/rust/issues/29642 - = help: add `#![feature(custom_attribute)]` to the crate attributes to enable -error[E0658]: the attribute `id` is currently unknown to the compiler and may have meaning added to it in the future +error: expected an inert attribute, found an attribute macro --> $DIR/proc-macro-cannot-be-used.rs:30:18 | LL | fn inherent1(#[id] self, #[id] arg1: u8) {} | ^^^^^ - | - = note: for more information, see https://github.com/rust-lang/rust/issues/29642 - = help: add `#![feature(custom_attribute)]` to the crate attributes to enable -error[E0658]: the attribute `id` is currently unknown to the compiler and may have meaning added to it in the future +error: expected an inert attribute, found an attribute macro --> $DIR/proc-macro-cannot-be-used.rs:30:30 | LL | fn inherent1(#[id] self, #[id] arg1: u8) {} | ^^^^^ - | - = note: for more information, see https://github.com/rust-lang/rust/issues/29642 - = help: add `#![feature(custom_attribute)]` to the crate attributes to enable -error[E0658]: the attribute `id` is currently unknown to the compiler and may have meaning added to it in the future +error: expected an inert attribute, found an attribute macro --> $DIR/proc-macro-cannot-be-used.rs:33:18 | LL | fn inherent2(#[id] &self, #[id] arg1: u8) {} | ^^^^^ - | - = note: for more information, see https://github.com/rust-lang/rust/issues/29642 - = help: add `#![feature(custom_attribute)]` to the crate attributes to enable -error[E0658]: the attribute `id` is currently unknown to the compiler and may have meaning added to it in the future +error: expected an inert attribute, found an attribute macro --> $DIR/proc-macro-cannot-be-used.rs:33:31 | LL | fn inherent2(#[id] &self, #[id] arg1: u8) {} | ^^^^^ - | - = note: for more information, see https://github.com/rust-lang/rust/issues/29642 - = help: add `#![feature(custom_attribute)]` to the crate attributes to enable -error[E0658]: the attribute `id` is currently unknown to the compiler and may have meaning added to it in the future +error: expected an inert attribute, found an attribute macro --> $DIR/proc-macro-cannot-be-used.rs:36:22 | LL | fn inherent3<'a>(#[id] &'a mut self, #[id] arg1: u8) {} | ^^^^^ - | - = note: for more information, see https://github.com/rust-lang/rust/issues/29642 - = help: add `#![feature(custom_attribute)]` to the crate attributes to enable -error[E0658]: the attribute `id` is currently unknown to the compiler and may have meaning added to it in the future +error: expected an inert attribute, found an attribute macro --> $DIR/proc-macro-cannot-be-used.rs:36:42 | LL | fn inherent3<'a>(#[id] &'a mut self, #[id] arg1: u8) {} | ^^^^^ - | - = note: for more information, see https://github.com/rust-lang/rust/issues/29642 - = help: add `#![feature(custom_attribute)]` to the crate attributes to enable -error[E0658]: the attribute `id` is currently unknown to the compiler and may have meaning added to it in the future +error: expected an inert attribute, found an attribute macro --> $DIR/proc-macro-cannot-be-used.rs:39:22 | LL | fn inherent4<'a>(#[id] self: Box, #[id] arg1: u8) {} | ^^^^^ - | - = note: for more information, see https://github.com/rust-lang/rust/issues/29642 - = help: add `#![feature(custom_attribute)]` to the crate attributes to enable -error[E0658]: the attribute `id` is currently unknown to the compiler and may have meaning added to it in the future +error: expected an inert attribute, found an attribute macro --> $DIR/proc-macro-cannot-be-used.rs:39:45 | LL | fn inherent4<'a>(#[id] self: Box, #[id] arg1: u8) {} | ^^^^^ - | - = note: for more information, see https://github.com/rust-lang/rust/issues/29642 - = help: add `#![feature(custom_attribute)]` to the crate attributes to enable -error[E0658]: the attribute `id` is currently unknown to the compiler and may have meaning added to it in the future +error: expected an inert attribute, found an attribute macro --> $DIR/proc-macro-cannot-be-used.rs:45:15 | LL | fn trait1(#[id] self, #[id] arg1: u8); | ^^^^^ - | - = note: for more information, see https://github.com/rust-lang/rust/issues/29642 - = help: add `#![feature(custom_attribute)]` to the crate attributes to enable -error[E0658]: the attribute `id` is currently unknown to the compiler and may have meaning added to it in the future +error: expected an inert attribute, found an attribute macro --> $DIR/proc-macro-cannot-be-used.rs:45:27 | LL | fn trait1(#[id] self, #[id] arg1: u8); | ^^^^^ - | - = note: for more information, see https://github.com/rust-lang/rust/issues/29642 - = help: add `#![feature(custom_attribute)]` to the crate attributes to enable -error[E0658]: the attribute `id` is currently unknown to the compiler and may have meaning added to it in the future +error: expected an inert attribute, found an attribute macro --> $DIR/proc-macro-cannot-be-used.rs:48:15 | LL | fn trait2(#[id] &self, #[id] arg1: u8); | ^^^^^ - | - = note: for more information, see https://github.com/rust-lang/rust/issues/29642 - = help: add `#![feature(custom_attribute)]` to the crate attributes to enable -error[E0658]: the attribute `id` is currently unknown to the compiler and may have meaning added to it in the future +error: expected an inert attribute, found an attribute macro --> $DIR/proc-macro-cannot-be-used.rs:48:28 | LL | fn trait2(#[id] &self, #[id] arg1: u8); | ^^^^^ - | - = note: for more information, see https://github.com/rust-lang/rust/issues/29642 - = help: add `#![feature(custom_attribute)]` to the crate attributes to enable -error[E0658]: the attribute `id` is currently unknown to the compiler and may have meaning added to it in the future +error: expected an inert attribute, found an attribute macro --> $DIR/proc-macro-cannot-be-used.rs:51:19 | LL | fn trait3<'a>(#[id] &'a mut self, #[id] arg1: u8); | ^^^^^ - | - = note: for more information, see https://github.com/rust-lang/rust/issues/29642 - = help: add `#![feature(custom_attribute)]` to the crate attributes to enable -error[E0658]: the attribute `id` is currently unknown to the compiler and may have meaning added to it in the future +error: expected an inert attribute, found an attribute macro --> $DIR/proc-macro-cannot-be-used.rs:51:39 | LL | fn trait3<'a>(#[id] &'a mut self, #[id] arg1: u8); | ^^^^^ - | - = note: for more information, see https://github.com/rust-lang/rust/issues/29642 - = help: add `#![feature(custom_attribute)]` to the crate attributes to enable -error[E0658]: the attribute `id` is currently unknown to the compiler and may have meaning added to it in the future +error: expected an inert attribute, found an attribute macro --> $DIR/proc-macro-cannot-be-used.rs:54:19 | LL | fn trait4<'a>(#[id] self: Box, #[id] arg1: u8, #[id] Vec); | ^^^^^ - | - = note: for more information, see https://github.com/rust-lang/rust/issues/29642 - = help: add `#![feature(custom_attribute)]` to the crate attributes to enable -error[E0658]: the attribute `id` is currently unknown to the compiler and may have meaning added to it in the future +error: expected an inert attribute, found an attribute macro --> $DIR/proc-macro-cannot-be-used.rs:54:42 | LL | fn trait4<'a>(#[id] self: Box, #[id] arg1: u8, #[id] Vec); | ^^^^^ - | - = note: for more information, see https://github.com/rust-lang/rust/issues/29642 - = help: add `#![feature(custom_attribute)]` to the crate attributes to enable -error[E0658]: the attribute `id` is currently unknown to the compiler and may have meaning added to it in the future +error: expected an inert attribute, found an attribute macro --> $DIR/proc-macro-cannot-be-used.rs:54:58 | LL | fn trait4<'a>(#[id] self: Box, #[id] arg1: u8, #[id] Vec); | ^^^^^ - | - = note: for more information, see https://github.com/rust-lang/rust/issues/29642 - = help: add `#![feature(custom_attribute)]` to the crate attributes to enable error: aborting due to 25 previous errors -For more information about this error, try `rustc --explain E0658`. From b117bd7366b38061ec91697f9f2c6d1736e01aa4 Mon Sep 17 00:00:00 2001 From: Guanqun Lu Date: Wed, 4 Sep 2019 23:49:30 +0800 Subject: [PATCH 26/27] check git in bootstrap.py when trying to update submodule --- src/bootstrap/bootstrap.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/bootstrap/bootstrap.py b/src/bootstrap/bootstrap.py index 14bc90700b76e..65129eeeec504 100644 --- a/src/bootstrap/bootstrap.py +++ b/src/bootstrap/bootstrap.py @@ -708,6 +708,14 @@ def update_submodules(self): if (not os.path.exists(os.path.join(self.rust_root, ".git"))) or \ self.get_toml('submodules') == "false": return + + # check the existence of 'git' command + try: + subprocess.check_output(['git', '--version']) + except (subprocess.CalledProcessError, OSError): + print("error: `git` is not found, please make sure it's installed and in the path.") + sys.exit(1) + slow_submodules = self.get_toml('fast-submodules') == "false" start_time = time() if slow_submodules: From 0d34fe42f724ba094b8d131f869c716204450e5c Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 9 Sep 2019 17:04:28 +0200 Subject: [PATCH 27/27] Unify escape usage --- src/librustdoc/html/static/main.js | 47 ++++++++++++++++++------------ 1 file changed, 29 insertions(+), 18 deletions(-) diff --git a/src/librustdoc/html/static/main.js b/src/librustdoc/html/static/main.js index 309e5575ee403..ef2c6d877bfc6 100644 --- a/src/librustdoc/html/static/main.js +++ b/src/librustdoc/html/static/main.js @@ -39,6 +39,14 @@ if (!DOMTokenList.prototype.remove) { }; } +function getSearchInput() { + return document.getElementsByClassName("search-input")[0]; +} + +function getSearchElement() { + return document.getElementById("search"); +} + (function() { "use strict"; @@ -71,7 +79,7 @@ if (!DOMTokenList.prototype.remove) { "derive", "traitalias"]; - var search_input = document.getElementsByClassName("search-input")[0]; + var search_input = getSearchInput(); // On the search screen, so you remain on the last tab you opened. // @@ -158,7 +166,7 @@ if (!DOMTokenList.prototype.remove) { // If we're in mobile mode, we should add the sidebar in any case. hideSidebar(); var elem; - var search = document.getElementById("search"); + var search = getSearchElement(); var i, from, to, match = window.location.hash.match(/^#?(\d+)(?:-(\d+))?$/); if (match) { from = parseInt(match[1], 10); @@ -250,7 +258,12 @@ if (!DOMTokenList.prototype.remove) { return String.fromCharCode(c); } + function getHelpElement() { + return document.getElementById("help"); + } + function displayHelp(display, ev, help) { + var help = help ? help : getHelpElement(); if (display === true) { if (hasClass(help, "hidden")) { ev.preventDefault(); @@ -264,9 +277,10 @@ if (!DOMTokenList.prototype.remove) { } } - function handleEscape(ev, help) { + function handleEscape(ev) { + var help = getHelpElement(); + var search = getSearchElement(); hideModal(); - var search = document.getElementById("search"); if (hasClass(help, "hidden") === false) { displayHelp(false, ev, help); } else if (hasClass(search, "hidden") === false) { @@ -284,22 +298,21 @@ if (!DOMTokenList.prototype.remove) { return; } - var help = document.getElementById("help"); if (document.activeElement.tagName === "INPUT") { switch (getVirtualKey(ev)) { case "Escape": - handleEscape(ev, help); + handleEscape(ev); break; } } else { switch (getVirtualKey(ev)) { case "Escape": - handleEscape(ev, help); + handleEscape(ev); break; case "s": case "S": - displayHelp(false, ev, help); + displayHelp(false, ev); hideModal(); ev.preventDefault(); focusSearchBar(); @@ -314,7 +327,7 @@ if (!DOMTokenList.prototype.remove) { case "?": if (ev.shiftKey) { hideModal(); - displayHelp(true, ev, help); + displayHelp(true, ev); } break; } @@ -1285,9 +1298,7 @@ if (!DOMTokenList.prototype.remove) { } else if (e.which === 16) { // shift // Does nothing, it's just to avoid losing "focus" on the highlighted element. } else if (e.which === 27) { // escape - removeClass(actives[currentTab][0], "highlighted"); - search_input.value = ""; - defocusSearchBar(); + handleEscape(e); } else if (actives[currentTab].length > 0) { removeClass(actives[currentTab][0], "highlighted"); } @@ -1438,7 +1449,7 @@ if (!DOMTokenList.prototype.remove) { ret_others[0] + ret_in_args[0] + ret_returned[0] + ""; addClass(main, "hidden"); - var search = document.getElementById("search"); + var search = getSearchElement(); removeClass(search, "hidden"); search.innerHTML = output; var tds = search.getElementsByTagName("td"); @@ -1648,7 +1659,7 @@ if (!DOMTokenList.prototype.remove) { if (hasClass(main, "content")) { removeClass(main, "hidden"); } - var search_c = document.getElementById("search"); + var search_c = getSearchElement(); if (hasClass(search_c, "content")) { addClass(search_c, "hidden"); } @@ -1695,7 +1706,7 @@ if (!DOMTokenList.prototype.remove) { if (hasClass(main, "content")) { removeClass(main, "hidden"); } - var search_c = document.getElementById("search"); + var search_c = getSearchElement(); if (hasClass(search_c, "content")) { addClass(search_c, "hidden"); } @@ -2464,7 +2475,7 @@ if (!DOMTokenList.prototype.remove) { var params = getQueryStringParams(); if (params && params.search) { addClass(main, "hidden"); - var search = document.getElementById("search"); + var search = getSearchElement(); removeClass(search, "hidden"); search.innerHTML = "

Loading search results...

"; } @@ -2549,10 +2560,10 @@ if (!DOMTokenList.prototype.remove) { // Sets the focus on the search bar at the top of the page function focusSearchBar() { - document.getElementsByClassName("search-input")[0].focus(); + getSearchInput().focus(); } // Removes the focus from the search bar function defocusSearchBar() { - document.getElementsByClassName("search-input")[0].blur(); + getSearchInput().blur(); }