From c0056c04f61a051e26dae2631c59637da815abbb Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Sat, 3 Aug 2019 16:59:05 +0200 Subject: [PATCH 01/15] legacy_ctor_visibility -> error --- .../src/lints/listing/deny-by-default.md | 35 ------------------- src/librustc/lint/builtin.rs | 11 ------ src/librustc_lint/lib.rs | 2 ++ src/librustc_resolve/late.rs | 20 +---------- src/test/ui/privacy/legacy-ctor-visibility.rs | 7 +--- .../ui/privacy/legacy-ctor-visibility.stderr | 17 ++++----- 6 files changed, 13 insertions(+), 79 deletions(-) diff --git a/src/doc/rustc/src/lints/listing/deny-by-default.md b/src/doc/rustc/src/lints/listing/deny-by-default.md index 5688e90ada1..540543f98f3 100644 --- a/src/doc/rustc/src/lints/listing/deny-by-default.md +++ b/src/doc/rustc/src/lints/listing/deny-by-default.md @@ -45,41 +45,6 @@ error: defaults for type parameters are only allowed in `struct`, `enum`, `type` = note: for more information, see issue #36887 ``` -## legacy-constructor-visibility - -[RFC 1506](https://github.com/rust-lang/rfcs/blob/master/text/1506-adt-kinds.md) modified some -visibility rules, and changed the visibility of struct constructors. Some -example code that triggers this lint: - -```rust,ignore -mod m { - pub struct S(u8); - - fn f() { - // this is trying to use S from the 'use' line, but because the `u8` is - // not pub, it is private - ::S; - } -} - -use m::S; -``` - -This will produce: - -```text -error: private struct constructors are not usable through re-exports in outer modules - --> src/main.rs:5:9 - | -5 | ::S; - | ^^^ - | - = note: `#[deny(legacy_constructor_visibility)]` on by default - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #39207 -``` - - ## legacy-directory-ownership The legacy_directory_ownership warning is issued when diff --git a/src/librustc/lint/builtin.rs b/src/librustc/lint/builtin.rs index 65777fe78db..4dd45f27aca 100644 --- a/src/librustc/lint/builtin.rs +++ b/src/librustc/lint/builtin.rs @@ -218,16 +218,6 @@ }; } -declare_lint! { - pub LEGACY_CONSTRUCTOR_VISIBILITY, - Deny, - "detects use of struct constructors that would be invisible with new visibility rules", - @future_incompatible = FutureIncompatibleInfo { - reference: "issue #39207 ", - edition: None, - }; -} - declare_lint! { pub MISSING_FRAGMENT_SPECIFIER, Deny, @@ -560,7 +550,6 @@ pub mod parser { SAFE_PACKED_BORROWS, PATTERNS_IN_FNS_WITHOUT_BODY, LEGACY_DIRECTORY_OWNERSHIP, - LEGACY_CONSTRUCTOR_VISIBILITY, MISSING_FRAGMENT_SPECIFIER, PARENTHESIZED_PARAMS_IN_TYPES_AND_MODULES, LATE_BOUND_LIFETIME_ARGUMENTS, diff --git a/src/librustc_lint/lib.rs b/src/librustc_lint/lib.rs index b1beef04c59..4636a3d65b7 100644 --- a/src/librustc_lint/lib.rs +++ b/src/librustc_lint/lib.rs @@ -334,6 +334,8 @@ macro_rules! register_passes { "converted into hard error, see https://github.com/rust-lang/rust/issues/57742"); store.register_removed("incoherent_fundamental_impls", "converted into hard error, see https://github.com/rust-lang/rust/issues/46205"); + store.register_removed("legacy_constructor_visibility", + "converted into hard error, see https://github.com/rust-lang/rust/issues/39207"); } fn register_internals(store: &mut lint::LintStore) { diff --git a/src/librustc_resolve/late.rs b/src/librustc_resolve/late.rs index 58af4b817d2..9c842597511 100644 --- a/src/librustc_resolve/late.rs +++ b/src/librustc_resolve/late.rs @@ -1539,25 +1539,7 @@ fn smart_resolve_path_fragment(&mut self, if is_expected(partial_res.base_res()) || partial_res.base_res() == Res::Err { partial_res } else { - // Add a temporary hack to smooth the transition to new struct ctor - // visibility rules. See #38932 for more details. - let mut res = None; - if let Res::Def(DefKind::Struct, def_id) = partial_res.base_res() { - if let Some((ctor_res, ctor_vis)) - = self.r.struct_constructors.get(&def_id).cloned() { - if is_expected(ctor_res) && - self.r.is_accessible_from(ctor_vis, self.parent_scope.module) { - let lint = lint::builtin::LEGACY_CONSTRUCTOR_VISIBILITY; - self.r.lint_buffer.buffer_lint(lint, id, span, - "private struct constructors are not usable through \ - re-exports in outer modules", - ); - res = Some(PartialRes::new(ctor_res)); - } - } - } - - res.unwrap_or_else(|| report_errors(self, Some(partial_res.base_res()))) + report_errors(self, Some(partial_res.base_res())) } } Some(partial_res) if source.defer_to_typeck() => { diff --git a/src/test/ui/privacy/legacy-ctor-visibility.rs b/src/test/ui/privacy/legacy-ctor-visibility.rs index 7db4be729e8..5732b6446fe 100644 --- a/src/test/ui/privacy/legacy-ctor-visibility.rs +++ b/src/test/ui/privacy/legacy-ctor-visibility.rs @@ -1,7 +1,3 @@ -// ignore-tidy-linelength - -#![allow(unused)] - use m::S; mod m { @@ -11,8 +7,7 @@ mod n { use S; fn f() { S(10); - //~^ ERROR private struct constructors are not usable through re-exports in outer modules - //~| WARN this was previously accepted + //~^ ERROR expected function, tuple struct or tuple variant, found struct `S` } } } diff --git a/src/test/ui/privacy/legacy-ctor-visibility.stderr b/src/test/ui/privacy/legacy-ctor-visibility.stderr index 69b6e08befc..74a1f1ceeff 100644 --- a/src/test/ui/privacy/legacy-ctor-visibility.stderr +++ b/src/test/ui/privacy/legacy-ctor-visibility.stderr @@ -1,12 +1,13 @@ -error: private struct constructors are not usable through re-exports in outer modules - --> $DIR/legacy-ctor-visibility.rs:13:13 +error[E0423]: expected function, tuple struct or tuple variant, found struct `S` + --> $DIR/legacy-ctor-visibility.rs:9:13 | -LL | S(10); - | ^ - | - = note: `#[deny(legacy_constructor_visibility)]` on by default - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #39207 +LL | / fn f() { +LL | | S(10); + | | ^ help: a function with a similar name exists: `f` +LL | | +LL | | } + | |_________- similarly named function `f` defined here error: aborting due to previous error +For more information about this error, try `rustc --explain E0423`. From 79b35e90f1cbfa21b6a39354cf7d8e8acfa8b0e1 Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Sat, 3 Aug 2019 17:42:17 +0200 Subject: [PATCH 02/15] legacy_directory_ownership -> error --- .../src/lints/listing/deny-by-default.md | 12 --------- src/librustc/lint/builtin.rs | 12 --------- src/librustc_lint/lib.rs | 2 ++ src/librustc_passes/ast_validation.rs | 5 ---- src/libsyntax/parse/mod.rs | 2 +- src/libsyntax/parse/parser/module.rs | 26 ++++--------------- src/libsyntax_expand/expand.rs | 2 +- src/libsyntax_pos/symbol.rs | 1 - 8 files changed, 9 insertions(+), 53 deletions(-) diff --git a/src/doc/rustc/src/lints/listing/deny-by-default.md b/src/doc/rustc/src/lints/listing/deny-by-default.md index 540543f98f3..f175a881fef 100644 --- a/src/doc/rustc/src/lints/listing/deny-by-default.md +++ b/src/doc/rustc/src/lints/listing/deny-by-default.md @@ -45,18 +45,6 @@ error: defaults for type parameters are only allowed in `struct`, `enum`, `type` = note: for more information, see issue #36887 ``` -## legacy-directory-ownership - -The legacy_directory_ownership warning is issued when - -* There is a non-inline module with a `#[path]` attribute (e.g. `#[path = "foo.rs"] mod bar;`), -* The module's file ("foo.rs" in the above example) is not named "mod.rs", and -* The module's file contains a non-inline child module without a `#[path]` attribute. - -The warning can be fixed by renaming the parent module to "mod.rs" and moving -it into its own directory if appropriate. - - ## missing-fragment-specifier The missing_fragment_specifier warning is issued when an unused pattern in a diff --git a/src/librustc/lint/builtin.rs b/src/librustc/lint/builtin.rs index 4dd45f27aca..9301dac32cd 100644 --- a/src/librustc/lint/builtin.rs +++ b/src/librustc/lint/builtin.rs @@ -207,17 +207,6 @@ }; } -declare_lint! { - pub LEGACY_DIRECTORY_OWNERSHIP, - Deny, - "non-inline, non-`#[path]` modules (e.g., `mod foo;`) were erroneously allowed in some files \ - not named `mod.rs`", - @future_incompatible = FutureIncompatibleInfo { - reference: "issue #37872 ", - edition: None, - }; -} - declare_lint! { pub MISSING_FRAGMENT_SPECIFIER, Deny, @@ -549,7 +538,6 @@ pub mod parser { SAFE_EXTERN_STATICS, SAFE_PACKED_BORROWS, PATTERNS_IN_FNS_WITHOUT_BODY, - LEGACY_DIRECTORY_OWNERSHIP, MISSING_FRAGMENT_SPECIFIER, PARENTHESIZED_PARAMS_IN_TYPES_AND_MODULES, LATE_BOUND_LIFETIME_ARGUMENTS, diff --git a/src/librustc_lint/lib.rs b/src/librustc_lint/lib.rs index 4636a3d65b7..1dcd61896c3 100644 --- a/src/librustc_lint/lib.rs +++ b/src/librustc_lint/lib.rs @@ -336,6 +336,8 @@ macro_rules! register_passes { "converted into hard error, see https://github.com/rust-lang/rust/issues/46205"); store.register_removed("legacy_constructor_visibility", "converted into hard error, see https://github.com/rust-lang/rust/issues/39207"); + store.register_removed("legacy_disrectory_ownership", + "converted into hard error, see https://github.com/rust-lang/rust/issues/37872"); } fn register_internals(store: &mut lint::LintStore) { diff --git a/src/librustc_passes/ast_validation.rs b/src/librustc_passes/ast_validation.rs index e625334040e..e046f6c2a07 100644 --- a/src/librustc_passes/ast_validation.rs +++ b/src/librustc_passes/ast_validation.rs @@ -654,11 +654,6 @@ fn visit_item(&mut self, item: &'a Item) { ItemKind::Mod(_) => { // Ensure that `path` attributes on modules are recorded as used (cf. issue #35584). attr::first_attr_value_str_by_name(&item.attrs, sym::path); - if attr::contains_name(&item.attrs, sym::warn_directory_ownership) { - let lint = lint::builtin::LEGACY_DIRECTORY_OWNERSHIP; - let msg = "cannot declare a new module at this location"; - self.lint_buffer.buffer_lint(lint, item.id, item.span, msg); - } } ItemKind::Union(ref vdata, _) => { if let VariantData::Tuple(..) | VariantData::Unit(..) = vdata { diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs index 6d8ecdf805b..59f4a4d22d6 100644 --- a/src/libsyntax/parse/mod.rs +++ b/src/libsyntax/parse/mod.rs @@ -51,7 +51,7 @@ pub enum DirectoryOwnership { relative: Option, }, UnownedViaBlock, - UnownedViaMod(bool /* legacy warnings? */), + UnownedViaMod, } // A bunch of utility functions of the form `parse__from_` diff --git a/src/libsyntax/parse/parser/module.rs b/src/libsyntax/parse/parser/module.rs index 242a17659a0..958cdae9492 100644 --- a/src/libsyntax/parse/parser/module.rs +++ b/src/libsyntax/parse/parser/module.rs @@ -21,7 +21,6 @@ pub(super) struct ModulePath { pub(super) struct ModulePathSuccess { pub path: PathBuf, pub directory_ownership: DirectoryOwnership, - warn: bool, } impl<'a> Parser<'a> { @@ -55,17 +54,10 @@ pub(super) fn parse_item_mod(&mut self, outer_attrs: &[Attribute]) -> PResult<'a if self.eat(&token::Semi) { if in_cfg && self.recurse_into_file_modules { // This mod is in an external file. Let's go get it! - let ModulePathSuccess { path, directory_ownership, warn } = + let ModulePathSuccess { path, directory_ownership } = self.submod_path(id, &outer_attrs, id_span)?; - let (module, mut attrs) = + let (module, attrs) = self.eval_src_mod(path, directory_ownership, id.to_string(), id_span)?; - // Record that we fetched the mod from an external file. - if warn { - let attr = attr::mk_attr_outer( - attr::mk_word_item(Ident::with_dummy_span(sym::warn_directory_ownership))); - attr::mark_known(&attr); - attrs.push(attr); - } Ok((id, ItemKind::Mod(module), Some(attrs))) } else { let placeholder = ast::Mod { @@ -136,17 +128,16 @@ fn submod_path( // `#[path]` included and contains a `mod foo;` declaration. // If you encounter this, it's your own darn fault :P Some(_) => DirectoryOwnership::Owned { relative: None }, - _ => DirectoryOwnership::UnownedViaMod(true), + _ => DirectoryOwnership::UnownedViaMod, }, path, - warn: false, }); } let relative = match self.directory.ownership { DirectoryOwnership::Owned { relative } => relative, DirectoryOwnership::UnownedViaBlock | - DirectoryOwnership::UnownedViaMod(_) => None, + DirectoryOwnership::UnownedViaMod => None, }; let paths = Parser::default_submod_path( id, relative, &self.directory.path, self.sess.source_map()); @@ -167,12 +158,7 @@ fn submod_path( } Err(err) } - DirectoryOwnership::UnownedViaMod(warn) => { - if warn { - if let Ok(result) = paths.result { - return Ok(ModulePathSuccess { warn: true, ..result }); - } - } + DirectoryOwnership::UnownedViaMod => { let mut err = self.diagnostic().struct_span_err(id_sp, "cannot declare a new module at this location"); if !id_sp.is_dummy() { @@ -250,14 +236,12 @@ pub(super) fn default_submod_path( directory_ownership: DirectoryOwnership::Owned { relative: Some(id), }, - warn: false, }), (false, true) => Ok(ModulePathSuccess { path: secondary_path, directory_ownership: DirectoryOwnership::Owned { relative: None, }, - warn: false, }), (false, false) => Err(Error::FileNotFoundForModule { mod_name: mod_name.clone(), diff --git a/src/libsyntax_expand/expand.rs b/src/libsyntax_expand/expand.rs index da70fdbb0f3..8c82e59e528 100644 --- a/src/libsyntax_expand/expand.rs +++ b/src/libsyntax_expand/expand.rs @@ -1300,7 +1300,7 @@ fn visit_block(&mut self, block: &mut P) { Some(_) => DirectoryOwnership::Owned { relative: Some(item.ident), }, - None => DirectoryOwnership::UnownedViaMod(false), + None => DirectoryOwnership::UnownedViaMod, }; path.pop(); module.directory = path; diff --git a/src/libsyntax_pos/symbol.rs b/src/libsyntax_pos/symbol.rs index 3f7b3e5b3d8..d834a59b486 100644 --- a/src/libsyntax_pos/symbol.rs +++ b/src/libsyntax_pos/symbol.rs @@ -734,7 +734,6 @@ visible_private_types, volatile, warn, - warn_directory_ownership, wasm_import_module, wasm_target_feature, while_let, From 98d2c510dd121d31061ae95b41a5afb3386d17e3 Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Sat, 3 Aug 2019 19:34:21 +0200 Subject: [PATCH 03/15] safe_extern_static -> error --- .../src/lints/listing/deny-by-default.md | 5 --- src/librustc/lint/builtin.rs | 11 ----- src/librustc/mir/mod.rs | 1 - src/librustc_lint/lib.rs | 2 + src/librustc_mir/transform/check_unsafety.rs | 43 +++++++------------ src/test/ui/issues/issue-14227.rs | 5 +-- src/test/ui/issues/issue-14227.stderr | 10 +++-- src/test/ui/issues/issue-16538.rs | 3 +- src/test/ui/issues/issue-16538.stderr | 16 +++++-- src/test/ui/issues/issue-28324.rs | 5 +-- src/test/ui/issues/issue-28324.stderr | 10 +++-- src/test/ui/safe-extern-statics.rs | 6 --- src/test/ui/safe-extern-statics.stderr | 34 ++++++--------- 13 files changed, 57 insertions(+), 94 deletions(-) diff --git a/src/doc/rustc/src/lints/listing/deny-by-default.md b/src/doc/rustc/src/lints/listing/deny-by-default.md index f175a881fef..b349c68359c 100644 --- a/src/doc/rustc/src/lints/listing/deny-by-default.md +++ b/src/doc/rustc/src/lints/listing/deny-by-default.md @@ -151,11 +151,6 @@ To fix it, remove the `()`s. This lint detects a specific situation of re-exporting a private `extern crate`; -## safe-extern-statics - -In older versions of Rust, there was a soundness issue where `extern static`s were allowed -to be accessed in safe code. This lint now catches and denies this kind of code. - ## unknown-crate-types This lint detects an unknown crate type found in a `#[crate_type]` directive. Some diff --git a/src/librustc/lint/builtin.rs b/src/librustc/lint/builtin.rs index 9301dac32cd..c1957df2e62 100644 --- a/src/librustc/lint/builtin.rs +++ b/src/librustc/lint/builtin.rs @@ -177,16 +177,6 @@ "lints that have been renamed or removed" } -declare_lint! { - pub SAFE_EXTERN_STATICS, - Deny, - "safe access to extern statics was erroneously allowed", - @future_incompatible = FutureIncompatibleInfo { - reference: "issue #36247 ", - edition: None, - }; -} - declare_lint! { pub SAFE_PACKED_BORROWS, Warn, @@ -535,7 +525,6 @@ pub mod parser { INVALID_TYPE_PARAM_DEFAULT, CONST_ERR, RENAMED_AND_REMOVED_LINTS, - SAFE_EXTERN_STATICS, SAFE_PACKED_BORROWS, PATTERNS_IN_FNS_WITHOUT_BODY, MISSING_FRAGMENT_SPECIFIER, diff --git a/src/librustc/mir/mod.rs b/src/librustc/mir/mod.rs index f7e0d0131de..2eaf05beb2e 100644 --- a/src/librustc/mir/mod.rs +++ b/src/librustc/mir/mod.rs @@ -2701,7 +2701,6 @@ pub enum UnsafetyViolationKind { General, /// Permitted both in `const fn`s and regular `fn`s. GeneralAndConstFn, - ExternStatic(hir::HirId), BorrowPacked(hir::HirId), } diff --git a/src/librustc_lint/lib.rs b/src/librustc_lint/lib.rs index 1dcd61896c3..5c10399d7db 100644 --- a/src/librustc_lint/lib.rs +++ b/src/librustc_lint/lib.rs @@ -338,6 +338,8 @@ macro_rules! register_passes { "converted into hard error, see https://github.com/rust-lang/rust/issues/39207"); store.register_removed("legacy_disrectory_ownership", "converted into hard error, see https://github.com/rust-lang/rust/issues/37872"); + store.register_removed("safe_extern_statics", + "converted into hard error, see https://github.com/rust-lang/rust/issues/36247"); } fn register_internals(store: &mut lint::LintStore) { diff --git a/src/librustc_mir/transform/check_unsafety.rs b/src/librustc_mir/transform/check_unsafety.rs index 7d550716858..9dc4fdf5308 100644 --- a/src/librustc_mir/transform/check_unsafety.rs +++ b/src/librustc_mir/transform/check_unsafety.rs @@ -8,7 +8,7 @@ use rustc::hir; use rustc::hir::Node; use rustc::hir::def_id::DefId; -use rustc::lint::builtin::{SAFE_EXTERN_STATICS, SAFE_PACKED_BORROWS, UNUSED_UNSAFE}; +use rustc::lint::builtin::{SAFE_PACKED_BORROWS, UNUSED_UNSAFE}; use rustc::mir::*; use rustc::mir::visit::{PlaceContext, Visitor, MutatingUseContext}; @@ -208,23 +208,20 @@ fn visit_place(&mut self, } PlaceBase::Static(box Static { kind: StaticKind::Static, def_id, .. }) => { if self.tcx.is_mutable_static(def_id) { - self.require_unsafe("use of mutable static", + self.require_unsafe( + "use of mutable static", "mutable statics can be mutated by multiple threads: aliasing \ - violations or data races will cause undefined behavior", - UnsafetyViolationKind::General); + violations or data races will cause undefined behavior", + UnsafetyViolationKind::General, + ); } else if self.tcx.is_foreign_item(def_id) { - let source_info = self.source_info; - let lint_root = - self.source_scope_local_data[source_info.scope].lint_root; - self.register_violations(&[UnsafetyViolation { - source_info, - description: Symbol::intern("use of extern static"), - details: Symbol::intern( - "extern statics are not controlled by the Rust type system: \ - invalid data, aliasing violations or data races will cause \ - undefined behavior"), - kind: UnsafetyViolationKind::ExternStatic(lint_root) - }], &[]); + self.require_unsafe( + "use of extern static", + "extern statics are not controlled by the Rust type system: \ + invalid data, aliasing violations or data races will cause \ + undefined behavior", + UnsafetyViolationKind::General, + ); } } } @@ -351,8 +348,7 @@ fn register_violations(&mut self, match violation.kind { UnsafetyViolationKind::GeneralAndConstFn | UnsafetyViolationKind::General => {}, - UnsafetyViolationKind::BorrowPacked(_) | - UnsafetyViolationKind::ExternStatic(_) => if self.min_const_fn { + UnsafetyViolationKind::BorrowPacked(_) => if self.min_const_fn { // const fns don't need to be backwards compatible and can // emit these violations as a hard error instead of a backwards // compat lint @@ -380,8 +376,7 @@ fn register_violations(&mut self, UnsafetyViolationKind::GeneralAndConstFn => {}, // these things are forbidden in const fns UnsafetyViolationKind::General | - UnsafetyViolationKind::BorrowPacked(_) | - UnsafetyViolationKind::ExternStatic(_) => { + UnsafetyViolationKind::BorrowPacked(_) => { let mut violation = violation.clone(); // const fns don't need to be backwards compatible and can // emit these violations as a hard error instead of a backwards @@ -646,14 +641,6 @@ pub fn check_unsafety(tcx: TyCtxt<'_>, def_id: DefId) { .note(&details.as_str()) .emit(); } - UnsafetyViolationKind::ExternStatic(lint_hir_id) => { - tcx.lint_node_note(SAFE_EXTERN_STATICS, - lint_hir_id, - source_info.span, - &format!("{} is unsafe and requires unsafe function or block \ - (error E0133)", description), - &details.as_str()); - } UnsafetyViolationKind::BorrowPacked(lint_hir_id) => { if let Some(impl_def_id) = builtin_derive_def_id(tcx, def_id) { tcx.unsafe_derive_on_repr_packed(impl_def_id); diff --git a/src/test/ui/issues/issue-14227.rs b/src/test/ui/issues/issue-14227.rs index 5de3867f95c..d80eefc41bf 100644 --- a/src/test/ui/issues/issue-14227.rs +++ b/src/test/ui/issues/issue-14227.rs @@ -1,10 +1,7 @@ -#![allow(safe_extern_statics, warnings)] - extern { pub static symbol: u32; } static CRASH: u32 = symbol; -//~^ ERROR could not evaluate static initializer -//~| tried to read from foreign (extern) static +//~^ ERROR use of extern static is unsafe and requires fn main() {} diff --git a/src/test/ui/issues/issue-14227.stderr b/src/test/ui/issues/issue-14227.stderr index 88e99e213bf..f9cdbe452df 100644 --- a/src/test/ui/issues/issue-14227.stderr +++ b/src/test/ui/issues/issue-14227.stderr @@ -1,9 +1,11 @@ -error[E0080]: could not evaluate static initializer - --> $DIR/issue-14227.rs:6:21 +error[E0133]: use of extern static is unsafe and requires unsafe function or block + --> $DIR/issue-14227.rs:4:21 | LL | static CRASH: u32 = symbol; - | ^^^^^^ tried to read from foreign (extern) static + | ^^^^^^ use of extern static + | + = note: extern statics are not controlled by the Rust type system: invalid data, aliasing violations or data races will cause undefined behavior error: aborting due to previous error -For more information about this error, try `rustc --explain E0080`. +For more information about this error, try `rustc --explain E0133`. diff --git a/src/test/ui/issues/issue-16538.rs b/src/test/ui/issues/issue-16538.rs index a990c078a79..54d9a732912 100644 --- a/src/test/ui/issues/issue-16538.rs +++ b/src/test/ui/issues/issue-16538.rs @@ -1,5 +1,3 @@ -#![allow(safe_extern_statics)] - mod Y { pub type X = usize; extern { @@ -13,5 +11,6 @@ pub fn foo(value: *const X) -> *const X { static foo: *const Y::X = Y::foo(Y::x as *const Y::X); //~^ ERROR `*const usize` cannot be shared between threads safely [E0277] //~| ERROR E0015 +//~| ERROR use of extern static is unsafe and requires fn main() {} diff --git a/src/test/ui/issues/issue-16538.stderr b/src/test/ui/issues/issue-16538.stderr index 2d8b5bf2f6f..5e1f95a989e 100644 --- a/src/test/ui/issues/issue-16538.stderr +++ b/src/test/ui/issues/issue-16538.stderr @@ -1,11 +1,11 @@ error[E0015]: calls in statics are limited to constant functions, tuple structs and tuple variants - --> $DIR/issue-16538.rs:13:27 + --> $DIR/issue-16538.rs:11:27 | LL | static foo: *const Y::X = Y::foo(Y::x as *const Y::X); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0277]: `*const usize` cannot be shared between threads safely - --> $DIR/issue-16538.rs:13:1 + --> $DIR/issue-16538.rs:11:1 | LL | static foo: *const Y::X = Y::foo(Y::x as *const Y::X); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `*const usize` cannot be shared between threads safely @@ -13,7 +13,15 @@ LL | static foo: *const Y::X = Y::foo(Y::x as *const Y::X); = help: the trait `std::marker::Sync` is not implemented for `*const usize` = note: shared static variables must have a type that implements `Sync` -error: aborting due to 2 previous errors +error[E0133]: use of extern static is unsafe and requires unsafe function or block + --> $DIR/issue-16538.rs:11:34 + | +LL | static foo: *const Y::X = Y::foo(Y::x as *const Y::X); + | ^^^^ use of extern static + | + = note: extern statics are not controlled by the Rust type system: invalid data, aliasing violations or data races will cause undefined behavior -Some errors have detailed explanations: E0015, E0277. +error: aborting due to 3 previous errors + +Some errors have detailed explanations: E0015, E0133, E0277. For more information about an error, try `rustc --explain E0015`. diff --git a/src/test/ui/issues/issue-28324.rs b/src/test/ui/issues/issue-28324.rs index 73e8cd6ab0d..bb48508a4a4 100644 --- a/src/test/ui/issues/issue-28324.rs +++ b/src/test/ui/issues/issue-28324.rs @@ -1,11 +1,8 @@ -#![allow(safe_extern_statics)] - extern { static error_message_count: u32; } pub static BAZ: u32 = *&error_message_count; -//~^ ERROR could not evaluate static initializer -//~| tried to read from foreign (extern) static +//~^ ERROR use of extern static is unsafe and requires fn main() {} diff --git a/src/test/ui/issues/issue-28324.stderr b/src/test/ui/issues/issue-28324.stderr index bbd02ba03f4..d7dad992152 100644 --- a/src/test/ui/issues/issue-28324.stderr +++ b/src/test/ui/issues/issue-28324.stderr @@ -1,9 +1,11 @@ -error[E0080]: could not evaluate static initializer - --> $DIR/issue-28324.rs:7:23 +error[E0133]: use of extern static is unsafe and requires unsafe function or block + --> $DIR/issue-28324.rs:5:24 | LL | pub static BAZ: u32 = *&error_message_count; - | ^^^^^^^^^^^^^^^^^^^^^ tried to read from foreign (extern) static + | ^^^^^^^^^^^^^^^^^^^^ use of extern static + | + = note: extern statics are not controlled by the Rust type system: invalid data, aliasing violations or data races will cause undefined behavior error: aborting due to previous error -For more information about this error, try `rustc --explain E0080`. +For more information about this error, try `rustc --explain E0133`. diff --git a/src/test/ui/safe-extern-statics.rs b/src/test/ui/safe-extern-statics.rs index eda30944468..0535a078d2c 100644 --- a/src/test/ui/safe-extern-statics.rs +++ b/src/test/ui/safe-extern-statics.rs @@ -1,7 +1,5 @@ // aux-build:extern-statics.rs -#![allow(unused)] - extern crate extern_statics; use extern_statics::*; @@ -11,11 +9,7 @@ fn main() { let a = A; //~ ERROR use of extern static is unsafe - //~^ WARN this was previously accepted by the compiler let ra = &A; //~ ERROR use of extern static is unsafe - //~^ WARN this was previously accepted by the compiler let xa = XA; //~ ERROR use of extern static is unsafe - //~^ WARN this was previously accepted by the compiler let xra = &XA; //~ ERROR use of extern static is unsafe - //~^ WARN this was previously accepted by the compiler } diff --git a/src/test/ui/safe-extern-statics.stderr b/src/test/ui/safe-extern-statics.stderr index 0948fad74e5..b42572ea3ee 100644 --- a/src/test/ui/safe-extern-statics.stderr +++ b/src/test/ui/safe-extern-statics.stderr @@ -1,43 +1,35 @@ -error: use of extern static is unsafe and requires unsafe function or block (error E0133) - --> $DIR/safe-extern-statics.rs:13:13 +error[E0133]: use of extern static is unsafe and requires unsafe function or block + --> $DIR/safe-extern-statics.rs:11:13 | LL | let a = A; - | ^ + | ^ use of extern static | - = note: `#[deny(safe_extern_statics)]` on by default - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #36247 = note: extern statics are not controlled by the Rust type system: invalid data, aliasing violations or data races will cause undefined behavior -error: use of extern static is unsafe and requires unsafe function or block (error E0133) - --> $DIR/safe-extern-statics.rs:15:14 +error[E0133]: use of extern static is unsafe and requires unsafe function or block + --> $DIR/safe-extern-statics.rs:12:14 | LL | let ra = &A; - | ^^ + | ^^ use of extern static | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #36247 = note: extern statics are not controlled by the Rust type system: invalid data, aliasing violations or data races will cause undefined behavior -error: use of extern static is unsafe and requires unsafe function or block (error E0133) - --> $DIR/safe-extern-statics.rs:17:14 +error[E0133]: use of extern static is unsafe and requires unsafe function or block + --> $DIR/safe-extern-statics.rs:13:14 | LL | let xa = XA; - | ^^ + | ^^ use of extern static | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #36247 = note: extern statics are not controlled by the Rust type system: invalid data, aliasing violations or data races will cause undefined behavior -error: use of extern static is unsafe and requires unsafe function or block (error E0133) - --> $DIR/safe-extern-statics.rs:19:15 +error[E0133]: use of extern static is unsafe and requires unsafe function or block + --> $DIR/safe-extern-statics.rs:14:15 | LL | let xra = &XA; - | ^^^ + | ^^^ use of extern static | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #36247 = note: extern statics are not controlled by the Rust type system: invalid data, aliasing violations or data races will cause undefined behavior error: aborting due to 4 previous errors +For more information about this error, try `rustc --explain E0133`. From b54c5781b8252189f04a58247f644bcf2bd9dd68 Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Sat, 3 Aug 2019 19:58:26 +0200 Subject: [PATCH 04/15] parenthesized_params_in_types_and_modules -> error --- .../src/lints/listing/deny-by-default.md | 25 ------- src/librustc/hir/lowering.rs | 39 +++-------- src/librustc/lint/builtin.rs | 11 ---- src/librustc_lint/lib.rs | 2 + src/test/ui/issues/issue-32995-2.rs | 5 -- src/test/ui/issues/issue-32995-2.stderr | 29 +++------ src/test/ui/issues/issue-32995.rs | 9 --- src/test/ui/issues/issue-32995.stderr | 65 +++++++------------ .../let-binding-init-expr-as-ty.rs | 2 +- .../let-binding-init-expr-as-ty.stderr | 19 ++++-- src/test/ui/type/ascription/issue-34255-1.rs | 1 - .../ui/type/ascription/issue-34255-1.stderr | 10 +-- 12 files changed, 59 insertions(+), 158 deletions(-) diff --git a/src/doc/rustc/src/lints/listing/deny-by-default.md b/src/doc/rustc/src/lints/listing/deny-by-default.md index b349c68359c..466a748bcee 100644 --- a/src/doc/rustc/src/lints/listing/deny-by-default.md +++ b/src/doc/rustc/src/lints/listing/deny-by-default.md @@ -122,31 +122,6 @@ error: literal out of range for u8 | ``` -## parenthesized-params-in-types-and-modules - -This lint detects incorrect parentheses. Some example code that triggers this -lint: - -```rust,ignore -let x = 5 as usize(); -``` - -This will produce: - -```text -error: parenthesized parameters may only be used with a trait - --> src/main.rs:2:21 - | -2 | let x = 5 as usize(); - | ^^ - | - = note: `#[deny(parenthesized_params_in_types_and_modules)]` on by default - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #42238 -``` - -To fix it, remove the `()`s. - ## pub-use-of-private-extern-crate This lint detects a specific situation of re-exporting a private `extern crate`; diff --git a/src/librustc/hir/lowering.rs b/src/librustc/hir/lowering.rs index c8bb35202f5..9f5e5fae07f 100644 --- a/src/librustc/hir/lowering.rs +++ b/src/librustc/hir/lowering.rs @@ -44,8 +44,7 @@ use crate::hir::{GenericArg, ConstArg}; use crate::hir::ptr::P; use crate::lint; -use crate::lint::builtin::{self, PARENTHESIZED_PARAMS_IN_TYPES_AND_MODULES, - ELIDED_LIFETIMES_IN_PATHS}; +use crate::lint::builtin::{self, ELIDED_LIFETIMES_IN_PATHS}; use crate::middle::cstore::CrateStore; use crate::session::Session; use crate::session::config::nightly_options; @@ -298,7 +297,6 @@ enum ParamMode { enum ParenthesizedGenericArgs { Ok, - Warn, Err, } @@ -1695,29 +1693,19 @@ fn lower_qpath( }; let parenthesized_generic_args = match partial_res.base_res() { // `a::b::Trait(Args)` - Res::Def(DefKind::Trait, _) - if i + 1 == proj_start => ParenthesizedGenericArgs::Ok, + Res::Def(DefKind::Trait, _) if i + 1 == proj_start => { + ParenthesizedGenericArgs::Ok + } // `a::b::Trait(Args)::TraitItem` - Res::Def(DefKind::Method, _) - | Res::Def(DefKind::AssocConst, _) - | Res::Def(DefKind::AssocTy, _) - if i + 2 == proj_start => - { + Res::Def(DefKind::Method, _) | + Res::Def(DefKind::AssocConst, _) | + Res::Def(DefKind::AssocTy, _) if i + 2 == proj_start => { ParenthesizedGenericArgs::Ok } // Avoid duplicated errors. Res::Err => ParenthesizedGenericArgs::Ok, // An error - Res::Def(DefKind::Struct, _) - | Res::Def(DefKind::Enum, _) - | Res::Def(DefKind::Union, _) - | Res::Def(DefKind::TyAlias, _) - | Res::Def(DefKind::Variant, _) if i + 1 == proj_start => - { - ParenthesizedGenericArgs::Err - } - // A warning for now, for compatibility reasons. - _ => ParenthesizedGenericArgs::Warn, + _ => ParenthesizedGenericArgs::Err, }; let num_lifetimes = type_def_id.map_or(0, |def_id| { @@ -1780,7 +1768,7 @@ fn lower_qpath( segment, param_mode, 0, - ParenthesizedGenericArgs::Warn, + ParenthesizedGenericArgs::Err, itctx.reborrow(), None, )); @@ -1856,15 +1844,6 @@ fn lower_path_segment( } GenericArgs::Parenthesized(ref data) => match parenthesized_generic_args { ParenthesizedGenericArgs::Ok => self.lower_parenthesized_parameter_data(data), - ParenthesizedGenericArgs::Warn => { - self.resolver.lint_buffer().buffer_lint( - PARENTHESIZED_PARAMS_IN_TYPES_AND_MODULES, - CRATE_NODE_ID, - data.span, - msg.into(), - ); - (hir::GenericArgs::none(), true) - } ParenthesizedGenericArgs::Err => { let mut err = struct_span_err!(self.sess, data.span, E0214, "{}", msg); err.span_label(data.span, "only `Fn` traits may use parentheses"); diff --git a/src/librustc/lint/builtin.rs b/src/librustc/lint/builtin.rs index c1957df2e62..c9dd60827ff 100644 --- a/src/librustc/lint/builtin.rs +++ b/src/librustc/lint/builtin.rs @@ -207,16 +207,6 @@ }; } -declare_lint! { - pub PARENTHESIZED_PARAMS_IN_TYPES_AND_MODULES, - Deny, - "detects parenthesized generic parameters in type and module names", - @future_incompatible = FutureIncompatibleInfo { - reference: "issue #42238 ", - edition: None, - }; -} - declare_lint! { pub LATE_BOUND_LIFETIME_ARGUMENTS, Warn, @@ -528,7 +518,6 @@ pub mod parser { SAFE_PACKED_BORROWS, PATTERNS_IN_FNS_WITHOUT_BODY, MISSING_FRAGMENT_SPECIFIER, - PARENTHESIZED_PARAMS_IN_TYPES_AND_MODULES, LATE_BOUND_LIFETIME_ARGUMENTS, ORDER_DEPENDENT_TRAIT_OBJECTS, DEPRECATED, diff --git a/src/librustc_lint/lib.rs b/src/librustc_lint/lib.rs index 5c10399d7db..c3c5589b9d0 100644 --- a/src/librustc_lint/lib.rs +++ b/src/librustc_lint/lib.rs @@ -340,6 +340,8 @@ macro_rules! register_passes { "converted into hard error, see https://github.com/rust-lang/rust/issues/37872"); store.register_removed("safe_extern_statics", "converted into hard error, see https://github.com/rust-lang/rust/issues/36247"); + store.register_removed("parenthesized_params_in_types_and_modules", + "converted into hard error, see https://github.com/rust-lang/rust/issues/42238"); } fn register_internals(store: &mut lint::LintStore) { diff --git a/src/test/ui/issues/issue-32995-2.rs b/src/test/ui/issues/issue-32995-2.rs index 2234f68f246..e713a64d3f5 100644 --- a/src/test/ui/issues/issue-32995-2.rs +++ b/src/test/ui/issues/issue-32995-2.rs @@ -1,13 +1,9 @@ -#![allow(unused)] - fn main() { { fn f() {} } //~^ ERROR parenthesized type parameters may only be used with a `Fn` trait - //~| WARN previously accepted { fn f() -> impl ::std::marker()::Send { } } //~^ ERROR parenthesized type parameters may only be used with a `Fn` trait - //~| WARN previously accepted } #[derive(Clone)] @@ -15,4 +11,3 @@ fn main() { impl ::std::marker()::Copy for X {} //~^ ERROR parenthesized type parameters may only be used with a `Fn` trait -//~| WARN previously accepted diff --git a/src/test/ui/issues/issue-32995-2.stderr b/src/test/ui/issues/issue-32995-2.stderr index 976e3064db6..6c2d772a233 100644 --- a/src/test/ui/issues/issue-32995-2.stderr +++ b/src/test/ui/issues/issue-32995-2.stderr @@ -1,30 +1,21 @@ -error: parenthesized type parameters may only be used with a `Fn` trait - --> $DIR/issue-32995-2.rs:4:22 +error[E0214]: parenthesized type parameters may only be used with a `Fn` trait + --> $DIR/issue-32995-2.rs:2:22 | LL | { fn f() {} } - | ^^^^^^^^ - | - = note: `#[deny(parenthesized_params_in_types_and_modules)]` on by default - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #42238 + | ^^^^^^^^ only `Fn` traits may use parentheses -error: parenthesized type parameters may only be used with a `Fn` trait - --> $DIR/issue-32995-2.rs:8:29 +error[E0214]: parenthesized type parameters may only be used with a `Fn` trait + --> $DIR/issue-32995-2.rs:5:29 | LL | { fn f() -> impl ::std::marker()::Send { } } - | ^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #42238 + | ^^^^^^^^ only `Fn` traits may use parentheses -error: parenthesized type parameters may only be used with a `Fn` trait - --> $DIR/issue-32995-2.rs:16:13 +error[E0214]: parenthesized type parameters may only be used with a `Fn` trait + --> $DIR/issue-32995-2.rs:12:13 | LL | impl ::std::marker()::Copy for X {} - | ^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #42238 + | ^^^^^^^^ only `Fn` traits may use parentheses error: aborting due to 3 previous errors +For more information about this error, try `rustc --explain E0214`. diff --git a/src/test/ui/issues/issue-32995.rs b/src/test/ui/issues/issue-32995.rs index 3526deffc79..0d07a76939f 100644 --- a/src/test/ui/issues/issue-32995.rs +++ b/src/test/ui/issues/issue-32995.rs @@ -1,33 +1,24 @@ -#![allow(unused)] - fn main() { let x: usize() = 1; //~^ ERROR parenthesized type parameters may only be used with a `Fn` trait - //~| WARN previously accepted let b: ::std::boxed()::Box<_> = Box::new(1); //~^ ERROR parenthesized type parameters may only be used with a `Fn` trait - //~| WARN previously accepted let p = ::std::str::()::from_utf8(b"foo").unwrap(); //~^ ERROR parenthesized type parameters may only be used with a `Fn` trait - //~| WARN previously accepted let p = ::std::str::from_utf8::()(b"foo").unwrap(); //~^ ERROR parenthesized type parameters may only be used with a `Fn` trait - //~| WARN previously accepted let o : Box = Box::new(1); //~^ ERROR parenthesized type parameters may only be used with a `Fn` trait - //~| WARN previously accepted let o : Box = Box::new(1); //~^ ERROR parenthesized type parameters may only be used with a `Fn` trait - //~| WARN previously accepted } fn foo() { let d : X() = Default::default(); //~^ ERROR parenthesized type parameters may only be used with a `Fn` trait - //~| WARN previously accepted } diff --git a/src/test/ui/issues/issue-32995.stderr b/src/test/ui/issues/issue-32995.stderr index 724e82a59dc..b868011b99b 100644 --- a/src/test/ui/issues/issue-32995.stderr +++ b/src/test/ui/issues/issue-32995.stderr @@ -1,66 +1,45 @@ -error: parenthesized type parameters may only be used with a `Fn` trait - --> $DIR/issue-32995.rs:4:12 +error[E0214]: parenthesized type parameters may only be used with a `Fn` trait + --> $DIR/issue-32995.rs:2:12 | LL | let x: usize() = 1; - | ^^^^^^^ - | - = note: `#[deny(parenthesized_params_in_types_and_modules)]` on by default - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #42238 + | ^^^^^^^ only `Fn` traits may use parentheses -error: parenthesized type parameters may only be used with a `Fn` trait - --> $DIR/issue-32995.rs:8:19 +error[E0214]: parenthesized type parameters may only be used with a `Fn` trait + --> $DIR/issue-32995.rs:5:19 | LL | let b: ::std::boxed()::Box<_> = Box::new(1); - | ^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #42238 + | ^^^^^^^ only `Fn` traits may use parentheses -error: parenthesized type parameters may only be used with a `Fn` trait - --> $DIR/issue-32995.rs:12:20 +error[E0214]: parenthesized type parameters may only be used with a `Fn` trait + --> $DIR/issue-32995.rs:8:20 | LL | let p = ::std::str::()::from_utf8(b"foo").unwrap(); - | ^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #42238 + | ^^^^^^^ only `Fn` traits may use parentheses -error: parenthesized type parameters may only be used with a `Fn` trait - --> $DIR/issue-32995.rs:16:25 +error[E0214]: parenthesized type parameters may only be used with a `Fn` trait + --> $DIR/issue-32995.rs:11:25 | LL | let p = ::std::str::from_utf8::()(b"foo").unwrap(); - | ^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #42238 + | ^^^^^^^^^^^^^ only `Fn` traits may use parentheses -error: parenthesized type parameters may only be used with a `Fn` trait - --> $DIR/issue-32995.rs:20:29 +error[E0214]: parenthesized type parameters may only be used with a `Fn` trait + --> $DIR/issue-32995.rs:14:29 | LL | let o : Box = Box::new(1); - | ^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #42238 + | ^^^^^^^^ only `Fn` traits may use parentheses -error: parenthesized type parameters may only be used with a `Fn` trait - --> $DIR/issue-32995.rs:24:35 +error[E0214]: parenthesized type parameters may only be used with a `Fn` trait + --> $DIR/issue-32995.rs:17:35 | LL | let o : Box = Box::new(1); - | ^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #42238 + | ^^^^^^^^ only `Fn` traits may use parentheses -error: parenthesized type parameters may only be used with a `Fn` trait - --> $DIR/issue-32995.rs:30:13 +error[E0214]: parenthesized type parameters may only be used with a `Fn` trait + --> $DIR/issue-32995.rs:22:13 | LL | let d : X() = Default::default(); - | ^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #42238 + | ^^^ only `Fn` traits may use parentheses error: aborting due to 7 previous errors +For more information about this error, try `rustc --explain E0214`. diff --git a/src/test/ui/suggestions/let-binding-init-expr-as-ty.rs b/src/test/ui/suggestions/let-binding-init-expr-as-ty.rs index beea951a18a..94c72a31e5e 100644 --- a/src/test/ui/suggestions/let-binding-init-expr-as-ty.rs +++ b/src/test/ui/suggestions/let-binding-init-expr-as-ty.rs @@ -1,9 +1,9 @@ pub fn foo(num: i32) -> i32 { let foo: i32::from_be(num); //~^ ERROR expected type, found local variable `num` + //~| ERROR type arguments are not allowed for this type //~| ERROR parenthesized type parameters may only be used with a `Fn` trait //~| ERROR ambiguous associated type - //~| WARNING this was previously accepted by the compiler but is being phased out foo } diff --git a/src/test/ui/suggestions/let-binding-init-expr-as-ty.stderr b/src/test/ui/suggestions/let-binding-init-expr-as-ty.stderr index a7c784fe827..5353b3a75b2 100644 --- a/src/test/ui/suggestions/let-binding-init-expr-as-ty.stderr +++ b/src/test/ui/suggestions/let-binding-init-expr-as-ty.stderr @@ -6,15 +6,20 @@ LL | let foo: i32::from_be(num); | | | help: use `=` if you meant to assign -error: parenthesized type parameters may only be used with a `Fn` trait +error[E0214]: parenthesized type parameters may only be used with a `Fn` trait --> $DIR/let-binding-init-expr-as-ty.rs:2:19 | LL | let foo: i32::from_be(num); | ^^^^^^^^^^^^ + | | + | only `Fn` traits may use parentheses + | help: use angle brackets instead: `from_be` + +error[E0109]: type arguments are not allowed for this type + --> $DIR/let-binding-init-expr-as-ty.rs:2:27 | - = note: `#[deny(parenthesized_params_in_types_and_modules)]` on by default - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #42238 +LL | let foo: i32::from_be(num); + | ^^^ type argument not allowed error[E0223]: ambiguous associated type --> $DIR/let-binding-init-expr-as-ty.rs:2:14 @@ -22,7 +27,7 @@ error[E0223]: ambiguous associated type LL | let foo: i32::from_be(num); | ^^^^^^^^^^^^^^^^^ help: use fully-qualified syntax: `::from_be` -error: aborting due to 3 previous errors +error: aborting due to 4 previous errors -Some errors have detailed explanations: E0223, E0573. -For more information about an error, try `rustc --explain E0223`. +Some errors have detailed explanations: E0109, E0214, E0223, E0573. +For more information about an error, try `rustc --explain E0109`. diff --git a/src/test/ui/type/ascription/issue-34255-1.rs b/src/test/ui/type/ascription/issue-34255-1.rs index c21d9f3d97c..c0d39c59014 100644 --- a/src/test/ui/type/ascription/issue-34255-1.rs +++ b/src/test/ui/type/ascription/issue-34255-1.rs @@ -8,7 +8,6 @@ pub fn new() -> Self { //~^ ERROR cannot find value `input_cells` in this scope //~| ERROR parenthesized type parameters may only be used with a `Fn` trait //~| ERROR wrong number of type arguments: expected 1, found 0 - //~| WARNING this was previously accepted by the compiler but is being phased out } } diff --git a/src/test/ui/type/ascription/issue-34255-1.stderr b/src/test/ui/type/ascription/issue-34255-1.stderr index 0d0acfde886..7895cf77fc0 100644 --- a/src/test/ui/type/ascription/issue-34255-1.stderr +++ b/src/test/ui/type/ascription/issue-34255-1.stderr @@ -4,15 +4,11 @@ error[E0425]: cannot find value `input_cells` in this scope LL | input_cells: Vec::new() | ^^^^^^^^^^^ a field by this name exists in `Self` -error: parenthesized type parameters may only be used with a `Fn` trait +error[E0214]: parenthesized type parameters may only be used with a `Fn` trait --> $DIR/issue-34255-1.rs:7:27 | LL | input_cells: Vec::new() - | ^^^^^ - | - = note: `#[deny(parenthesized_params_in_types_and_modules)]` on by default - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #42238 + | ^^^^^ only `Fn` traits may use parentheses error[E0107]: wrong number of type arguments: expected 1, found 0 --> $DIR/issue-34255-1.rs:7:22 @@ -22,5 +18,5 @@ LL | input_cells: Vec::new() error: aborting due to 3 previous errors -Some errors have detailed explanations: E0107, E0425. +Some errors have detailed explanations: E0107, E0214, E0425. For more information about an error, try `rustc --explain E0107`. From 8e27c4f3122c2ccb529ee3911a9d7e956f2462cd Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Sat, 3 Aug 2019 20:29:45 +0200 Subject: [PATCH 05/15] duplicate_macro_exports -> error --- src/librustc/lint/builtin.rs | 16 ---------------- src/librustc_lint/lib.rs | 2 ++ src/librustc_resolve/resolve_imports.rs | 18 +++++++----------- .../ui/issues/auxiliary/issue-38715-modern.rs | 7 ------- src/test/ui/issues/auxiliary/issue-38715.rs | 7 ------- src/test/ui/issues/issue-38715-rpass.rs | 15 --------------- src/test/ui/issues/issue-38715.rs | 1 - src/test/ui/issues/issue-38715.stderr | 3 --- 8 files changed, 9 insertions(+), 60 deletions(-) delete mode 100644 src/test/ui/issues/auxiliary/issue-38715-modern.rs delete mode 100644 src/test/ui/issues/auxiliary/issue-38715.rs delete mode 100644 src/test/ui/issues/issue-38715-rpass.rs diff --git a/src/librustc/lint/builtin.rs b/src/librustc/lint/builtin.rs index c9dd60827ff..2e7db404747 100644 --- a/src/librustc/lint/builtin.rs +++ b/src/librustc/lint/builtin.rs @@ -331,16 +331,6 @@ "detects labels that are never used" } -declare_lint! { - pub DUPLICATE_MACRO_EXPORTS, - Deny, - "detects duplicate macro exports", - @future_incompatible = FutureIncompatibleInfo { - reference: "issue #35896 ", - edition: Some(Edition::Edition2018), - }; -} - declare_lint! { pub INTRA_DOC_LINK_RESOLUTION_FAILURE, Warn, @@ -533,7 +523,6 @@ pub mod parser { ABSOLUTE_PATHS_NOT_STARTING_WITH_CRATE, UNSTABLE_NAME_COLLISIONS, IRREFUTABLE_LET_PATTERNS, - DUPLICATE_MACRO_EXPORTS, INTRA_DOC_LINK_RESOLUTION_FAILURE, MISSING_DOC_CODE_EXAMPLES, PRIVATE_DOC_TESTS, @@ -559,7 +548,6 @@ pub enum BuiltinLintDiagnostics { Normal, BareTraitObject(Span, /* is_global */ bool), AbsPathWithModule(Span), - DuplicatedMacroExports(ast::Ident, Span, Span), ProcMacroDeriveResolutionFallback(Span), MacroExpandedMacroExportsAccessedByAbsolutePaths(Span), ElidedLifetimesInPaths(usize, Span, bool, Span, String), @@ -642,10 +630,6 @@ pub fn run(self, sess: &Session, db: &mut DiagnosticBuilder<'_>) { }; db.span_suggestion(span, "use `crate`", sugg, app); } - BuiltinLintDiagnostics::DuplicatedMacroExports(ident, earlier_span, later_span) => { - db.span_label(later_span, format!("`{}` already exported", ident)); - db.span_note(earlier_span, "previous macro export is now shadowed"); - } BuiltinLintDiagnostics::ProcMacroDeriveResolutionFallback(span) => { db.span_label(span, "names from parent modules are not \ accessible without an explicit import"); diff --git a/src/librustc_lint/lib.rs b/src/librustc_lint/lib.rs index c3c5589b9d0..6310ff3b847 100644 --- a/src/librustc_lint/lib.rs +++ b/src/librustc_lint/lib.rs @@ -342,6 +342,8 @@ macro_rules! register_passes { "converted into hard error, see https://github.com/rust-lang/rust/issues/36247"); store.register_removed("parenthesized_params_in_types_and_modules", "converted into hard error, see https://github.com/rust-lang/rust/issues/42238"); + store.register_removed("duplicate_macro_exports", + "converted into hard error, see https://github.com/rust-lang/rust/issues/35896"); } fn register_internals(store: &mut lint::LintStore) { diff --git a/src/librustc_resolve/resolve_imports.rs b/src/librustc_resolve/resolve_imports.rs index c06be18dc2c..083b11daaa1 100644 --- a/src/librustc_resolve/resolve_imports.rs +++ b/src/librustc_resolve/resolve_imports.rs @@ -16,18 +16,14 @@ use rustc_data_structures::ptr_key::PtrKey; use rustc::ty; use rustc::lint::builtin::BuiltinLintDiagnostics; -use rustc::lint::builtin::{ - DUPLICATE_MACRO_EXPORTS, - PUB_USE_OF_PRIVATE_EXTERN_CRATE, - UNUSED_IMPORTS, -}; +use rustc::lint::builtin::{PUB_USE_OF_PRIVATE_EXTERN_CRATE, UNUSED_IMPORTS}; use rustc::hir::def_id::DefId; use rustc::hir::def::{self, PartialRes, Export}; use rustc::session::DiagnosticMessageId; use rustc::util::nodemap::FxHashSet; use rustc::{bug, span_bug}; -use syntax::ast::{Ident, Name, NodeId, CRATE_NODE_ID}; +use syntax::ast::{Ident, Name, NodeId}; use syntax::symbol::kw; use syntax::util::lev_distance::find_best_match_for_name; use syntax::{struct_span_err, unwrap_or}; @@ -496,13 +492,13 @@ impl<'a> Resolver<'a> { if let (&NameBindingKind::Res(_, true), &NameBindingKind::Res(_, true)) = (&old_binding.kind, &binding.kind) { - this.lint_buffer.buffer_lint_with_diagnostic( - DUPLICATE_MACRO_EXPORTS, - CRATE_NODE_ID, + this.session.struct_span_err( binding.span, &format!("a macro named `{}` has already been exported", key.ident), - BuiltinLintDiagnostics::DuplicatedMacroExports( - key.ident, old_binding.span, binding.span)); + ) + .span_label(binding.span, format!("`{}` already exported", key.ident)) + .span_note(old_binding.span, "previous macro export is now shadowed") + .emit(); resolution.binding = Some(binding); } else { diff --git a/src/test/ui/issues/auxiliary/issue-38715-modern.rs b/src/test/ui/issues/auxiliary/issue-38715-modern.rs deleted file mode 100644 index 15d072957cb..00000000000 --- a/src/test/ui/issues/auxiliary/issue-38715-modern.rs +++ /dev/null @@ -1,7 +0,0 @@ -#![allow(duplicate_macro_exports)] - -#[macro_export] -macro_rules! foo_modern { ($i:ident) => {} } - -#[macro_export] -macro_rules! foo_modern { () => {} } diff --git a/src/test/ui/issues/auxiliary/issue-38715.rs b/src/test/ui/issues/auxiliary/issue-38715.rs deleted file mode 100644 index 5c15073f5a5..00000000000 --- a/src/test/ui/issues/auxiliary/issue-38715.rs +++ /dev/null @@ -1,7 +0,0 @@ -#![allow(duplicate_macro_exports)] - -#[macro_export] -macro_rules! foo { ($i:ident) => {} } - -#[macro_export] -macro_rules! foo { () => {} } diff --git a/src/test/ui/issues/issue-38715-rpass.rs b/src/test/ui/issues/issue-38715-rpass.rs deleted file mode 100644 index e3c3a027f3c..00000000000 --- a/src/test/ui/issues/issue-38715-rpass.rs +++ /dev/null @@ -1,15 +0,0 @@ -// run-pass -// aux-build:issue-38715.rs -// aux-build:issue-38715-modern.rs - -// Test that `#[macro_export] macro_rules!` shadow earlier `#[macro_export] macro_rules!` - -#[macro_use] -extern crate issue_38715; -#[macro_use] -extern crate issue_38715_modern; - -fn main() { - foo!(); - foo_modern!(); -} diff --git a/src/test/ui/issues/issue-38715.rs b/src/test/ui/issues/issue-38715.rs index 850ffcdabe4..7e9defab588 100644 --- a/src/test/ui/issues/issue-38715.rs +++ b/src/test/ui/issues/issue-38715.rs @@ -3,6 +3,5 @@ macro_rules! foo { ($i:ident) => {} } #[macro_export] macro_rules! foo { () => {} } //~ ERROR a macro named `foo` has already been exported - //~| WARN this was previously accepted fn main() {} diff --git a/src/test/ui/issues/issue-38715.stderr b/src/test/ui/issues/issue-38715.stderr index 02b96d2d244..d7c4f88ff50 100644 --- a/src/test/ui/issues/issue-38715.stderr +++ b/src/test/ui/issues/issue-38715.stderr @@ -4,9 +4,6 @@ error: a macro named `foo` has already been exported LL | macro_rules! foo { () => {} } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `foo` already exported | - = note: `#[deny(duplicate_macro_exports)]` on by default - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition! - = note: for more information, see issue #35896 note: previous macro export is now shadowed --> $DIR/issue-38715.rs:2:1 | From 0cbd06ae1c12368d5c73024caf1a47daf7ea87be Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Sat, 3 Aug 2019 21:59:22 +0200 Subject: [PATCH 06/15] nested_impl_trait -> error --- src/librustc/lint/builtin.rs | 18 --- src/librustc_lint/lib.rs | 2 + src/librustc_passes/ast_validation.rs | 126 +++--------------- ...-deeply-nested-impl-trait-in-assoc-proj.rs | 37 +---- ...ply-nested-impl-trait-in-assoc-proj.stderr | 32 +---- .../issues/issue-57979-impl-trait-in-path.rs | 35 +---- .../issue-57979-impl-trait-in-path.stderr | 30 +---- ...e-57979-nested-impl-trait-in-assoc-proj.rs | 35 +---- ...979-nested-impl-trait-in-assoc-proj.stderr | 40 ++---- 9 files changed, 56 insertions(+), 299 deletions(-) diff --git a/src/librustc/lint/builtin.rs b/src/librustc/lint/builtin.rs index 2e7db404747..4ffb8dabe3b 100644 --- a/src/librustc/lint/builtin.rs +++ b/src/librustc/lint/builtin.rs @@ -446,16 +446,6 @@ pub mod parser { }; } -declare_lint! { - pub NESTED_IMPL_TRAIT, - Warn, - "nested occurrence of `impl Trait` type", - @future_incompatible = FutureIncompatibleInfo { - reference: "issue #59014 ", - edition: None, - }; -} - declare_lint! { pub MUTABLE_BORROW_RESERVATION_CONFLICT, Warn, @@ -534,7 +524,6 @@ pub mod parser { parser::META_VARIABLE_MISUSE, DEPRECATED_IN_FUTURE, AMBIGUOUS_ASSOCIATED_ITEMS, - NESTED_IMPL_TRAIT, MUTABLE_BORROW_RESERVATION_CONFLICT, INDIRECT_STRUCTURAL_MATCH, SOFT_UNSTABLE, @@ -553,7 +542,6 @@ pub enum BuiltinLintDiagnostics { ElidedLifetimesInPaths(usize, Span, bool, Span, String), UnknownCrateTypes(Span, String, String), UnusedImports(String, Vec<(Span, String)>), - NestedImplTrait { outer_impl_trait_span: Span, inner_impl_trait_span: Span }, RedundantImport(Vec<(Span, bool)>, ast::Ident), DeprecatedMacro(Option, Span), } @@ -662,12 +650,6 @@ pub fn run(self, sess: &Session, db: &mut DiagnosticBuilder<'_>) { ); } } - BuiltinLintDiagnostics::NestedImplTrait { - outer_impl_trait_span, inner_impl_trait_span - } => { - db.span_label(outer_impl_trait_span, "outer `impl Trait`"); - db.span_label(inner_impl_trait_span, "nested `impl Trait` here"); - } BuiltinLintDiagnostics::RedundantImport(spans, ident) => { for (span, is_imported) in spans { let introduced = if is_imported { "imported" } else { "defined" }; diff --git a/src/librustc_lint/lib.rs b/src/librustc_lint/lib.rs index 6310ff3b847..2ca3d4b19b2 100644 --- a/src/librustc_lint/lib.rs +++ b/src/librustc_lint/lib.rs @@ -344,6 +344,8 @@ macro_rules! register_passes { "converted into hard error, see https://github.com/rust-lang/rust/issues/42238"); store.register_removed("duplicate_macro_exports", "converted into hard error, see https://github.com/rust-lang/rust/issues/35896"); + store.register_removed("nested_impl_trait", + "converted into hard error, see https://github.com/rust-lang/rust/issues/59014"); } fn register_internals(store: &mut lint::LintStore) { diff --git a/src/librustc_passes/ast_validation.rs b/src/librustc_passes/ast_validation.rs index e046f6c2a07..4577b6e1e07 100644 --- a/src/librustc_passes/ast_validation.rs +++ b/src/librustc_passes/ast_validation.rs @@ -9,7 +9,6 @@ use std::mem; use syntax::print::pprust; use rustc::lint; -use rustc::lint::builtin::{BuiltinLintDiagnostics, NESTED_IMPL_TRAIT}; use rustc::session::Session; use rustc_data_structures::fx::FxHashMap; use syntax::ast::*; @@ -23,31 +22,6 @@ use syntax_pos::{Span, MultiSpan}; use errors::{Applicability, FatalError}; -#[derive(Copy, Clone, Debug)] -struct OuterImplTrait { - span: Span, - - /// rust-lang/rust#57979: a bug in original implementation caused - /// us to fail sometimes to record an outer `impl Trait`. - /// Therefore, in order to reliably issue a warning (rather than - /// an error) in the *precise* places where we are newly injecting - /// the diagnostic, we have to distinguish between the places - /// where the outer `impl Trait` has always been recorded, versus - /// the places where it has only recently started being recorded. - only_recorded_since_pull_request_57730: bool, -} - -impl OuterImplTrait { - /// This controls whether we should downgrade the nested impl - /// trait diagnostic to a warning rather than an error, based on - /// whether the outer impl trait had been improperly skipped in - /// earlier implementations of the analysis on the stable - /// compiler. - fn should_warn_instead_of_error(&self) -> bool { - self.only_recorded_since_pull_request_57730 - } -} - struct AstValidator<'a> { session: &'a Session, has_proc_macro_decls: bool, @@ -55,7 +29,7 @@ struct AstValidator<'a> { /// Used to ban nested `impl Trait`, e.g., `impl Into`. /// Nested `impl Trait` _is_ allowed in associated type position, /// e.g., `impl Iterator`. - outer_impl_trait: Option, + outer_impl_trait: Option, /// Used to ban `impl Trait` in path projections like `::Item` /// or `Foo::Bar` @@ -65,26 +39,10 @@ struct AstValidator<'a> { /// certain positions. is_assoc_ty_bound_banned: bool, - /// rust-lang/rust#57979: the ban of nested `impl Trait` was buggy - /// until PRs #57730 and #57981 landed: it would jump directly to - /// walk_ty rather than visit_ty (or skip recurring entirely for - /// impl trait in projections), and thus miss some cases. We track - /// whether we should downgrade to a warning for short-term via - /// these booleans. - warning_period_57979_didnt_record_next_impl_trait: bool, - warning_period_57979_impl_trait_in_proj: bool, - lint_buffer: &'a mut lint::LintBuffer, } impl<'a> AstValidator<'a> { - fn with_impl_trait_in_proj_warning(&mut self, v: bool, f: impl FnOnce(&mut Self) -> T) -> T { - let old = mem::replace(&mut self.warning_period_57979_impl_trait_in_proj, v); - let ret = f(self); - self.warning_period_57979_impl_trait_in_proj = old; - ret - } - fn with_banned_impl_trait(&mut self, f: impl FnOnce(&mut Self)) { let old = mem::replace(&mut self.is_impl_trait_banned, true); f(self); @@ -97,7 +55,7 @@ fn with_banned_assoc_ty_bound(&mut self, f: impl FnOnce(&mut Self)) { self.is_assoc_ty_bound_banned = old; } - fn with_impl_trait(&mut self, outer: Option, f: impl FnOnce(&mut Self)) { + fn with_impl_trait(&mut self, outer: Option, f: impl FnOnce(&mut Self)) { let old = mem::replace(&mut self.outer_impl_trait, outer); f(self); self.outer_impl_trait = old; @@ -105,14 +63,7 @@ fn with_impl_trait(&mut self, outer: Option, f: impl FnOnce(&mut fn visit_assoc_ty_constraint_from_generic_args(&mut self, constraint: &'a AssocTyConstraint) { match constraint.kind { - AssocTyConstraintKind::Equality { ref ty } => { - // rust-lang/rust#57979: bug in old `visit_generic_args` called - // `walk_ty` rather than `visit_ty`, skipping outer `impl Trait` - // if it happened to occur at `ty`. - if let TyKind::ImplTrait(..) = ty.kind { - self.warning_period_57979_didnt_record_next_impl_trait = true; - } - } + AssocTyConstraintKind::Equality { .. } => {} AssocTyConstraintKind::Bound { .. } => { if self.is_assoc_ty_bound_banned { self.err_handler().span_err(constraint.span, @@ -124,37 +75,11 @@ fn visit_assoc_ty_constraint_from_generic_args(&mut self, constraint: &'a AssocT self.visit_assoc_ty_constraint(constraint); } - fn visit_ty_from_generic_args(&mut self, ty: &'a Ty) { - // rust-lang/rust#57979: bug in old `visit_generic_args` called - // `walk_ty` rather than `visit_ty`, skippping outer `impl Trait` - // if it happened to occur at `ty`. - if let TyKind::ImplTrait(..) = ty.kind { - self.warning_period_57979_didnt_record_next_impl_trait = true; - } - self.visit_ty(ty); - } - - fn outer_impl_trait(&mut self, span: Span) -> OuterImplTrait { - let only_recorded_since_pull_request_57730 = - self.warning_period_57979_didnt_record_next_impl_trait; - - // (This flag is designed to be set to `true`, and then only - // reach the construction point for the outer impl trait once, - // so its safe and easiest to unconditionally reset it to - // false.) - self.warning_period_57979_didnt_record_next_impl_trait = false; - - OuterImplTrait { - span, only_recorded_since_pull_request_57730, - } - } - // Mirrors `visit::walk_ty`, but tracks relevant state. fn walk_ty(&mut self, t: &'a Ty) { match t.kind { TyKind::ImplTrait(..) => { - let outer_impl_trait = self.outer_impl_trait(t.span); - self.with_impl_trait(Some(outer_impl_trait), |this| visit::walk_ty(this, t)) + self.with_impl_trait(Some(t.span), |this| visit::walk_ty(this, t)) } TyKind::Path(ref qself, ref path) => { // We allow these: @@ -484,32 +409,21 @@ fn visit_ty(&mut self, ty: &'a Ty) { } TyKind::ImplTrait(_, ref bounds) => { if self.is_impl_trait_banned { - if self.warning_period_57979_impl_trait_in_proj { - self.lint_buffer.buffer_lint( - NESTED_IMPL_TRAIT, ty.id, ty.span, - "`impl Trait` is not allowed in path parameters"); - } else { - struct_span_err!(self.session, ty.span, E0667, - "`impl Trait` is not allowed in path parameters").emit(); - } + struct_span_err!( + self.session, ty.span, E0667, + "`impl Trait` is not allowed in path parameters" + ) + .emit(); } - if let Some(outer_impl_trait) = self.outer_impl_trait { - if outer_impl_trait.should_warn_instead_of_error() { - self.lint_buffer.buffer_lint_with_diagnostic( - NESTED_IMPL_TRAIT, ty.id, ty.span, - "nested `impl Trait` is not allowed", - BuiltinLintDiagnostics::NestedImplTrait { - outer_impl_trait_span: outer_impl_trait.span, - inner_impl_trait_span: ty.span, - }); - } else { - struct_span_err!(self.session, ty.span, E0666, - "nested `impl Trait` is not allowed") - .span_label(outer_impl_trait.span, "outer `impl Trait`") - .span_label(ty.span, "nested `impl Trait` here") - .emit(); - } + if let Some(outer_impl_trait_sp) = self.outer_impl_trait { + struct_span_err!( + self.session, ty.span, E0666, + "nested `impl Trait` is not allowed" + ) + .span_label(outer_impl_trait_sp, "outer `impl Trait`") + .span_label(ty.span, "nested `impl Trait` here") + .emit(); } if !bounds.iter() @@ -517,7 +431,7 @@ fn visit_ty(&mut self, ty: &'a Ty) { self.err_handler().span_err(ty.span, "at least one trait must be specified"); } - self.with_impl_trait_in_proj_warning(true, |this| this.walk_ty(ty)); + self.walk_ty(ty); return; } _ => {} @@ -726,7 +640,7 @@ fn visit_generic_args(&mut self, _: Span, generic_args: &'a GenericArgs) { if let Some(ref type_) = data.output { // `-> Foo` syntax is essentially an associated type binding, // so it is also allowed to contain nested `impl Trait`. - self.with_impl_trait(None, |this| this.visit_ty_from_generic_args(type_)); + self.with_impl_trait(None, |this| this.visit_ty(type_)); } } } @@ -844,8 +758,6 @@ pub fn check_crate(session: &Session, krate: &Crate, lints: &mut lint::LintBuffe outer_impl_trait: None, is_impl_trait_banned: false, is_assoc_ty_bound_banned: false, - warning_period_57979_didnt_record_next_impl_trait: false, - warning_period_57979_impl_trait_in_proj: false, lint_buffer: lints, }; visit::walk_crate(&mut validator, krate); diff --git a/src/test/ui/impl-trait/issues/issue-57979-deeply-nested-impl-trait-in-assoc-proj.rs b/src/test/ui/impl-trait/issues/issue-57979-deeply-nested-impl-trait-in-assoc-proj.rs index 5eef6a39325..0daec3305c0 100644 --- a/src/test/ui/impl-trait/issues/issue-57979-deeply-nested-impl-trait-in-assoc-proj.rs +++ b/src/test/ui/impl-trait/issues/issue-57979-deeply-nested-impl-trait-in-assoc-proj.rs @@ -1,42 +1,17 @@ // rust-lang/rust#57979 : the initial support for `impl Trait` didn't // properly check syntax hidden behind an associated type projection, // but it did catch *some cases*. This is checking that we continue to -// properly emit errors for those, even with the new -// future-incompatibility warnings. +// properly emit errors for those. // // issue-57979-nested-impl-trait-in-assoc-proj.rs shows the main case // that we were previously failing to catch. struct Deeper(T); -mod allowed { - #![allow(nested_impl_trait)] - - pub trait Foo { } - pub trait Bar { } - pub trait Quux { type Assoc; } - pub fn demo(_: impl Quux>>) { } - //~^ ERROR nested `impl Trait` is not allowed -} - -mod warned { - #![warn(nested_impl_trait)] - - pub trait Foo { } - pub trait Bar { } - pub trait Quux { type Assoc; } - pub fn demo(_: impl Quux>>) { } - //~^ ERROR nested `impl Trait` is not allowed -} - -mod denied { - #![deny(nested_impl_trait)] - - pub trait Foo { } - pub trait Bar { } - pub trait Quux { type Assoc; } - pub fn demo(_: impl Quux>>) { } - //~^ ERROR nested `impl Trait` is not allowed -} +pub trait Foo { } +pub trait Bar { } +pub trait Quux { type Assoc; } +pub fn demo(_: impl Quux>>) { } +//~^ ERROR nested `impl Trait` is not allowed fn main() { } diff --git a/src/test/ui/impl-trait/issues/issue-57979-deeply-nested-impl-trait-in-assoc-proj.stderr b/src/test/ui/impl-trait/issues/issue-57979-deeply-nested-impl-trait-in-assoc-proj.stderr index 2b6f15e6d3e..6bebbc01f3d 100644 --- a/src/test/ui/impl-trait/issues/issue-57979-deeply-nested-impl-trait-in-assoc-proj.stderr +++ b/src/test/ui/impl-trait/issues/issue-57979-deeply-nested-impl-trait-in-assoc-proj.stderr @@ -1,30 +1,12 @@ error[E0666]: nested `impl Trait` is not allowed - --> $DIR/issue-57979-deeply-nested-impl-trait-in-assoc-proj.rs:18:59 + --> $DIR/issue-57979-deeply-nested-impl-trait-in-assoc-proj.rs:14:48 | -LL | pub fn demo(_: impl Quux>>) { } - | ---------^^^^^^^^- - | | | - | | nested `impl Trait` here - | outer `impl Trait` +LL | pub fn demo(_: impl Quux>>) { } + | ---------^^^^^^^^- + | | | + | | nested `impl Trait` here + | outer `impl Trait` -error[E0666]: nested `impl Trait` is not allowed - --> $DIR/issue-57979-deeply-nested-impl-trait-in-assoc-proj.rs:28:59 - | -LL | pub fn demo(_: impl Quux>>) { } - | ---------^^^^^^^^- - | | | - | | nested `impl Trait` here - | outer `impl Trait` - -error[E0666]: nested `impl Trait` is not allowed - --> $DIR/issue-57979-deeply-nested-impl-trait-in-assoc-proj.rs:38:59 - | -LL | pub fn demo(_: impl Quux>>) { } - | ---------^^^^^^^^- - | | | - | | nested `impl Trait` here - | outer `impl Trait` - -error: aborting due to 3 previous errors +error: aborting due to previous error For more information about this error, try `rustc --explain E0666`. diff --git a/src/test/ui/impl-trait/issues/issue-57979-impl-trait-in-path.rs b/src/test/ui/impl-trait/issues/issue-57979-impl-trait-in-path.rs index 84fcb5e2880..c5ecd1caae1 100644 --- a/src/test/ui/impl-trait/issues/issue-57979-impl-trait-in-path.rs +++ b/src/test/ui/impl-trait/issues/issue-57979-impl-trait-in-path.rs @@ -3,35 +3,10 @@ // Here we test behavior of occurrences of `impl Trait` within a path // component in that context. -mod allowed { - #![allow(nested_impl_trait)] - - pub trait Bar { } - pub trait Quux { type Assoc; } - pub fn demo(_: impl Quux<(), Assoc=<() as Quux>::Assoc>) { } - impl Quux for () { type Assoc = u32; } -} - -mod warned { - #![warn(nested_impl_trait)] - - pub trait Bar { } - pub trait Quux { type Assoc; } - pub fn demo(_: impl Quux<(), Assoc=<() as Quux>::Assoc>) { } - //~^ WARN `impl Trait` is not allowed in path parameters - //~| WARN will become a hard error in a future release! - impl Quux for () { type Assoc = u32; } -} - -mod denied { - #![deny(nested_impl_trait)] - - pub trait Bar { } - pub trait Quux { type Assoc; } - pub fn demo(_: impl Quux<(), Assoc=<() as Quux>::Assoc>) { } - //~^ ERROR `impl Trait` is not allowed in path parameters - //~| WARN will become a hard error in a future release! - impl Quux for () { type Assoc = u32; } -} +pub trait Bar { } +pub trait Quux { type Assoc; } +pub fn demo(_: impl Quux<(), Assoc=<() as Quux>::Assoc>) { } +//~^ ERROR `impl Trait` is not allowed in path parameters +impl Quux for () { type Assoc = u32; } fn main() { } diff --git a/src/test/ui/impl-trait/issues/issue-57979-impl-trait-in-path.stderr b/src/test/ui/impl-trait/issues/issue-57979-impl-trait-in-path.stderr index 982ecba291f..f64545d83b8 100644 --- a/src/test/ui/impl-trait/issues/issue-57979-impl-trait-in-path.stderr +++ b/src/test/ui/impl-trait/issues/issue-57979-impl-trait-in-path.stderr @@ -1,30 +1,8 @@ -warning: `impl Trait` is not allowed in path parameters - --> $DIR/issue-57979-impl-trait-in-path.rs:20:52 +error[E0667]: `impl Trait` is not allowed in path parameters + --> $DIR/issue-57979-impl-trait-in-path.rs:8:48 | -LL | pub fn demo(_: impl Quux<(), Assoc=<() as Quux>::Assoc>) { } - | ^^^^^^^^ - | -note: lint level defined here - --> $DIR/issue-57979-impl-trait-in-path.rs:16:13 - | -LL | #![warn(nested_impl_trait)] - | ^^^^^^^^^^^^^^^^^ - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #59014 - -error: `impl Trait` is not allowed in path parameters - --> $DIR/issue-57979-impl-trait-in-path.rs:31:52 - | -LL | pub fn demo(_: impl Quux<(), Assoc=<() as Quux>::Assoc>) { } - | ^^^^^^^^ - | -note: lint level defined here - --> $DIR/issue-57979-impl-trait-in-path.rs:27:13 - | -LL | #![deny(nested_impl_trait)] - | ^^^^^^^^^^^^^^^^^ - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #59014 +LL | pub fn demo(_: impl Quux<(), Assoc=<() as Quux>::Assoc>) { } + | ^^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/impl-trait/issues/issue-57979-nested-impl-trait-in-assoc-proj.rs b/src/test/ui/impl-trait/issues/issue-57979-nested-impl-trait-in-assoc-proj.rs index 5c20ffc7c67..5a444d3dfdd 100644 --- a/src/test/ui/impl-trait/issues/issue-57979-nested-impl-trait-in-assoc-proj.rs +++ b/src/test/ui/impl-trait/issues/issue-57979-nested-impl-trait-in-assoc-proj.rs @@ -3,35 +3,10 @@ // Here we test behavior of occurrences of `impl Trait` within an // `impl Trait` in that context. -mod allowed { - #![allow(nested_impl_trait)] - - pub trait Foo { } - pub trait Bar { } - pub trait Quux { type Assoc; } - pub fn demo(_: impl Quux>) { } -} - -mod warned { - #![warn(nested_impl_trait)] - - pub trait Foo { } - pub trait Bar { } - pub trait Quux { type Assoc; } - pub fn demo(_: impl Quux>) { } - //~^ WARN nested `impl Trait` is not allowed - //~| WARN will become a hard error in a future release! -} - -mod denied { - #![deny(nested_impl_trait)] - - pub trait Foo { } - pub trait Bar { } - pub trait Quux { type Assoc; } - pub fn demo(_: impl Quux>) { } - //~^ ERROR nested `impl Trait` is not allowed - //~| WARN will become a hard error in a future release! -} +pub trait Foo { } +pub trait Bar { } +pub trait Quux { type Assoc; } +pub fn demo(_: impl Quux>) { } +//~^ ERROR nested `impl Trait` is not allowed fn main() { } diff --git a/src/test/ui/impl-trait/issues/issue-57979-nested-impl-trait-in-assoc-proj.stderr b/src/test/ui/impl-trait/issues/issue-57979-nested-impl-trait-in-assoc-proj.stderr index 508aea24321..8d3d4b5e206 100644 --- a/src/test/ui/impl-trait/issues/issue-57979-nested-impl-trait-in-assoc-proj.stderr +++ b/src/test/ui/impl-trait/issues/issue-57979-nested-impl-trait-in-assoc-proj.stderr @@ -1,36 +1,12 @@ -warning: nested `impl Trait` is not allowed - --> $DIR/issue-57979-nested-impl-trait-in-assoc-proj.rs:21:45 +error[E0666]: nested `impl Trait` is not allowed + --> $DIR/issue-57979-nested-impl-trait-in-assoc-proj.rs:9:41 | -LL | pub fn demo(_: impl Quux>) { } - | ---------^^^^^^^^- - | | | - | | nested `impl Trait` here - | outer `impl Trait` - | -note: lint level defined here - --> $DIR/issue-57979-nested-impl-trait-in-assoc-proj.rs:16:13 - | -LL | #![warn(nested_impl_trait)] - | ^^^^^^^^^^^^^^^^^ - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #59014 - -error: nested `impl Trait` is not allowed - --> $DIR/issue-57979-nested-impl-trait-in-assoc-proj.rs:32:45 - | -LL | pub fn demo(_: impl Quux>) { } - | ---------^^^^^^^^- - | | | - | | nested `impl Trait` here - | outer `impl Trait` - | -note: lint level defined here - --> $DIR/issue-57979-nested-impl-trait-in-assoc-proj.rs:27:13 - | -LL | #![deny(nested_impl_trait)] - | ^^^^^^^^^^^^^^^^^ - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #59014 +LL | pub fn demo(_: impl Quux>) { } + | ---------^^^^^^^^- + | | | + | | nested `impl Trait` here + | outer `impl Trait` error: aborting due to previous error +For more information about this error, try `rustc --explain E0666`. From a12e69d62798a4fb894209b249e16a6eda7c0d0f Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Sun, 27 Oct 2019 00:14:49 +0200 Subject: [PATCH 07/15] ill_formed_attribute_input -> deny --- src/librustc/lint/builtin.rs | 2 +- .../issue-43106-gating-of-inline.rs | 2 +- .../issue-43106-gating-of-inline.stderr | 6 ++--- .../ui/malformed/malformed-regressions.rs | 26 +++++++------------ .../ui/malformed/malformed-regressions.stderr | 24 +++++++++-------- 5 files changed, 28 insertions(+), 32 deletions(-) diff --git a/src/librustc/lint/builtin.rs b/src/librustc/lint/builtin.rs index 4ffb8dabe3b..baa1075e6b3 100644 --- a/src/librustc/lint/builtin.rs +++ b/src/librustc/lint/builtin.rs @@ -408,7 +408,7 @@ pub mod parser { declare_lint! { pub ILL_FORMED_ATTRIBUTE_INPUT, - Warn, + Deny, "ill-formed attribute inputs that were previously accepted and used in practice", @future_incompatible = super::FutureIncompatibleInfo { reference: "issue #57571 ", diff --git a/src/test/ui/feature-gate/issue-43106-gating-of-inline.rs b/src/test/ui/feature-gate/issue-43106-gating-of-inline.rs index bb9e6d4ca83..80c602eb00a 100644 --- a/src/test/ui/feature-gate/issue-43106-gating-of-inline.rs +++ b/src/test/ui/feature-gate/issue-43106-gating-of-inline.rs @@ -15,7 +15,7 @@ mod inner { #![inline] } //~^ ERROR attribute should be applied to function or closure #[inline = "2100"] fn f() { } - //~^ WARN attribute must be of the form + //~^ ERROR attribute must be of the form //~| WARN this was previously accepted #[inline] struct S; diff --git a/src/test/ui/feature-gate/issue-43106-gating-of-inline.stderr b/src/test/ui/feature-gate/issue-43106-gating-of-inline.stderr index 4310a0c7d58..0987937192f 100644 --- a/src/test/ui/feature-gate/issue-43106-gating-of-inline.stderr +++ b/src/test/ui/feature-gate/issue-43106-gating-of-inline.stderr @@ -1,10 +1,10 @@ -warning: attribute must be of the form `#[inline]` or `#[inline(always|never)]` +error: attribute must be of the form `#[inline]` or `#[inline(always|never)]` --> $DIR/issue-43106-gating-of-inline.rs:17:5 | LL | #[inline = "2100"] fn f() { } | ^^^^^^^^^^^^^^^^^^ | - = note: `#[warn(ill_formed_attribute_input)]` on by default + = note: `#[deny(ill_formed_attribute_input)]` on by default = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #57571 @@ -47,6 +47,6 @@ error[E0518]: attribute should be applied to function or closure LL | #[inline] impl S { } | ^^^^^^^^^ ---------- not a function or closure -error: aborting due to 5 previous errors +error: aborting due to 6 previous errors For more information about this error, try `rustc --explain E0518`. diff --git a/src/test/ui/malformed/malformed-regressions.rs b/src/test/ui/malformed/malformed-regressions.rs index 1eca8c73904..ac1444bbaef 100644 --- a/src/test/ui/malformed/malformed-regressions.rs +++ b/src/test/ui/malformed/malformed-regressions.rs @@ -1,18 +1,12 @@ -// build-pass (FIXME(62277): could be check-pass?) +#[doc] //~ ERROR attribute must be of the form +//~^ WARN this was previously accepted +#[ignore()] //~ ERROR attribute must be of the form +//~^ WARN this was previously accepted +#[inline = ""] //~ ERROR attribute must be of the form +//~^ WARN this was previously accepted +#[link] //~ ERROR attribute must be of the form +//~^ WARN this was previously accepted +#[link = ""] //~ ERROR attribute must be of the form +//~^ WARN this was previously accepted -#[doc] -//~^ WARN attribute must be of the form -//~| WARN this was previously accepted -#[ignore()] -//~^ WARN attribute must be of the form -//~| WARN this was previously accepted -#[inline = ""] -//~^ WARN attribute must be of the form -//~| WARN this was previously accepted -#[link] -//~^WARN attribute must be of the form -//~| WARN this was previously accepted -#[link = ""] -//~^ WARN attribute must be of the form -//~| WARN this was previously accepted fn main() {} diff --git a/src/test/ui/malformed/malformed-regressions.stderr b/src/test/ui/malformed/malformed-regressions.stderr index 8f4e952338f..b14f99be50c 100644 --- a/src/test/ui/malformed/malformed-regressions.stderr +++ b/src/test/ui/malformed/malformed-regressions.stderr @@ -1,15 +1,15 @@ -warning: attribute must be of the form `#[doc(hidden|inline|...)]` or `#[doc = "string"]` - --> $DIR/malformed-regressions.rs:3:1 +error: attribute must be of the form `#[doc(hidden|inline|...)]` or `#[doc = "string"]` + --> $DIR/malformed-regressions.rs:1:1 | LL | #[doc] | ^^^^^^ | - = note: `#[warn(ill_formed_attribute_input)]` on by default + = note: `#[deny(ill_formed_attribute_input)]` on by default = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #57571 -warning: attribute must be of the form `#[ignore]` or `#[ignore = "reason"]` - --> $DIR/malformed-regressions.rs:6:1 +error: attribute must be of the form `#[ignore]` or `#[ignore = "reason"]` + --> $DIR/malformed-regressions.rs:3:1 | LL | #[ignore()] | ^^^^^^^^^^^ @@ -17,8 +17,8 @@ LL | #[ignore()] = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #57571 -warning: attribute must be of the form `#[inline]` or `#[inline(always|never)]` - --> $DIR/malformed-regressions.rs:9:1 +error: attribute must be of the form `#[inline]` or `#[inline(always|never)]` + --> $DIR/malformed-regressions.rs:5:1 | LL | #[inline = ""] | ^^^^^^^^^^^^^^ @@ -26,8 +26,8 @@ LL | #[inline = ""] = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #57571 -warning: attribute must be of the form `#[link(name = "...", /*opt*/ kind = "dylib|static|...", /*opt*/ cfg = "...")]` - --> $DIR/malformed-regressions.rs:12:1 +error: attribute must be of the form `#[link(name = "...", /*opt*/ kind = "dylib|static|...", /*opt*/ cfg = "...")]` + --> $DIR/malformed-regressions.rs:7:1 | LL | #[link] | ^^^^^^^ @@ -35,8 +35,8 @@ LL | #[link] = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #57571 -warning: attribute must be of the form `#[link(name = "...", /*opt*/ kind = "dylib|static|...", /*opt*/ cfg = "...")]` - --> $DIR/malformed-regressions.rs:15:1 +error: attribute must be of the form `#[link(name = "...", /*opt*/ kind = "dylib|static|...", /*opt*/ cfg = "...")]` + --> $DIR/malformed-regressions.rs:9:1 | LL | #[link = ""] | ^^^^^^^^^^^^ @@ -44,3 +44,5 @@ LL | #[link = ""] = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #57571 +error: aborting due to 5 previous errors + From 574d2b83a16dbbe975bbb3cf2ed541563a2f756c Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Sat, 3 Aug 2019 22:33:19 +0200 Subject: [PATCH 08/15] patterns_in_fns_without_body -> deny --- .../src/lints/listing/deny-by-default.md | 40 +++++++++++++++++++ .../src/lints/listing/warn-by-default.md | 40 ------------------- src/librustc/lint/builtin.rs | 2 +- 3 files changed, 41 insertions(+), 41 deletions(-) diff --git a/src/doc/rustc/src/lints/listing/deny-by-default.md b/src/doc/rustc/src/lints/listing/deny-by-default.md index 466a748bcee..dc5a9e44acf 100644 --- a/src/doc/rustc/src/lints/listing/deny-by-default.md +++ b/src/doc/rustc/src/lints/listing/deny-by-default.md @@ -122,6 +122,46 @@ error: literal out of range for u8 | ``` +## patterns-in-fns-without-body + +This lint detects patterns in functions without body were that were +previously erroneously allowed. Some example code that triggers this lint: + +```rust,compile_fail +trait Trait { + fn foo(mut arg: u8); +} +``` + +This will produce: + +```text +warning: patterns aren't allowed in methods without bodies + --> src/main.rs:2:12 + | +2 | fn foo(mut arg: u8); + | ^^^^^^^ + | + = note: `#[warn(patterns_in_fns_without_body)]` on by default + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #35203 +``` + +To fix this, remove the pattern; it can be used in the implementation without +being used in the definition. That is: + +```rust +trait Trait { + fn foo(arg: u8); +} + +impl Trait for i32 { + fn foo(mut arg: u8) { + + } +} +``` + ## pub-use-of-private-extern-crate This lint detects a specific situation of re-exporting a private `extern crate`; diff --git a/src/doc/rustc/src/lints/listing/warn-by-default.md b/src/doc/rustc/src/lints/listing/warn-by-default.md index 813d7c4bafe..77642a850fa 100644 --- a/src/doc/rustc/src/lints/listing/warn-by-default.md +++ b/src/doc/rustc/src/lints/listing/warn-by-default.md @@ -307,46 +307,6 @@ warning: path statement with no effect | ``` -## patterns-in-fns-without-body - -This lint detects patterns in functions without body were that were -previously erroneously allowed. Some example code that triggers this lint: - -```rust -trait Trait { - fn foo(mut arg: u8); -} -``` - -This will produce: - -```text -warning: patterns aren't allowed in methods without bodies - --> src/main.rs:2:12 - | -2 | fn foo(mut arg: u8); - | ^^^^^^^ - | - = note: `#[warn(patterns_in_fns_without_body)]` on by default - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #35203 -``` - -To fix this, remove the pattern; it can be used in the implementation without -being used in the definition. That is: - -```rust -trait Trait { - fn foo(arg: u8); -} - -impl Trait for i32 { - fn foo(mut arg: u8) { - - } -} -``` - ## plugin-as-library This lint detects when compiler plugins are used as ordinary library in diff --git a/src/librustc/lint/builtin.rs b/src/librustc/lint/builtin.rs index baa1075e6b3..f8a592d22c1 100644 --- a/src/librustc/lint/builtin.rs +++ b/src/librustc/lint/builtin.rs @@ -189,7 +189,7 @@ declare_lint! { pub PATTERNS_IN_FNS_WITHOUT_BODY, - Warn, + Deny, "patterns in functions without body were erroneously allowed", @future_incompatible = FutureIncompatibleInfo { reference: "issue #35203 ", From 52e8ec14322e1f0c2cba5fc3c54e876e58a5ddee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Mon, 28 Oct 2019 11:08:53 -0700 Subject: [PATCH 09/15] Remove "here" from "expected one of X here" --- src/libsyntax/parse/parser/diagnostics.rs | 2 +- src/test/ui/anon-params-denied-2018.stderr | 8 ++++---- .../incorrect-syntax-suggestions.stderr | 2 +- src/test/ui/async-await/no-async-const.stderr | 2 +- src/test/ui/async-await/no-unsafe-async.stderr | 4 ++-- src/test/ui/can-begin-expr-check.stderr | 2 +- src/test/ui/codemap_tests/bad-format-args.stderr | 2 +- .../const-generics/const-expression-parameter.stderr | 2 +- src/test/ui/did_you_mean/issue-40006.stderr | 2 +- .../issue-54109-and_instead_of_ampersands.stderr | 8 ++++---- .../edition-keywords-2018-2015-parsing.stderr | 2 +- .../edition-keywords-2018-2018-parsing.stderr | 2 +- .../feature-gates/feature-gate-extern_prelude.stderr | 2 +- src/test/ui/imports/import-prefix-macro-1.stderr | 2 +- src/test/ui/invalid/invalid-variadic-function.stderr | 2 +- src/test/ui/issues/issue-20616-1.stderr | 2 +- src/test/ui/issues/issue-20616-2.stderr | 2 +- src/test/ui/issues/issue-20616-3.stderr | 2 +- src/test/ui/issues/issue-20616-4.stderr | 2 +- src/test/ui/issues/issue-20616-5.stderr | 2 +- src/test/ui/issues/issue-20616-6.stderr | 2 +- src/test/ui/issues/issue-20616-7.stderr | 2 +- src/test/ui/issues/issue-20616-8.stderr | 2 +- src/test/ui/issues/issue-20616-9.stderr | 2 +- src/test/ui/issues/issue-21146.stderr | 2 +- src/test/ui/issues/issue-34334.stderr | 2 +- src/test/ui/issues/issue-39616.stderr | 2 +- src/test/ui/issues/issue-44021.stderr | 2 +- src/test/ui/issues/issue-52496.stderr | 2 +- src/test/ui/issues/issue-58856-2.stderr | 2 +- src/test/ui/issues/issue-60075.stderr | 2 +- .../ui/label/label_break_value_illegal_uses.stderr | 4 ++-- src/test/ui/macro_backtrace/main.stderr | 6 +++--- src/test/ui/macros/assert-trailing-junk.stderr | 4 ++-- src/test/ui/macros/issue-54441.stderr | 2 +- src/test/ui/malformed/malformed-derive-entry.stderr | 4 ++-- src/test/ui/mismatched_types/recovered-block.stderr | 2 +- src/test/ui/missing/missing-comma-in-match.fixed | 2 +- src/test/ui/missing/missing-comma-in-match.rs | 2 +- src/test/ui/missing/missing-comma-in-match.stderr | 2 +- .../expected-comma-found-token.stderr | 2 +- src/test/ui/parser/assoc-oddities-1.stderr | 2 +- src/test/ui/parser/assoc-oddities-2.stderr | 2 +- ...ssociated-types-project-from-hrtb-explicit.stderr | 2 +- src/test/ui/parser/attr-bad-meta.stderr | 2 +- src/test/ui/parser/bad-match.stderr | 2 +- src/test/ui/parser/bad-name.stderr | 2 +- src/test/ui/parser/better-expected.stderr | 2 +- src/test/ui/parser/bounds-lifetime-1.stderr | 2 +- src/test/ui/parser/bounds-lifetime-2.stderr | 2 +- src/test/ui/parser/bounds-lifetime-where.stderr | 2 +- src/test/ui/parser/bounds-lifetime.stderr | 2 +- src/test/ui/parser/bounds-type-where.stderr | 2 +- src/test/ui/parser/class-implements-bad-trait.stderr | 2 +- src/test/ui/parser/closure-return-syntax.stderr | 2 +- src/test/ui/parser/default.stderr | 2 +- src/test/ui/parser/duplicate-visibility.stderr | 2 +- src/test/ui/parser/empty-impl-semicolon.stderr | 2 +- .../ui/parser/extern-crate-unexpected-token.stderr | 2 +- .../ui/parser/extern-expected-fn-or-brace.stderr | 2 +- src/test/ui/parser/extern-foreign-crate.stderr | 2 +- src/test/ui/parser/inverted-parameters.stderr | 12 ++++++------ src/test/ui/parser/issue-15980.rs | 2 +- src/test/ui/parser/issue-15980.stderr | 2 +- src/test/ui/parser/issue-17904.stderr | 2 +- src/test/ui/parser/issue-19096.stderr | 4 ++-- src/test/ui/parser/issue-20711-2.stderr | 2 +- src/test/ui/parser/issue-20711.stderr | 2 +- src/test/ui/parser/issue-22647.stderr | 2 +- src/test/ui/parser/issue-22712.stderr | 2 +- src/test/ui/parser/issue-24197.stderr | 2 +- src/test/ui/parser/issue-24375.stderr | 2 +- src/test/ui/parser/issue-24780.stderr | 2 +- src/test/ui/parser/issue-32446.stderr | 2 +- src/test/ui/parser/issue-33455.stderr | 2 +- src/test/ui/parser/issue-41155.stderr | 2 +- src/test/ui/parser/issue-62660.stderr | 2 +- src/test/ui/parser/issue-62973.stderr | 4 ++-- src/test/ui/parser/issue-63135.stderr | 2 +- src/test/ui/parser/lifetime-semicolon.stderr | 2 +- src/test/ui/parser/macro/issue-37234.stderr | 2 +- .../ui/parser/macro/macro-incomplete-parse.stderr | 2 +- .../ui/parser/macro/trait-non-item-macros.stderr | 2 +- src/test/ui/parser/macros-no-semicolon.stderr | 2 +- src/test/ui/parser/match-refactor-to-expr.rs | 2 +- src/test/ui/parser/match-refactor-to-expr.stderr | 2 +- .../missing-close-brace-in-impl-trait.stderr | 2 +- .../missing-close-brace-in-trait.stderr | 2 +- src/test/ui/parser/missing_right_paren.stderr | 2 +- src/test/ui/parser/multitrait.stderr | 2 +- src/test/ui/parser/not-a-pred.stderr | 2 +- src/test/ui/parser/omitted-arg-in-item-fn.stderr | 2 +- src/test/ui/parser/pat-lt-bracket-1.stderr | 2 +- src/test/ui/parser/pat-lt-bracket-2.stderr | 2 +- src/test/ui/parser/pat-lt-bracket-3.stderr | 2 +- src/test/ui/parser/pat-lt-bracket-4.stderr | 2 +- src/test/ui/parser/pat-lt-bracket-5.stderr | 2 +- src/test/ui/parser/pat-lt-bracket-6.stderr | 2 +- src/test/ui/parser/pat-lt-bracket-7.stderr | 2 +- src/test/ui/parser/pat-ranges-1.stderr | 2 +- src/test/ui/parser/pat-ranges-2.stderr | 2 +- src/test/ui/parser/pat-ranges-3.stderr | 2 +- src/test/ui/parser/pat-ranges-4.stderr | 2 +- src/test/ui/parser/range-3.stderr | 2 +- src/test/ui/parser/range-4.stderr | 2 +- src/test/ui/parser/raw-str-unbalanced.stderr | 2 +- src/test/ui/parser/raw/raw-literal-keywords.stderr | 6 +++--- src/test/ui/parser/recover-enum2.stderr | 2 +- .../recover-for-loop-parens-around-head.stderr | 2 +- .../ui/parser/removed-syntax-closure-lifetime.stderr | 2 +- .../ui/parser/removed-syntax-enum-newtype.stderr | 2 +- src/test/ui/parser/removed-syntax-fixed-vec.stderr | 2 +- .../ui/parser/removed-syntax-ptr-lifetime.stderr | 2 +- src/test/ui/parser/removed-syntax-static-fn.stderr | 2 +- src/test/ui/parser/removed-syntax-uniq-mut-ty.stderr | 2 +- src/test/ui/parser/removed-syntax-with-1.stderr | 2 +- src/test/ui/parser/removed-syntax-with-2.stderr | 2 +- src/test/ui/parser/underscore_item_not_const.stderr | 2 +- .../parser/use-as-where-use-ends-with-mod-sep.stderr | 2 +- src/test/ui/resolve/token-error-correct-3.stderr | 2 +- .../disallowed-positions.stderr | 2 +- .../ui/rfc-2565-param-attrs/param-attrs-2018.stderr | 2 +- .../empty_generics.stderr | 2 +- src/test/ui/similar-tokens.stderr | 2 +- src/test/ui/span/issue-34264.stderr | 6 +++--- src/test/ui/suggestions/issue-64252-self-type.stderr | 4 ++-- src/test/ui/tuple/tuple-struct-fields/test.stderr | 2 +- src/test/ui/tuple/tuple-struct-fields/test2.stderr | 2 +- src/test/ui/tuple/tuple-struct-fields/test3.stderr | 2 +- src/test/ui/type/ascription/issue-54516.stderr | 2 +- src/test/ui/type/ascription/issue-60933.stderr | 2 +- .../ui/unsafe/unsafe-block-without-braces.stderr | 2 +- 132 files changed, 156 insertions(+), 156 deletions(-) diff --git a/src/libsyntax/parse/parser/diagnostics.rs b/src/libsyntax/parse/parser/diagnostics.rs index 49a517a5c44..c4d60ec098d 100644 --- a/src/libsyntax/parse/parser/diagnostics.rs +++ b/src/libsyntax/parse/parser/diagnostics.rs @@ -289,7 +289,7 @@ fn tokens_to_string(tokens: &[TokenType]) -> String { }; (format!("expected one of {}, found {}", expect, actual), (self.sess.source_map().next_point(self.prev_span), - format!("expected one of {} here", short_expect))) + format!("expected one of {}", short_expect))) } else if expected.is_empty() { (format!("unexpected token: {}", actual), (self.prev_span, "unexpected token after this".to_string())) diff --git a/src/test/ui/anon-params-denied-2018.stderr b/src/test/ui/anon-params-denied-2018.stderr index 3fcf41a9a60..e7a806a8468 100644 --- a/src/test/ui/anon-params-denied-2018.stderr +++ b/src/test/ui/anon-params-denied-2018.stderr @@ -2,7 +2,7 @@ error: expected one of `:`, `@`, or `|`, found `)` --> $DIR/anon-params-denied-2018.rs:6:15 | LL | fn foo(i32); - | ^ expected one of `:`, `@`, or `|` here + | ^ expected one of `:`, `@`, or `|` | = note: anonymous parameters are removed in the 2018 edition (see RFC 1685) help: if this is a `self` type, give it a parameter name @@ -22,7 +22,7 @@ error: expected one of `:`, `@`, or `|`, found `,` --> $DIR/anon-params-denied-2018.rs:8:36 | LL | fn bar_with_default_impl(String, String) {} - | ^ expected one of `:`, `@`, or `|` here + | ^ expected one of `:`, `@`, or `|` | = note: anonymous parameters are removed in the 2018 edition (see RFC 1685) help: if this is a `self` type, give it a parameter name @@ -42,7 +42,7 @@ error: expected one of `:`, `@`, or `|`, found `)` --> $DIR/anon-params-denied-2018.rs:8:44 | LL | fn bar_with_default_impl(String, String) {} - | ^ expected one of `:`, `@`, or `|` here + | ^ expected one of `:`, `@`, or `|` | = note: anonymous parameters are removed in the 2018 edition (see RFC 1685) help: if this was a parameter name, give it a type @@ -58,7 +58,7 @@ error: expected one of `:`, `@`, or `|`, found `,` --> $DIR/anon-params-denied-2018.rs:13:22 | LL | fn baz(a:usize, b, c: usize) -> usize { - | ^ expected one of `:`, `@`, or `|` here + | ^ expected one of `:`, `@`, or `|` | = note: anonymous parameters are removed in the 2018 edition (see RFC 1685) help: if this was a parameter name, give it a type diff --git a/src/test/ui/async-await/await-keyword/incorrect-syntax-suggestions.stderr b/src/test/ui/async-await/await-keyword/incorrect-syntax-suggestions.stderr index 4b5e2d59e38..92cef80c193 100644 --- a/src/test/ui/async-await/await-keyword/incorrect-syntax-suggestions.stderr +++ b/src/test/ui/async-await/await-keyword/incorrect-syntax-suggestions.stderr @@ -130,7 +130,7 @@ error: expected one of `.`, `?`, `{`, or an operator, found `}` --> $DIR/incorrect-syntax-suggestions.rs:134:1 | LL | match await { await => () } - | ----- - expected one of `.`, `?`, `{`, or an operator here + | ----- - expected one of `.`, `?`, `{`, or an operator | | | while parsing this match expression ... diff --git a/src/test/ui/async-await/no-async-const.stderr b/src/test/ui/async-await/no-async-const.stderr index f89d1810ba4..05cdbff0bf0 100644 --- a/src/test/ui/async-await/no-async-const.stderr +++ b/src/test/ui/async-await/no-async-const.stderr @@ -2,7 +2,7 @@ error: expected one of `fn` or `unsafe`, found keyword `const` --> $DIR/no-async-const.rs:5:11 | LL | pub async const fn x() {} - | ^^^^^ expected one of `fn` or `unsafe` here + | ^^^^^ expected one of `fn` or `unsafe` error: aborting due to previous error diff --git a/src/test/ui/async-await/no-unsafe-async.stderr b/src/test/ui/async-await/no-unsafe-async.stderr index 79d9f1befd6..bbeb3427849 100644 --- a/src/test/ui/async-await/no-unsafe-async.stderr +++ b/src/test/ui/async-await/no-unsafe-async.stderr @@ -2,13 +2,13 @@ error: expected one of `extern` or `fn`, found keyword `async` --> $DIR/no-unsafe-async.rs:7:12 | LL | unsafe async fn g() {} - | ^^^^^ expected one of `extern` or `fn` here + | ^^^^^ expected one of `extern` or `fn` error: expected one of `extern`, `fn`, or `{`, found keyword `async` --> $DIR/no-unsafe-async.rs:11:8 | LL | unsafe async fn f() {} - | ^^^^^ expected one of `extern`, `fn`, or `{` here + | ^^^^^ expected one of `extern`, `fn`, or `{` error: aborting due to 2 previous errors diff --git a/src/test/ui/can-begin-expr-check.stderr b/src/test/ui/can-begin-expr-check.stderr index 0e03e9915fc..d674fc36bc2 100644 --- a/src/test/ui/can-begin-expr-check.stderr +++ b/src/test/ui/can-begin-expr-check.stderr @@ -2,7 +2,7 @@ error: expected one of `.`, `;`, `?`, `}`, or an operator, found keyword `enum` --> $DIR/can-begin-expr-check.rs:19:12 | LL | return enum; - | ^^^^ expected one of `.`, `;`, `?`, `}`, or an operator here + | ^^^^ expected one of `.`, `;`, `?`, `}`, or an operator error: aborting due to previous error diff --git a/src/test/ui/codemap_tests/bad-format-args.stderr b/src/test/ui/codemap_tests/bad-format-args.stderr index 3372ef6dea1..17d4df2a223 100644 --- a/src/test/ui/codemap_tests/bad-format-args.stderr +++ b/src/test/ui/codemap_tests/bad-format-args.stderr @@ -16,7 +16,7 @@ error: expected one of `,`, `.`, `?`, or an operator, found `1` --> $DIR/bad-format-args.rs:4:19 | LL | format!("", 1 1); - | ^ expected one of `,`, `.`, `?`, or an operator here + | ^ expected one of `,`, `.`, `?`, or an operator error: aborting due to 3 previous errors diff --git a/src/test/ui/const-generics/const-expression-parameter.stderr b/src/test/ui/const-generics/const-expression-parameter.stderr index 7311e27c289..28bea4ec94f 100644 --- a/src/test/ui/const-generics/const-expression-parameter.stderr +++ b/src/test/ui/const-generics/const-expression-parameter.stderr @@ -2,7 +2,7 @@ error: expected one of `,` or `>`, found `+` --> $DIR/const-expression-parameter.rs:13:22 | LL | i32_identity::<1 + 2>(); - | ^ expected one of `,` or `>` here + | ^ expected one of `,` or `>` warning: the feature `const_generics` is incomplete and may cause the compiler to crash --> $DIR/const-expression-parameter.rs:1:12 diff --git a/src/test/ui/did_you_mean/issue-40006.stderr b/src/test/ui/did_you_mean/issue-40006.stderr index f0baa175d63..30ae6ed4c6d 100644 --- a/src/test/ui/did_you_mean/issue-40006.stderr +++ b/src/test/ui/did_you_mean/issue-40006.stderr @@ -48,7 +48,7 @@ error: expected one of `!` or `::`, found `(` --> $DIR/issue-40006.rs:28:9 | LL | ::Y (); - | ^ expected one of `!` or `::` here + | ^ expected one of `!` or `::` error: missing `fn`, `type`, or `const` for impl-item declaration --> $DIR/issue-40006.rs:32:8 diff --git a/src/test/ui/did_you_mean/issue-54109-and_instead_of_ampersands.stderr b/src/test/ui/did_you_mean/issue-54109-and_instead_of_ampersands.stderr index 35123b11133..f230395f7a5 100644 --- a/src/test/ui/did_you_mean/issue-54109-and_instead_of_ampersands.stderr +++ b/src/test/ui/did_you_mean/issue-54109-and_instead_of_ampersands.stderr @@ -24,7 +24,7 @@ error: expected one of `!`, `)`, `,`, `.`, `::`, `?`, `{`, or an operator, found LL | if (a and b) { | ^^^ | | - | expected one of 8 possible tokens here + | expected one of 8 possible tokens | help: use `&&` instead of `and` for the boolean operator error: expected one of `!`, `)`, `,`, `.`, `::`, `?`, `{`, or an operator, found `or` @@ -33,7 +33,7 @@ error: expected one of `!`, `)`, `,`, `.`, `::`, `?`, `{`, or an operator, found LL | if (a or b) { | ^^ | | - | expected one of 8 possible tokens here + | expected one of 8 possible tokens | help: use `||` instead of `or` for the boolean operator error: expected one of `!`, `.`, `::`, `?`, `{`, or an operator, found `and` @@ -42,7 +42,7 @@ error: expected one of `!`, `.`, `::`, `?`, `{`, or an operator, found `and` LL | while a and b { | ^^^ | | - | expected one of `!`, `.`, `::`, `?`, `{`, or an operator here + | expected one of `!`, `.`, `::`, `?`, `{`, or an operator | help: use `&&` instead of `and` for the boolean operator error: expected one of `!`, `.`, `::`, `?`, `{`, or an operator, found `or` @@ -51,7 +51,7 @@ error: expected one of `!`, `.`, `::`, `?`, `{`, or an operator, found `or` LL | while a or b { | ^^ | | - | expected one of `!`, `.`, `::`, `?`, `{`, or an operator here + | expected one of `!`, `.`, `::`, `?`, `{`, or an operator | help: use `||` instead of `or` for the boolean operator error: aborting due to 6 previous errors diff --git a/src/test/ui/editions/edition-keywords-2018-2015-parsing.stderr b/src/test/ui/editions/edition-keywords-2018-2015-parsing.stderr index 77eb44c2065..22a7495ca23 100644 --- a/src/test/ui/editions/edition-keywords-2018-2015-parsing.stderr +++ b/src/test/ui/editions/edition-keywords-2018-2015-parsing.stderr @@ -36,7 +36,7 @@ error: macro expansion ends with an incomplete expression: expected one of `move --> <::edition_kw_macro_2015::passes_ident macros>:1:22 | LL | ($ i : ident) => ($ i) - | ^ expected one of `move`, `|`, or `||` here + | ^ expected one of `move`, `|`, or `||` | ::: $DIR/edition-keywords-2018-2015-parsing.rs:16:8 | diff --git a/src/test/ui/editions/edition-keywords-2018-2018-parsing.stderr b/src/test/ui/editions/edition-keywords-2018-2018-parsing.stderr index 01f9f00e91c..7488fcc2e58 100644 --- a/src/test/ui/editions/edition-keywords-2018-2018-parsing.stderr +++ b/src/test/ui/editions/edition-keywords-2018-2018-parsing.stderr @@ -36,7 +36,7 @@ error: macro expansion ends with an incomplete expression: expected one of `move --> <::edition_kw_macro_2018::passes_ident macros>:1:22 | LL | ($ i : ident) => ($ i) - | ^ expected one of `move`, `|`, or `||` here + | ^ expected one of `move`, `|`, or `||` | ::: $DIR/edition-keywords-2018-2018-parsing.rs:16:8 | diff --git a/src/test/ui/feature-gates/feature-gate-extern_prelude.stderr b/src/test/ui/feature-gates/feature-gate-extern_prelude.stderr index c15a8b33037..d72e47e9ed8 100644 --- a/src/test/ui/feature-gates/feature-gate-extern_prelude.stderr +++ b/src/test/ui/feature-gates/feature-gate-extern_prelude.stderr @@ -2,7 +2,7 @@ error: expected one of `!` or `::`, found `-` --> $DIR/feature-gate-extern_prelude.rs:1:4 | LL | can-only-test-this-in-run-make-fulldeps - | ^ expected one of `!` or `::` here + | ^ expected one of `!` or `::` error: aborting due to previous error diff --git a/src/test/ui/imports/import-prefix-macro-1.stderr b/src/test/ui/imports/import-prefix-macro-1.stderr index 862a31b4465..6c12a366b71 100644 --- a/src/test/ui/imports/import-prefix-macro-1.stderr +++ b/src/test/ui/imports/import-prefix-macro-1.stderr @@ -2,7 +2,7 @@ error: expected one of `::`, `;`, or `as`, found `{` --> $DIR/import-prefix-macro-1.rs:11:27 | LL | ($p: path) => (use $p {S, Z}); - | ^^^^^^ expected one of `::`, `;`, or `as` here + | ^^^^^^ expected one of `::`, `;`, or `as` ... LL | import! { a::b::c } | ------------------- in this macro invocation diff --git a/src/test/ui/invalid/invalid-variadic-function.stderr b/src/test/ui/invalid/invalid-variadic-function.stderr index fd20bd84edc..7e58b17e7db 100644 --- a/src/test/ui/invalid/invalid-variadic-function.stderr +++ b/src/test/ui/invalid/invalid-variadic-function.stderr @@ -8,7 +8,7 @@ error: expected one of `->`, `where`, or `{`, found `;` --> $DIR/invalid-variadic-function.rs:1:30 | LL | extern "C" fn foo(x: u8, ...); - | ^ expected one of `->`, `where`, or `{` here + | ^ expected one of `->`, `where`, or `{` error: aborting due to 2 previous errors diff --git a/src/test/ui/issues/issue-20616-1.stderr b/src/test/ui/issues/issue-20616-1.stderr index 143486c8f5a..81604623785 100644 --- a/src/test/ui/issues/issue-20616-1.stderr +++ b/src/test/ui/issues/issue-20616-1.stderr @@ -2,7 +2,7 @@ error: expected one of `,`, `:`, or `>`, found `T` --> $DIR/issue-20616-1.rs:9:16 | LL | type Type_1<'a T> = &'a T; - | ^ expected one of `,`, `:`, or `>` here + | ^ expected one of `,`, `:`, or `>` error: aborting due to previous error diff --git a/src/test/ui/issues/issue-20616-2.stderr b/src/test/ui/issues/issue-20616-2.stderr index 1152dec8bad..50ec7a304c5 100644 --- a/src/test/ui/issues/issue-20616-2.stderr +++ b/src/test/ui/issues/issue-20616-2.stderr @@ -2,7 +2,7 @@ error: expected one of `,` or `>`, found `(` --> $DIR/issue-20616-2.rs:12:31 | LL | type Type_2 = Type_1_<'static ()>; - | ^ expected one of `,` or `>` here + | ^ expected one of `,` or `>` error: aborting due to previous error diff --git a/src/test/ui/issues/issue-20616-3.stderr b/src/test/ui/issues/issue-20616-3.stderr index f51fb949c74..cc4d79484e7 100644 --- a/src/test/ui/issues/issue-20616-3.stderr +++ b/src/test/ui/issues/issue-20616-3.stderr @@ -2,7 +2,7 @@ error: expected one of `>`, const, identifier, lifetime, or type, found `,` --> $DIR/issue-20616-3.rs:13:24 | LL | type Type_3 = Box; - | ^ expected one of `>`, const, identifier, lifetime, or type here + | ^ expected one of `>`, const, identifier, lifetime, or type error: aborting due to previous error diff --git a/src/test/ui/issues/issue-20616-4.stderr b/src/test/ui/issues/issue-20616-4.stderr index 22a655465e8..254e4d6a34d 100644 --- a/src/test/ui/issues/issue-20616-4.stderr +++ b/src/test/ui/issues/issue-20616-4.stderr @@ -2,7 +2,7 @@ error: expected one of `>`, const, identifier, lifetime, or type, found `,` --> $DIR/issue-20616-4.rs:16:34 | LL | type Type_4 = Type_1_<'static,, T>; - | ^ expected one of `>`, const, identifier, lifetime, or type here + | ^ expected one of `>`, const, identifier, lifetime, or type error: aborting due to previous error diff --git a/src/test/ui/issues/issue-20616-5.stderr b/src/test/ui/issues/issue-20616-5.stderr index d83fc41f43e..aee8bf01a43 100644 --- a/src/test/ui/issues/issue-20616-5.stderr +++ b/src/test/ui/issues/issue-20616-5.stderr @@ -2,7 +2,7 @@ error: expected one of `>`, const, identifier, lifetime, or type, found `,` --> $DIR/issue-20616-5.rs:22:34 | LL | type Type_5<'a> = Type_1_<'a, (),,>; - | ^ expected one of `>`, const, identifier, lifetime, or type here + | ^ expected one of `>`, const, identifier, lifetime, or type error: aborting due to previous error diff --git a/src/test/ui/issues/issue-20616-6.stderr b/src/test/ui/issues/issue-20616-6.stderr index 0740df59523..7192a87bc18 100644 --- a/src/test/ui/issues/issue-20616-6.stderr +++ b/src/test/ui/issues/issue-20616-6.stderr @@ -2,7 +2,7 @@ error: expected one of `>`, const, identifier, lifetime, or type, found `,` --> $DIR/issue-20616-6.rs:25:26 | LL | type Type_6 = Type_5_<'a,,>; - | ^ expected one of `>`, const, identifier, lifetime, or type here + | ^ expected one of `>`, const, identifier, lifetime, or type error: aborting due to previous error diff --git a/src/test/ui/issues/issue-20616-7.stderr b/src/test/ui/issues/issue-20616-7.stderr index c0e108375be..123dc1e2b7d 100644 --- a/src/test/ui/issues/issue-20616-7.stderr +++ b/src/test/ui/issues/issue-20616-7.stderr @@ -2,7 +2,7 @@ error: expected one of `>`, const, identifier, lifetime, or type, found `,` --> $DIR/issue-20616-7.rs:28:22 | LL | type Type_7 = Box<(),,>; - | ^ expected one of `>`, const, identifier, lifetime, or type here + | ^ expected one of `>`, const, identifier, lifetime, or type error: aborting due to previous error diff --git a/src/test/ui/issues/issue-20616-8.stderr b/src/test/ui/issues/issue-20616-8.stderr index 0ef9192f1e7..479469634c5 100644 --- a/src/test/ui/issues/issue-20616-8.stderr +++ b/src/test/ui/issues/issue-20616-8.stderr @@ -2,7 +2,7 @@ error: expected one of `>`, `const`, identifier, or lifetime, found `,` --> $DIR/issue-20616-8.rs:31:16 | LL | type Type_8<'a,,> = &'a (); - | ^ expected one of `>`, `const`, identifier, or lifetime here + | ^ expected one of `>`, `const`, identifier, or lifetime error: aborting due to previous error diff --git a/src/test/ui/issues/issue-20616-9.stderr b/src/test/ui/issues/issue-20616-9.stderr index 5fd1400a2e8..b7e3322b7aa 100644 --- a/src/test/ui/issues/issue-20616-9.stderr +++ b/src/test/ui/issues/issue-20616-9.stderr @@ -2,7 +2,7 @@ error: expected one of `>`, `const`, identifier, or lifetime, found `,` --> $DIR/issue-20616-9.rs:34:15 | LL | type Type_9 = Box; - | ^ expected one of `>`, `const`, identifier, or lifetime here + | ^ expected one of `>`, `const`, identifier, or lifetime error: aborting due to previous error diff --git a/src/test/ui/issues/issue-21146.stderr b/src/test/ui/issues/issue-21146.stderr index 2798196ea00..c71fda3d63f 100644 --- a/src/test/ui/issues/issue-21146.stderr +++ b/src/test/ui/issues/issue-21146.stderr @@ -2,7 +2,7 @@ error: expected one of `!` or `::`, found `` --> $DIR/auxiliary/issue-21146-inc.rs:3:1 | LL | parse_error - | ^^^^^^^^^^^ expected one of `!` or `::` here + | ^^^^^^^^^^^ expected one of `!` or `::` error: aborting due to previous error diff --git a/src/test/ui/issues/issue-34334.stderr b/src/test/ui/issues/issue-34334.stderr index 8d52e08374a..a3749487ac9 100644 --- a/src/test/ui/issues/issue-34334.stderr +++ b/src/test/ui/issues/issue-34334.stderr @@ -14,7 +14,7 @@ error: expected one of `,` or `>`, found `=` --> $DIR/issue-34334.rs:2:29 | LL | let sr: Vec<(u32, _, _) = vec![]; - | --- ^ expected one of `,` or `>` here + | --- ^ expected one of `,` or `>` | | | | | help: use `=` if you meant to assign | while parsing the type for `sr` diff --git a/src/test/ui/issues/issue-39616.stderr b/src/test/ui/issues/issue-39616.stderr index 75eb55fa50b..74e94eda51f 100644 --- a/src/test/ui/issues/issue-39616.stderr +++ b/src/test/ui/issues/issue-39616.stderr @@ -8,7 +8,7 @@ error: expected one of `)`, `,`, `->`, `where`, or `{`, found `]` --> $DIR/issue-39616.rs:1:16 | LL | fn foo(a: [0; 1]) {} - | ^ expected one of `)`, `,`, `->`, `where`, or `{` here + | ^ expected one of `)`, `,`, `->`, `where`, or `{` error: aborting due to 2 previous errors diff --git a/src/test/ui/issues/issue-44021.stderr b/src/test/ui/issues/issue-44021.stderr index 94500087e55..b888cd989a6 100644 --- a/src/test/ui/issues/issue-44021.stderr +++ b/src/test/ui/issues/issue-44021.stderr @@ -2,7 +2,7 @@ error: expected one of `:`, `@`, or `|`, found `}` --> $DIR/issue-44021.rs:3:18 | LL | fn f() {|x, y} - | ^ expected one of `:`, `@`, or `|` here + | ^ expected one of `:`, `@`, or `|` error: aborting due to previous error diff --git a/src/test/ui/issues/issue-52496.stderr b/src/test/ui/issues/issue-52496.stderr index 43009a15bd4..10fcc46f344 100644 --- a/src/test/ui/issues/issue-52496.stderr +++ b/src/test/ui/issues/issue-52496.stderr @@ -8,7 +8,7 @@ error: expected one of `,` or `}`, found `.` --> $DIR/issue-52496.rs:8:22 | LL | let _ = Foo { bar.into(), bat: -1, . }; - | --- ^ expected one of `,` or `}` here + | --- ^ expected one of `,` or `}` | | | while parsing this struct diff --git a/src/test/ui/issues/issue-58856-2.stderr b/src/test/ui/issues/issue-58856-2.stderr index a83dd674a87..01d70d861e2 100644 --- a/src/test/ui/issues/issue-58856-2.stderr +++ b/src/test/ui/issues/issue-58856-2.stderr @@ -11,7 +11,7 @@ error: expected one of `async`, `const`, `crate`, `default`, `extern`, `fn`, `pu --> $DIR/issue-58856-2.rs:11:1 | LL | } - | - expected one of 10 possible tokens here + | - expected one of 10 possible tokens LL | } | ^ unexpected token diff --git a/src/test/ui/issues/issue-60075.stderr b/src/test/ui/issues/issue-60075.stderr index 961a546d8d6..39e3ad7b6b4 100644 --- a/src/test/ui/issues/issue-60075.stderr +++ b/src/test/ui/issues/issue-60075.stderr @@ -2,7 +2,7 @@ error: expected one of `.`, `;`, `?`, `else`, or an operator, found `}` --> $DIR/issue-60075.rs:6:10 | LL | }); - | ^ expected one of `.`, `;`, `?`, `else`, or an operator here + | ^ expected one of `.`, `;`, `?`, `else`, or an operator error: expected one of `async`, `const`, `extern`, `fn`, `type`, `unsafe`, or `}`, found `;` --> $DIR/issue-60075.rs:6:11 diff --git a/src/test/ui/label/label_break_value_illegal_uses.stderr b/src/test/ui/label/label_break_value_illegal_uses.stderr index 80b4329ad40..0036f0f1db0 100644 --- a/src/test/ui/label/label_break_value_illegal_uses.stderr +++ b/src/test/ui/label/label_break_value_illegal_uses.stderr @@ -2,7 +2,7 @@ error: expected one of `extern`, `fn`, or `{`, found `'b` --> $DIR/label_break_value_illegal_uses.rs:6:12 | LL | unsafe 'b: {} - | ^^ expected one of `extern`, `fn`, or `{` here + | ^^ expected one of `extern`, `fn`, or `{` error: expected `{`, found `'b` --> $DIR/label_break_value_illegal_uses.rs:10:13 @@ -27,7 +27,7 @@ error: expected one of `.`, `?`, `{`, or an operator, found `'b` --> $DIR/label_break_value_illegal_uses.rs:18:17 | LL | match false 'b: {} - | ----- ^^ expected one of `.`, `?`, `{`, or an operator here + | ----- ^^ expected one of `.`, `?`, `{`, or an operator | | | while parsing this match expression diff --git a/src/test/ui/macro_backtrace/main.stderr b/src/test/ui/macro_backtrace/main.stderr index e7bd141ccd5..c4950e0fdf5 100644 --- a/src/test/ui/macro_backtrace/main.stderr +++ b/src/test/ui/macro_backtrace/main.stderr @@ -3,7 +3,7 @@ error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found | LL | / macro_rules! pong { LL | | () => { syntax error }; - | | ^^^^^ expected one of 8 possible tokens here + | | ^^^^^ expected one of 8 possible tokens LL | | } | |_- in this expansion of `pong!` ... @@ -15,7 +15,7 @@ error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found | LL | / macro_rules! pong { LL | | () => { syntax error }; - | | ^^^^^ expected one of 8 possible tokens here + | | ^^^^^ expected one of 8 possible tokens LL | | } | |_- in this expansion of `pong!` ... @@ -35,7 +35,7 @@ error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found | LL | / macro_rules! pong { LL | | () => { syntax error }; - | | ^^^^^ expected one of 8 possible tokens here + | | ^^^^^ expected one of 8 possible tokens LL | | } | |_- in this expansion of `pong!` (#5) ... diff --git a/src/test/ui/macros/assert-trailing-junk.stderr b/src/test/ui/macros/assert-trailing-junk.stderr index 6fc0a278461..4d18a531a80 100644 --- a/src/test/ui/macros/assert-trailing-junk.stderr +++ b/src/test/ui/macros/assert-trailing-junk.stderr @@ -2,13 +2,13 @@ error: expected one of `,`, `.`, `?`, or an operator, found `some` --> $DIR/assert-trailing-junk.rs:6:18 | LL | assert!(true some extra junk, "whatever"); - | ^^^^ expected one of `,`, `.`, `?`, or an operator here + | ^^^^ expected one of `,`, `.`, `?`, or an operator error: expected one of `,`, `.`, `?`, or an operator, found `some` --> $DIR/assert-trailing-junk.rs:9:18 | LL | assert!(true some extra junk); - | ^^^^ expected one of `,`, `.`, `?`, or an operator here + | ^^^^ expected one of `,`, `.`, `?`, or an operator error: no rules expected the token `blah` --> $DIR/assert-trailing-junk.rs:12:30 diff --git a/src/test/ui/macros/issue-54441.stderr b/src/test/ui/macros/issue-54441.stderr index 287d579c76d..1139ef06a12 100644 --- a/src/test/ui/macros/issue-54441.stderr +++ b/src/test/ui/macros/issue-54441.stderr @@ -2,7 +2,7 @@ error: expected one of `crate`, `fn`, `pub`, `static`, or `type`, found keyword --> $DIR/issue-54441.rs:3:9 | LL | let - | ^^^ expected one of `crate`, `fn`, `pub`, `static`, or `type` here + | ^^^ expected one of `crate`, `fn`, `pub`, `static`, or `type` ... LL | m!(); | ----- in this macro invocation diff --git a/src/test/ui/malformed/malformed-derive-entry.stderr b/src/test/ui/malformed/malformed-derive-entry.stderr index f7500febe97..8d750b66838 100644 --- a/src/test/ui/malformed/malformed-derive-entry.stderr +++ b/src/test/ui/malformed/malformed-derive-entry.stderr @@ -2,13 +2,13 @@ error: expected one of `)`, `,`, or `::`, found `(` --> $DIR/malformed-derive-entry.rs:1:14 | LL | #[derive(Copy(Bad))] - | ^ expected one of `)`, `,`, or `::` here + | ^ expected one of `)`, `,`, or `::` error: expected one of `)`, `,`, or `::`, found `=` --> $DIR/malformed-derive-entry.rs:4:14 | LL | #[derive(Copy="bad")] - | ^ expected one of `)`, `,`, or `::` here + | ^ expected one of `)`, `,`, or `::` error: malformed `derive` attribute input --> $DIR/malformed-derive-entry.rs:7:1 diff --git a/src/test/ui/mismatched_types/recovered-block.stderr b/src/test/ui/mismatched_types/recovered-block.stderr index 207dc78a4b9..525d09b8fc1 100644 --- a/src/test/ui/mismatched_types/recovered-block.stderr +++ b/src/test/ui/mismatched_types/recovered-block.stderr @@ -13,7 +13,7 @@ error: expected one of `(` or `<`, found `{` --> $DIR/recovered-block.rs:19:9 | LL | Foo { text: "".to_string() } - | ^ expected one of `(` or `<` here + | ^ expected one of `(` or `<` error: aborting due to 2 previous errors diff --git a/src/test/ui/missing/missing-comma-in-match.fixed b/src/test/ui/missing/missing-comma-in-match.fixed index de1b9506af9..f091082f35f 100644 --- a/src/test/ui/missing/missing-comma-in-match.fixed +++ b/src/test/ui/missing/missing-comma-in-match.fixed @@ -5,7 +5,7 @@ fn main() { &None => 1, &Some(2) => { 3 } //~^ ERROR expected one of `,`, `.`, `?`, `}`, or an operator, found `=>` - //~| NOTE expected one of `,`, `.`, `?`, `}`, or an operator here + //~| NOTE expected one of `,`, `.`, `?`, `}`, or an operator _ => 2 }; } diff --git a/src/test/ui/missing/missing-comma-in-match.rs b/src/test/ui/missing/missing-comma-in-match.rs index d7d16155cf2..54dab4e9750 100644 --- a/src/test/ui/missing/missing-comma-in-match.rs +++ b/src/test/ui/missing/missing-comma-in-match.rs @@ -5,7 +5,7 @@ fn main() { &None => 1 &Some(2) => { 3 } //~^ ERROR expected one of `,`, `.`, `?`, `}`, or an operator, found `=>` - //~| NOTE expected one of `,`, `.`, `?`, `}`, or an operator here + //~| NOTE expected one of `,`, `.`, `?`, `}`, or an operator _ => 2 }; } diff --git a/src/test/ui/missing/missing-comma-in-match.stderr b/src/test/ui/missing/missing-comma-in-match.stderr index ae46516f8d1..fe210f697c4 100644 --- a/src/test/ui/missing/missing-comma-in-match.stderr +++ b/src/test/ui/missing/missing-comma-in-match.stderr @@ -4,7 +4,7 @@ error: expected one of `,`, `.`, `?`, `}`, or an operator, found `=>` LL | &None => 1 | - help: missing a comma here to end this `match` arm LL | &Some(2) => { 3 } - | ^^ expected one of `,`, `.`, `?`, `}`, or an operator here + | ^^ expected one of `,`, `.`, `?`, `}`, or an operator error: aborting due to previous error diff --git a/src/test/ui/on-unimplemented/expected-comma-found-token.stderr b/src/test/ui/on-unimplemented/expected-comma-found-token.stderr index 5bbdbe29416..738bf7c6c6b 100644 --- a/src/test/ui/on-unimplemented/expected-comma-found-token.stderr +++ b/src/test/ui/on-unimplemented/expected-comma-found-token.stderr @@ -2,7 +2,7 @@ error: expected one of `)` or `,`, found `label` --> $DIR/expected-comma-found-token.rs:9:5 | LL | message="the message" - | - expected one of `)` or `,` here + | - expected one of `)` or `,` LL | label="the label" | ^^^^^ unexpected token diff --git a/src/test/ui/parser/assoc-oddities-1.stderr b/src/test/ui/parser/assoc-oddities-1.stderr index 376ddf4d68b..acf71b4893a 100644 --- a/src/test/ui/parser/assoc-oddities-1.stderr +++ b/src/test/ui/parser/assoc-oddities-1.stderr @@ -2,7 +2,7 @@ error: expected one of `.`, `;`, `?`, or `}`, found `[` --> $DIR/assoc-oddities-1.rs:10:28 | LL | ..if c { a } else { b }[n]; - | ^ expected one of `.`, `;`, `?`, or `}` here + | ^ expected one of `.`, `;`, `?`, or `}` error: aborting due to previous error diff --git a/src/test/ui/parser/assoc-oddities-2.stderr b/src/test/ui/parser/assoc-oddities-2.stderr index 4b3893d2c17..d3b90c34c29 100644 --- a/src/test/ui/parser/assoc-oddities-2.stderr +++ b/src/test/ui/parser/assoc-oddities-2.stderr @@ -2,7 +2,7 @@ error: expected one of `.`, `;`, `?`, or `}`, found `[` --> $DIR/assoc-oddities-2.rs:5:29 | LL | x..if c { a } else { b }[n]; - | ^ expected one of `.`, `;`, `?`, or `}` here + | ^ expected one of `.`, `;`, `?`, or `}` error: aborting due to previous error diff --git a/src/test/ui/parser/associated-types-project-from-hrtb-explicit.stderr b/src/test/ui/parser/associated-types-project-from-hrtb-explicit.stderr index 7d0bb0965b6..17bd5b54738 100644 --- a/src/test/ui/parser/associated-types-project-from-hrtb-explicit.stderr +++ b/src/test/ui/parser/associated-types-project-from-hrtb-explicit.stderr @@ -13,7 +13,7 @@ error: expected one of `::` or `>`, found `Foo` --> $DIR/associated-types-project-from-hrtb-explicit.rs:10:29 | LL | fn foo2(x: Foo<&'x isize>>::A) - | ^^^ expected one of `::` or `>` here + | ^^^ expected one of `::` or `>` error: aborting due to 2 previous errors diff --git a/src/test/ui/parser/attr-bad-meta.stderr b/src/test/ui/parser/attr-bad-meta.stderr index a452df5e90c..8d65c423c8d 100644 --- a/src/test/ui/parser/attr-bad-meta.stderr +++ b/src/test/ui/parser/attr-bad-meta.stderr @@ -2,7 +2,7 @@ error: expected one of `(`, `::`, `=`, `[`, `]`, or `{`, found `*` --> $DIR/attr-bad-meta.rs:1:7 | LL | #[path*] - | ^ expected one of `(`, `::`, `=`, `[`, `]`, or `{` here + | ^ expected one of `(`, `::`, `=`, `[`, `]`, or `{` error: aborting due to previous error diff --git a/src/test/ui/parser/bad-match.stderr b/src/test/ui/parser/bad-match.stderr index d5baaf5e93b..13784c409cd 100644 --- a/src/test/ui/parser/bad-match.stderr +++ b/src/test/ui/parser/bad-match.stderr @@ -2,7 +2,7 @@ error: expected one of `:`, `;`, `=`, `@`, or `|`, found `x` --> $DIR/bad-match.rs:2:13 | LL | let isize x = 5; - | ^ expected one of `:`, `;`, `=`, `@`, or `|` here + | ^ expected one of `:`, `;`, `=`, `@`, or `|` error: aborting due to previous error diff --git a/src/test/ui/parser/bad-name.stderr b/src/test/ui/parser/bad-name.stderr index dce4dabedf5..a36b67794fa 100644 --- a/src/test/ui/parser/bad-name.stderr +++ b/src/test/ui/parser/bad-name.stderr @@ -2,7 +2,7 @@ error: expected one of `:`, `;`, `=`, `@`, or `|`, found `.` --> $DIR/bad-name.rs:4:8 | LL | let x.y::.z foo; - | ^ expected one of `:`, `;`, `=`, `@`, or `|` here + | ^ expected one of `:`, `;`, `=`, `@`, or `|` error: aborting due to previous error diff --git a/src/test/ui/parser/better-expected.stderr b/src/test/ui/parser/better-expected.stderr index d100d01e78f..21bf8d19a72 100644 --- a/src/test/ui/parser/better-expected.stderr +++ b/src/test/ui/parser/better-expected.stderr @@ -2,7 +2,7 @@ error: expected one of `!`, `(`, `+`, `::`, `;`, `<`, or `]`, found `3` --> $DIR/better-expected.rs:2:19 | LL | let x: [isize 3]; - | - ^ expected one of 7 possible tokens here + | - ^ expected one of 7 possible tokens | | | while parsing the type for `x` diff --git a/src/test/ui/parser/bounds-lifetime-1.stderr b/src/test/ui/parser/bounds-lifetime-1.stderr index 17d65314d96..000e84f635b 100644 --- a/src/test/ui/parser/bounds-lifetime-1.stderr +++ b/src/test/ui/parser/bounds-lifetime-1.stderr @@ -2,7 +2,7 @@ error: expected one of `,`, `:`, or `>`, found `'b` --> $DIR/bounds-lifetime-1.rs:1:17 | LL | type A = for<'a 'b> fn(); - | ^^ expected one of `,`, `:`, or `>` here + | ^^ expected one of `,`, `:`, or `>` error: aborting due to previous error diff --git a/src/test/ui/parser/bounds-lifetime-2.stderr b/src/test/ui/parser/bounds-lifetime-2.stderr index 587e527f0a8..dd3e69c1139 100644 --- a/src/test/ui/parser/bounds-lifetime-2.stderr +++ b/src/test/ui/parser/bounds-lifetime-2.stderr @@ -2,7 +2,7 @@ error: expected one of `,`, `:`, or `>`, found `+` --> $DIR/bounds-lifetime-2.rs:1:17 | LL | type A = for<'a + 'b> fn(); - | ^ expected one of `,`, `:`, or `>` here + | ^ expected one of `,`, `:`, or `>` error: aborting due to previous error diff --git a/src/test/ui/parser/bounds-lifetime-where.stderr b/src/test/ui/parser/bounds-lifetime-where.stderr index 9507a459858..05cebd6d351 100644 --- a/src/test/ui/parser/bounds-lifetime-where.stderr +++ b/src/test/ui/parser/bounds-lifetime-where.stderr @@ -2,7 +2,7 @@ error: expected one of `=`, lifetime, or type, found `,` --> $DIR/bounds-lifetime-where.rs:8:14 | LL | type A where , = u8; - | ^ expected one of `=`, lifetime, or type here + | ^ expected one of `=`, lifetime, or type error: aborting due to previous error diff --git a/src/test/ui/parser/bounds-lifetime.stderr b/src/test/ui/parser/bounds-lifetime.stderr index facbd280070..12b9b61ebd1 100644 --- a/src/test/ui/parser/bounds-lifetime.stderr +++ b/src/test/ui/parser/bounds-lifetime.stderr @@ -2,7 +2,7 @@ error: expected one of `>`, `const`, identifier, or lifetime, found `,` --> $DIR/bounds-lifetime.rs:9:14 | LL | type A = for<,> fn(); - | ^ expected one of `>`, `const`, identifier, or lifetime here + | ^ expected one of `>`, `const`, identifier, or lifetime error: aborting due to previous error diff --git a/src/test/ui/parser/bounds-type-where.stderr b/src/test/ui/parser/bounds-type-where.stderr index 459d5c3b6ea..5636ee75c97 100644 --- a/src/test/ui/parser/bounds-type-where.stderr +++ b/src/test/ui/parser/bounds-type-where.stderr @@ -2,7 +2,7 @@ error: expected one of `!`, `(`, `+`, `::`, `:`, `<`, `==`, or `=`, found `,` --> $DIR/bounds-type-where.rs:8:15 | LL | type A where T, = u8; - | ^ expected one of 8 possible tokens here + | ^ expected one of 8 possible tokens error: aborting due to previous error diff --git a/src/test/ui/parser/class-implements-bad-trait.stderr b/src/test/ui/parser/class-implements-bad-trait.stderr index 45583466adc..3a4dea95d5d 100644 --- a/src/test/ui/parser/class-implements-bad-trait.stderr +++ b/src/test/ui/parser/class-implements-bad-trait.stderr @@ -2,7 +2,7 @@ error: expected one of `!` or `::`, found `cat` --> $DIR/class-implements-bad-trait.rs:2:7 | LL | class cat : nonexistent { - | ^^^ expected one of `!` or `::` here + | ^^^ expected one of `!` or `::` error: aborting due to previous error diff --git a/src/test/ui/parser/closure-return-syntax.stderr b/src/test/ui/parser/closure-return-syntax.stderr index dd7ebffd506..bfb7f98c5f5 100644 --- a/src/test/ui/parser/closure-return-syntax.stderr +++ b/src/test/ui/parser/closure-return-syntax.stderr @@ -2,7 +2,7 @@ error: expected one of `!`, `(`, `+`, `::`, `<`, or `{`, found `22` --> $DIR/closure-return-syntax.rs:5:23 | LL | let x = || -> i32 22; - | ^^ expected one of `!`, `(`, `+`, `::`, `<`, or `{` here + | ^^ expected one of `!`, `(`, `+`, `::`, `<`, or `{` error: aborting due to previous error diff --git a/src/test/ui/parser/default.stderr b/src/test/ui/parser/default.stderr index 8843fd303ec..dde36cf8dde 100644 --- a/src/test/ui/parser/default.stderr +++ b/src/test/ui/parser/default.stderr @@ -2,7 +2,7 @@ error: expected one of `async`, `const`, `extern`, `fn`, `type`, or `unsafe`, fo --> $DIR/default.rs:22:13 | LL | default pub fn foo() -> T { T::default() } - | ^^^ expected one of `async`, `const`, `extern`, `fn`, `type`, or `unsafe` here + | ^^^ expected one of `async`, `const`, `extern`, `fn`, `type`, or `unsafe` error[E0449]: unnecessary visibility qualifier --> $DIR/default.rs:16:5 diff --git a/src/test/ui/parser/duplicate-visibility.stderr b/src/test/ui/parser/duplicate-visibility.stderr index 675adb88d20..313e88e812b 100644 --- a/src/test/ui/parser/duplicate-visibility.stderr +++ b/src/test/ui/parser/duplicate-visibility.stderr @@ -2,7 +2,7 @@ error: expected one of `(`, `fn`, `static`, or `type`, found keyword `pub` --> $DIR/duplicate-visibility.rs:3:9 | LL | pub pub fn foo(); - | ^^^ expected one of `(`, `fn`, `static`, or `type` here + | ^^^ expected one of `(`, `fn`, `static`, or `type` error: aborting due to previous error diff --git a/src/test/ui/parser/empty-impl-semicolon.stderr b/src/test/ui/parser/empty-impl-semicolon.stderr index 46f2393cd83..398eb5c898c 100644 --- a/src/test/ui/parser/empty-impl-semicolon.stderr +++ b/src/test/ui/parser/empty-impl-semicolon.stderr @@ -2,7 +2,7 @@ error: expected one of `!`, `(`, `+`, `::`, `<`, `for`, `where`, or `{`, found ` --> $DIR/empty-impl-semicolon.rs:1:9 | LL | impl Foo; - | ^ expected one of 8 possible tokens here + | ^ expected one of 8 possible tokens error: aborting due to previous error diff --git a/src/test/ui/parser/extern-crate-unexpected-token.stderr b/src/test/ui/parser/extern-crate-unexpected-token.stderr index 04edd46936a..0e745dc582f 100644 --- a/src/test/ui/parser/extern-crate-unexpected-token.stderr +++ b/src/test/ui/parser/extern-crate-unexpected-token.stderr @@ -2,7 +2,7 @@ error: expected one of `crate`, `fn`, or `{`, found `crte` --> $DIR/extern-crate-unexpected-token.rs:1:8 | LL | extern crte foo; - | ^^^^ expected one of `crate`, `fn`, or `{` here + | ^^^^ expected one of `crate`, `fn`, or `{` error: aborting due to previous error diff --git a/src/test/ui/parser/extern-expected-fn-or-brace.stderr b/src/test/ui/parser/extern-expected-fn-or-brace.stderr index 691f4cddff2..0ebe9a0d3ea 100644 --- a/src/test/ui/parser/extern-expected-fn-or-brace.stderr +++ b/src/test/ui/parser/extern-expected-fn-or-brace.stderr @@ -2,7 +2,7 @@ error: expected one of `fn` or `{`, found keyword `mod` --> $DIR/extern-expected-fn-or-brace.rs:4:12 | LL | extern "C" mod foo; - | ^^^ expected one of `fn` or `{` here + | ^^^ expected one of `fn` or `{` error: aborting due to previous error diff --git a/src/test/ui/parser/extern-foreign-crate.stderr b/src/test/ui/parser/extern-foreign-crate.stderr index de9f0c93232..eb75c0fc9c6 100644 --- a/src/test/ui/parser/extern-foreign-crate.stderr +++ b/src/test/ui/parser/extern-foreign-crate.stderr @@ -2,7 +2,7 @@ error: expected one of `;` or `as`, found `{` --> $DIR/extern-foreign-crate.rs:4:18 | LL | extern crate foo {} - | ^ expected one of `;` or `as` here + | ^ expected one of `;` or `as` error: aborting due to previous error diff --git a/src/test/ui/parser/inverted-parameters.stderr b/src/test/ui/parser/inverted-parameters.stderr index 2bda4460031..51e9087ffc1 100644 --- a/src/test/ui/parser/inverted-parameters.stderr +++ b/src/test/ui/parser/inverted-parameters.stderr @@ -4,7 +4,7 @@ error: expected one of `:`, `@`, or `|`, found `bar` LL | fn foo(&self, &str bar) {} | -----^^^ | | | - | | expected one of `:`, `@`, or `|` here + | | expected one of `:`, `@`, or `|` | help: declare the type after the parameter binding: `: ` error: expected one of `:`, `@`, or `|`, found `quux` @@ -13,26 +13,26 @@ error: expected one of `:`, `@`, or `|`, found `quux` LL | fn baz(S quux, xyzzy: i32) {} | --^^^^ | | | - | | expected one of `:`, `@`, or `|` here + | | expected one of `:`, `@`, or `|` | help: declare the type after the parameter binding: `: ` error: expected one of `:`, `@`, or `|`, found `a` --> $DIR/inverted-parameters.rs:15:12 | LL | fn one(i32 a b) {} - | ^ expected one of `:`, `@`, or `|` here + | ^ expected one of `:`, `@`, or `|` error: expected one of `:` or `|`, found `(` --> $DIR/inverted-parameters.rs:18:23 | LL | fn pattern((i32, i32) (a, b)) {} - | ^ expected one of `:` or `|` here + | ^ expected one of `:` or `|` error: expected one of `:`, `@`, or `|`, found `)` --> $DIR/inverted-parameters.rs:21:12 | LL | fn fizz(i32) {} - | ^ expected one of `:`, `@`, or `|` here + | ^ expected one of `:`, `@`, or `|` | = note: anonymous parameters are removed in the 2018 edition (see RFC 1685) help: if this was a parameter name, give it a type @@ -50,7 +50,7 @@ error: expected one of `:`, `@`, or `|`, found `S` LL | fn missing_colon(quux S) {} | -----^ | | | - | | expected one of `:`, `@`, or `|` here + | | expected one of `:`, `@`, or `|` | help: declare the type after the parameter binding: `: ` error: aborting due to 6 previous errors diff --git a/src/test/ui/parser/issue-15980.rs b/src/test/ui/parser/issue-15980.rs index beb94c8042d..87faa7d5ff1 100644 --- a/src/test/ui/parser/issue-15980.rs +++ b/src/test/ui/parser/issue-15980.rs @@ -9,7 +9,7 @@ fn main(){ //~^ ERROR expected identifier, found keyword `return` //~| NOTE expected identifier, found keyword } - //~^ NOTE expected one of `.`, `=>`, `?`, or an operator here + //~^ NOTE expected one of `.`, `=>`, `?`, or an operator _ => {} //~^ ERROR expected one of `.`, `=>`, `?`, or an operator, found reserved identifier `_` //~| NOTE unexpected token diff --git a/src/test/ui/parser/issue-15980.stderr b/src/test/ui/parser/issue-15980.stderr index 26f75d45fa2..5cefead2c74 100644 --- a/src/test/ui/parser/issue-15980.stderr +++ b/src/test/ui/parser/issue-15980.stderr @@ -16,7 +16,7 @@ error: expected one of `.`, `=>`, `?`, or an operator, found reserved identifier --> $DIR/issue-15980.rs:13:9 | LL | } - | - expected one of `.`, `=>`, `?`, or an operator here + | - expected one of `.`, `=>`, `?`, or an operator LL | LL | _ => {} | ^ unexpected token diff --git a/src/test/ui/parser/issue-17904.stderr b/src/test/ui/parser/issue-17904.stderr index 38f30099ed5..a3cac676189 100644 --- a/src/test/ui/parser/issue-17904.stderr +++ b/src/test/ui/parser/issue-17904.stderr @@ -2,7 +2,7 @@ error: expected one of `:`, `==`, or `=`, found `;` --> $DIR/issue-17904.rs:4:33 | LL | struct Foo where T: Copy, (T); - | ^ expected one of `:`, `==`, or `=` here + | ^ expected one of `:`, `==`, or `=` error: aborting due to previous error diff --git a/src/test/ui/parser/issue-19096.stderr b/src/test/ui/parser/issue-19096.stderr index 957b40dbd5e..4df7f878b9e 100644 --- a/src/test/ui/parser/issue-19096.stderr +++ b/src/test/ui/parser/issue-19096.stderr @@ -2,13 +2,13 @@ error: expected one of `.`, `;`, `?`, `}`, or an operator, found `::` --> $DIR/issue-19096.rs:3:8 | LL | t.0::; - | ^^ expected one of `.`, `;`, `?`, `}`, or an operator here + | ^^ expected one of `.`, `;`, `?`, `}`, or an operator error: expected one of `.`, `;`, `?`, `}`, or an operator, found `::` --> $DIR/issue-19096.rs:8:8 | LL | t.0::; - | ^^ expected one of `.`, `;`, `?`, `}`, or an operator here + | ^^ expected one of `.`, `;`, `?`, `}`, or an operator error: aborting due to 2 previous errors diff --git a/src/test/ui/parser/issue-20711-2.stderr b/src/test/ui/parser/issue-20711-2.stderr index 56749c107d1..ee484890fad 100644 --- a/src/test/ui/parser/issue-20711-2.stderr +++ b/src/test/ui/parser/issue-20711-2.stderr @@ -2,7 +2,7 @@ error: expected one of `async`, `const`, `crate`, `default`, `extern`, `fn`, `pu --> $DIR/issue-20711-2.rs:7:1 | LL | #[stable(feature = "rust1", since = "1.0.0")] - | - expected one of 9 possible tokens here + | - expected one of 9 possible tokens LL | } | ^ unexpected token diff --git a/src/test/ui/parser/issue-20711.stderr b/src/test/ui/parser/issue-20711.stderr index f7b99a91b51..152c9f1c689 100644 --- a/src/test/ui/parser/issue-20711.stderr +++ b/src/test/ui/parser/issue-20711.stderr @@ -2,7 +2,7 @@ error: expected one of `async`, `const`, `crate`, `default`, `extern`, `fn`, `pu --> $DIR/issue-20711.rs:5:1 | LL | #[stable(feature = "rust1", since = "1.0.0")] - | - expected one of 9 possible tokens here + | - expected one of 9 possible tokens LL | } | ^ unexpected token diff --git a/src/test/ui/parser/issue-22647.stderr b/src/test/ui/parser/issue-22647.stderr index 4b1ef4f3dfc..89b454d1973 100644 --- a/src/test/ui/parser/issue-22647.stderr +++ b/src/test/ui/parser/issue-22647.stderr @@ -2,7 +2,7 @@ error: expected one of `:`, `;`, `=`, `@`, or `|`, found `<` --> $DIR/issue-22647.rs:2:15 | LL | let caller = |f: F| - | ^ expected one of `:`, `;`, `=`, `@`, or `|` here + | ^ expected one of `:`, `;`, `=`, `@`, or `|` error: aborting due to previous error diff --git a/src/test/ui/parser/issue-22712.stderr b/src/test/ui/parser/issue-22712.stderr index d9e83144b36..30fabac6564 100644 --- a/src/test/ui/parser/issue-22712.stderr +++ b/src/test/ui/parser/issue-22712.stderr @@ -2,7 +2,7 @@ error: expected one of `:`, `;`, `=`, `@`, or `|`, found `<` --> $DIR/issue-22712.rs:6:12 | LL | let Foo> - | ^ expected one of `:`, `;`, `=`, `@`, or `|` here + | ^ expected one of `:`, `;`, `=`, `@`, or `|` error: aborting due to previous error diff --git a/src/test/ui/parser/issue-24197.stderr b/src/test/ui/parser/issue-24197.stderr index 24818db622a..fd7015ccd39 100644 --- a/src/test/ui/parser/issue-24197.stderr +++ b/src/test/ui/parser/issue-24197.stderr @@ -2,7 +2,7 @@ error: expected one of `:`, `;`, `=`, `@`, or `|`, found `[` --> $DIR/issue-24197.rs:2:12 | LL | let buf[0] = 0; - | ^ expected one of `:`, `;`, `=`, `@`, or `|` here + | ^ expected one of `:`, `;`, `=`, `@`, or `|` error: aborting due to previous error diff --git a/src/test/ui/parser/issue-24375.stderr b/src/test/ui/parser/issue-24375.stderr index e45b08be9ab..7aed88768a0 100644 --- a/src/test/ui/parser/issue-24375.stderr +++ b/src/test/ui/parser/issue-24375.stderr @@ -2,7 +2,7 @@ error: expected one of `=>`, `@`, `if`, or `|`, found `[` --> $DIR/issue-24375.rs:6:12 | LL | tmp[0] => {} - | ^ expected one of `=>`, `@`, `if`, or `|` here + | ^ expected one of `=>`, `@`, `if`, or `|` error: aborting due to previous error diff --git a/src/test/ui/parser/issue-24780.stderr b/src/test/ui/parser/issue-24780.stderr index 469c034795e..d9470191b25 100644 --- a/src/test/ui/parser/issue-24780.stderr +++ b/src/test/ui/parser/issue-24780.stderr @@ -2,7 +2,7 @@ error: expected one of `!`, `+`, `::`, `where`, or `{`, found `>` --> $DIR/issue-24780.rs:5:23 | LL | fn foo() -> Vec> { - | ^ expected one of `!`, `+`, `::`, `where`, or `{` here + | ^ expected one of `!`, `+`, `::`, `where`, or `{` error: aborting due to previous error diff --git a/src/test/ui/parser/issue-32446.stderr b/src/test/ui/parser/issue-32446.stderr index b0c18f4ec5a..ab37dd7c39d 100644 --- a/src/test/ui/parser/issue-32446.stderr +++ b/src/test/ui/parser/issue-32446.stderr @@ -2,7 +2,7 @@ error: expected one of `async`, `const`, `extern`, `fn`, `type`, `unsafe`, or `} --> $DIR/issue-32446.rs:4:11 | LL | trait T { ... } - | ^^^ expected one of 7 possible tokens here + | ^^^ expected one of 7 possible tokens error: aborting due to previous error diff --git a/src/test/ui/parser/issue-33455.stderr b/src/test/ui/parser/issue-33455.stderr index 4516c388afc..c535ef23b22 100644 --- a/src/test/ui/parser/issue-33455.stderr +++ b/src/test/ui/parser/issue-33455.stderr @@ -2,7 +2,7 @@ error: expected one of `::`, `;`, or `as`, found `.` --> $DIR/issue-33455.rs:1:8 | LL | use foo.bar; - | ^ expected one of `::`, `;`, or `as` here + | ^ expected one of `::`, `;`, or `as` error: aborting due to previous error diff --git a/src/test/ui/parser/issue-41155.stderr b/src/test/ui/parser/issue-41155.stderr index 624d1a3d11e..0e191eb7e0a 100644 --- a/src/test/ui/parser/issue-41155.stderr +++ b/src/test/ui/parser/issue-41155.stderr @@ -2,7 +2,7 @@ error: expected one of `(`, `async`, `const`, `default`, `extern`, `fn`, `type`, --> $DIR/issue-41155.rs:5:1 | LL | pub - | - expected one of 8 possible tokens here + | - expected one of 8 possible tokens LL | } | ^ unexpected token diff --git a/src/test/ui/parser/issue-62660.stderr b/src/test/ui/parser/issue-62660.stderr index 3a8f6797b82..0844da1bd92 100644 --- a/src/test/ui/parser/issue-62660.stderr +++ b/src/test/ui/parser/issue-62660.stderr @@ -2,7 +2,7 @@ error: expected one of `!`, `(`, `+`, `,`, `::`, `<`, or `>`, found `)` --> $DIR/issue-62660.rs:7:38 | LL | pub fn foo(_: i32, self: Box $DIR/issue-62973.rs:6:25 | LL | fn p() { match s { v, E { [) {) } - | - - -^ expected one of `,` or `}` here + | - - -^ expected one of `,` or `}` | | | | | | | help: `}` may belong here | | while parsing this struct @@ -42,7 +42,7 @@ LL | fn p() { match s { v, E { [) {) } | ----- while parsing this match expression LL | LL | - | ^ expected one of `.`, `?`, `{`, or an operator here + | ^ expected one of `.`, `?`, `{`, or an operator error: incorrect close delimiter: `)` --> $DIR/issue-62973.rs:6:28 diff --git a/src/test/ui/parser/issue-63135.stderr b/src/test/ui/parser/issue-63135.stderr index 8e8087978a3..152601b3538 100644 --- a/src/test/ui/parser/issue-63135.stderr +++ b/src/test/ui/parser/issue-63135.stderr @@ -32,7 +32,7 @@ error: expected one of `:` or `|`, found `)` --> $DIR/issue-63135.rs:3:16 | LL | fn i(n{...,f # - | ^ expected one of `:` or `|` here + | ^ expected one of `:` or `|` error: aborting due to 5 previous errors diff --git a/src/test/ui/parser/lifetime-semicolon.stderr b/src/test/ui/parser/lifetime-semicolon.stderr index 71ed8200e9a..4641c286cb8 100644 --- a/src/test/ui/parser/lifetime-semicolon.stderr +++ b/src/test/ui/parser/lifetime-semicolon.stderr @@ -2,7 +2,7 @@ error: expected one of `,` or `>`, found `;` --> $DIR/lifetime-semicolon.rs:5:30 | LL | fn foo<'a, 'b>(x: &mut Foo<'a; 'b>) {} - | ^ expected one of `,` or `>` here + | ^ expected one of `,` or `>` error: aborting due to previous error diff --git a/src/test/ui/parser/macro/issue-37234.stderr b/src/test/ui/parser/macro/issue-37234.stderr index 004de9d905f..8cef5ae3758 100644 --- a/src/test/ui/parser/macro/issue-37234.stderr +++ b/src/test/ui/parser/macro/issue-37234.stderr @@ -2,7 +2,7 @@ error: expected one of `.`, `;`, `?`, or an operator, found `""` --> $DIR/issue-37234.rs:3:19 | LL | let x = 5 ""; - | ^^ expected one of `.`, `;`, `?`, or an operator here + | ^^ expected one of `.`, `;`, `?`, or an operator ... LL | failed!(); | ---------- in this macro invocation diff --git a/src/test/ui/parser/macro/macro-incomplete-parse.stderr b/src/test/ui/parser/macro/macro-incomplete-parse.stderr index e40919cda94..46cccba74c0 100644 --- a/src/test/ui/parser/macro/macro-incomplete-parse.stderr +++ b/src/test/ui/parser/macro/macro-incomplete-parse.stderr @@ -13,7 +13,7 @@ error: expected one of `.`, `;`, `?`, `}`, or an operator, found `,` --> $DIR/macro-incomplete-parse.rs:10:14 | LL | () => ( 1, - | ^ expected one of `.`, `;`, `?`, `}`, or an operator here + | ^ expected one of `.`, `;`, `?`, `}`, or an operator ... LL | ignored_expr!(); | ---------------- in this macro invocation diff --git a/src/test/ui/parser/macro/trait-non-item-macros.stderr b/src/test/ui/parser/macro/trait-non-item-macros.stderr index a953e23a710..dd97a3afa99 100644 --- a/src/test/ui/parser/macro/trait-non-item-macros.stderr +++ b/src/test/ui/parser/macro/trait-non-item-macros.stderr @@ -2,7 +2,7 @@ error: expected one of `async`, `const`, `extern`, `fn`, `type`, or `unsafe`, fo --> $DIR/trait-non-item-macros.rs:2:19 | LL | ($a:expr) => ($a) - | ^^ expected one of `async`, `const`, `extern`, `fn`, `type`, or `unsafe` here + | ^^ expected one of `async`, `const`, `extern`, `fn`, `type`, or `unsafe` ... LL | bah!(2); | -------- in this macro invocation diff --git a/src/test/ui/parser/macros-no-semicolon.stderr b/src/test/ui/parser/macros-no-semicolon.stderr index 09925eae51d..9492191b8df 100644 --- a/src/test/ui/parser/macros-no-semicolon.stderr +++ b/src/test/ui/parser/macros-no-semicolon.stderr @@ -2,7 +2,7 @@ error: expected one of `.`, `;`, `?`, `}`, or an operator, found `assert_eq` --> $DIR/macros-no-semicolon.rs:3:5 | LL | assert_eq!(1, 2) - | - expected one of `.`, `;`, `?`, `}`, or an operator here + | - expected one of `.`, `;`, `?`, `}`, or an operator LL | assert_eq!(3, 4) | ^^^^^^^^^ unexpected token diff --git a/src/test/ui/parser/match-refactor-to-expr.rs b/src/test/ui/parser/match-refactor-to-expr.rs index 09ebb2e1d83..e10ebf2e2d6 100644 --- a/src/test/ui/parser/match-refactor-to-expr.rs +++ b/src/test/ui/parser/match-refactor-to-expr.rs @@ -2,7 +2,7 @@ fn main() { let foo = match //~ NOTE while parsing this match expression Some(4).unwrap_or_else(5) - //~^ NOTE expected one of `.`, `?`, `{`, or an operator here + //~^ NOTE expected one of `.`, `?`, `{`, or an operator ; //~ NOTE unexpected token //~^ ERROR expected one of `.`, `?`, `{`, or an operator, found `;` diff --git a/src/test/ui/parser/match-refactor-to-expr.stderr b/src/test/ui/parser/match-refactor-to-expr.stderr index bf20bc93500..5cbf0232bc3 100644 --- a/src/test/ui/parser/match-refactor-to-expr.stderr +++ b/src/test/ui/parser/match-refactor-to-expr.stderr @@ -7,7 +7,7 @@ LL | match | while parsing this match expression | help: try removing this `match` LL | Some(4).unwrap_or_else(5) - | - expected one of `.`, `?`, `{`, or an operator here + | - expected one of `.`, `?`, `{`, or an operator LL | LL | ; | ^ unexpected token diff --git a/src/test/ui/parser/mismatched-braces/missing-close-brace-in-impl-trait.stderr b/src/test/ui/parser/mismatched-braces/missing-close-brace-in-impl-trait.stderr index 9bf54181a07..e1aed8a6b4e 100644 --- a/src/test/ui/parser/mismatched-braces/missing-close-brace-in-impl-trait.stderr +++ b/src/test/ui/parser/mismatched-braces/missing-close-brace-in-impl-trait.stderr @@ -16,7 +16,7 @@ LL | LL | fn foo(&self) {} | - | | - | expected one of 10 possible tokens here + | expected one of 10 possible tokens | help: `}` may belong here LL | LL | trait T { diff --git a/src/test/ui/parser/mismatched-braces/missing-close-brace-in-trait.stderr b/src/test/ui/parser/mismatched-braces/missing-close-brace-in-trait.stderr index 4bfb4c1cb3a..1bd8e445fad 100644 --- a/src/test/ui/parser/mismatched-braces/missing-close-brace-in-trait.stderr +++ b/src/test/ui/parser/mismatched-braces/missing-close-brace-in-trait.stderr @@ -15,7 +15,7 @@ LL | trait T { LL | fn foo(&self); | - | | - | expected one of 7 possible tokens here + | expected one of 7 possible tokens | help: `}` may belong here LL | LL | pub(crate) struct Bar(); diff --git a/src/test/ui/parser/missing_right_paren.stderr b/src/test/ui/parser/missing_right_paren.stderr index fc75b031e76..ac16ebe6412 100644 --- a/src/test/ui/parser/missing_right_paren.stderr +++ b/src/test/ui/parser/missing_right_paren.stderr @@ -11,7 +11,7 @@ error: expected one of `:` or `|`, found `)` --> $DIR/missing_right_paren.rs:3:11 | LL | fn main((ؼ - | ^ expected one of `:` or `|` here + | ^ expected one of `:` or `|` error: aborting due to 2 previous errors diff --git a/src/test/ui/parser/multitrait.stderr b/src/test/ui/parser/multitrait.stderr index 61dbc823848..5a8bb2f7a45 100644 --- a/src/test/ui/parser/multitrait.stderr +++ b/src/test/ui/parser/multitrait.stderr @@ -2,7 +2,7 @@ error: expected one of `!`, `(`, `+`, `::`, `<`, `for`, `where`, or `{`, found ` --> $DIR/multitrait.rs:5:9 | LL | impl Cmp, ToString for S { - | ^ expected one of 8 possible tokens here + | ^ expected one of 8 possible tokens error: aborting due to previous error diff --git a/src/test/ui/parser/not-a-pred.stderr b/src/test/ui/parser/not-a-pred.stderr index 46d6038e802..90246b92bf0 100644 --- a/src/test/ui/parser/not-a-pred.stderr +++ b/src/test/ui/parser/not-a-pred.stderr @@ -2,7 +2,7 @@ error: expected one of `->`, `where`, or `{`, found `:` --> $DIR/not-a-pred.rs:3:26 | LL | fn f(a: isize, b: isize) : lt(a, b) { } - | ^ expected one of `->`, `where`, or `{` here + | ^ expected one of `->`, `where`, or `{` error: aborting due to previous error diff --git a/src/test/ui/parser/omitted-arg-in-item-fn.stderr b/src/test/ui/parser/omitted-arg-in-item-fn.stderr index 7feb15592c5..c7c76a7f1d4 100644 --- a/src/test/ui/parser/omitted-arg-in-item-fn.stderr +++ b/src/test/ui/parser/omitted-arg-in-item-fn.stderr @@ -2,7 +2,7 @@ error: expected one of `:`, `@`, or `|`, found `)` --> $DIR/omitted-arg-in-item-fn.rs:1:9 | LL | fn foo(x) { - | ^ expected one of `:`, `@`, or `|` here + | ^ expected one of `:`, `@`, or `|` | = note: anonymous parameters are removed in the 2018 edition (see RFC 1685) help: if this was a parameter name, give it a type diff --git a/src/test/ui/parser/pat-lt-bracket-1.stderr b/src/test/ui/parser/pat-lt-bracket-1.stderr index 1bf27161513..e8ccbad668a 100644 --- a/src/test/ui/parser/pat-lt-bracket-1.stderr +++ b/src/test/ui/parser/pat-lt-bracket-1.stderr @@ -2,7 +2,7 @@ error: expected one of `=>`, `@`, `if`, or `|`, found `<` --> $DIR/pat-lt-bracket-1.rs:3:7 | LL | x < 7 => (), - | ^ expected one of `=>`, `@`, `if`, or `|` here + | ^ expected one of `=>`, `@`, `if`, or `|` error: aborting due to previous error diff --git a/src/test/ui/parser/pat-lt-bracket-2.stderr b/src/test/ui/parser/pat-lt-bracket-2.stderr index 2191e31ad1f..e51dd57f9c7 100644 --- a/src/test/ui/parser/pat-lt-bracket-2.stderr +++ b/src/test/ui/parser/pat-lt-bracket-2.stderr @@ -2,7 +2,7 @@ error: expected one of `:`, `@`, or `|`, found `<` --> $DIR/pat-lt-bracket-2.rs:1:7 | LL | fn a(B<) {} - | ^ expected one of `:`, `@`, or `|` here + | ^ expected one of `:`, `@`, or `|` | = note: anonymous parameters are removed in the 2018 edition (see RFC 1685) help: if this is a type, explicitly ignore the parameter name diff --git a/src/test/ui/parser/pat-lt-bracket-3.stderr b/src/test/ui/parser/pat-lt-bracket-3.stderr index 536d14e1b65..bacf868e3c4 100644 --- a/src/test/ui/parser/pat-lt-bracket-3.stderr +++ b/src/test/ui/parser/pat-lt-bracket-3.stderr @@ -2,7 +2,7 @@ error: expected one of `=>`, `@`, `if`, or `|`, found `<` --> $DIR/pat-lt-bracket-3.rs:6:16 | LL | Foo(x, y) => { - | ^ expected one of `=>`, `@`, `if`, or `|` here + | ^ expected one of `=>`, `@`, `if`, or `|` error: aborting due to previous error diff --git a/src/test/ui/parser/pat-lt-bracket-4.stderr b/src/test/ui/parser/pat-lt-bracket-4.stderr index d14702acee6..911c276b931 100644 --- a/src/test/ui/parser/pat-lt-bracket-4.stderr +++ b/src/test/ui/parser/pat-lt-bracket-4.stderr @@ -2,7 +2,7 @@ error: expected one of `=>`, `@`, `if`, or `|`, found `<` --> $DIR/pat-lt-bracket-4.rs:8:12 | LL | Foo::A(value) => value, - | ^ expected one of `=>`, `@`, `if`, or `|` here + | ^ expected one of `=>`, `@`, `if`, or `|` error: aborting due to previous error diff --git a/src/test/ui/parser/pat-lt-bracket-5.stderr b/src/test/ui/parser/pat-lt-bracket-5.stderr index 167314dde06..e23674bcec5 100644 --- a/src/test/ui/parser/pat-lt-bracket-5.stderr +++ b/src/test/ui/parser/pat-lt-bracket-5.stderr @@ -2,7 +2,7 @@ error: expected one of `:`, `;`, `=`, `@`, or `|`, found `[` --> $DIR/pat-lt-bracket-5.rs:2:10 | LL | let v[0] = v[1]; - | ^ expected one of `:`, `;`, `=`, `@`, or `|` here + | ^ expected one of `:`, `;`, `=`, `@`, or `|` error: aborting due to previous error diff --git a/src/test/ui/parser/pat-lt-bracket-6.stderr b/src/test/ui/parser/pat-lt-bracket-6.stderr index 6f08f0a9d95..234e0c37723 100644 --- a/src/test/ui/parser/pat-lt-bracket-6.stderr +++ b/src/test/ui/parser/pat-lt-bracket-6.stderr @@ -2,7 +2,7 @@ error: expected one of `)`, `,`, `@`, or `|`, found `[` --> $DIR/pat-lt-bracket-6.rs:5:19 | LL | let Test(&desc[..]) = x; - | ^ expected one of `)`, `,`, `@`, or `|` here + | ^ expected one of `)`, `,`, `@`, or `|` error[E0658]: subslice patterns are unstable --> $DIR/pat-lt-bracket-6.rs:5:20 diff --git a/src/test/ui/parser/pat-lt-bracket-7.stderr b/src/test/ui/parser/pat-lt-bracket-7.stderr index 196f1c0ae91..86693ac27bd 100644 --- a/src/test/ui/parser/pat-lt-bracket-7.stderr +++ b/src/test/ui/parser/pat-lt-bracket-7.stderr @@ -2,7 +2,7 @@ error: expected one of `)`, `,`, `@`, or `|`, found `[` --> $DIR/pat-lt-bracket-7.rs:5:16 | LL | for Thing(x[]) in foo {} - | ^ expected one of `)`, `,`, `@`, or `|` here + | ^ expected one of `)`, `,`, `@`, or `|` error[E0308]: mismatched types --> $DIR/pat-lt-bracket-7.rs:9:30 diff --git a/src/test/ui/parser/pat-ranges-1.stderr b/src/test/ui/parser/pat-ranges-1.stderr index 4e2c5d28381..b64a3ce5c08 100644 --- a/src/test/ui/parser/pat-ranges-1.stderr +++ b/src/test/ui/parser/pat-ranges-1.stderr @@ -2,7 +2,7 @@ error: expected one of `:`, `;`, `=`, or `|`, found `..=` --> $DIR/pat-ranges-1.rs:4:21 | LL | let macropus!() ..= 11 = 12; - | ^^^ expected one of `:`, `;`, `=`, or `|` here + | ^^^ expected one of `:`, `;`, `=`, or `|` error: aborting due to previous error diff --git a/src/test/ui/parser/pat-ranges-2.stderr b/src/test/ui/parser/pat-ranges-2.stderr index 64df56f5a61..1a9e33bebe9 100644 --- a/src/test/ui/parser/pat-ranges-2.stderr +++ b/src/test/ui/parser/pat-ranges-2.stderr @@ -2,7 +2,7 @@ error: expected one of `::`, `:`, `;`, `=`, or `|`, found `!` --> $DIR/pat-ranges-2.rs:4:26 | LL | let 10 ..= makropulos!() = 12; - | ^ expected one of `::`, `:`, `;`, `=`, or `|` here + | ^ expected one of `::`, `:`, `;`, `=`, or `|` error: aborting due to previous error diff --git a/src/test/ui/parser/pat-ranges-3.stderr b/src/test/ui/parser/pat-ranges-3.stderr index c32c18d98dc..c9787b789a8 100644 --- a/src/test/ui/parser/pat-ranges-3.stderr +++ b/src/test/ui/parser/pat-ranges-3.stderr @@ -2,7 +2,7 @@ error: expected one of `:`, `;`, `=`, or `|`, found `+` --> $DIR/pat-ranges-3.rs:4:19 | LL | let 10 ..= 10 + 3 = 12; - | ^ expected one of `:`, `;`, `=`, or `|` here + | ^ expected one of `:`, `;`, `=`, or `|` error: aborting due to previous error diff --git a/src/test/ui/parser/pat-ranges-4.stderr b/src/test/ui/parser/pat-ranges-4.stderr index 53e38bc670b..69084b5a414 100644 --- a/src/test/ui/parser/pat-ranges-4.stderr +++ b/src/test/ui/parser/pat-ranges-4.stderr @@ -2,7 +2,7 @@ error: expected one of `...`, `..=`, `..`, `:`, `;`, `=`, or `|`, found `-` --> $DIR/pat-ranges-4.rs:4:12 | LL | let 10 - 3 ..= 10 = 8; - | ^ expected one of 7 possible tokens here + | ^ expected one of 7 possible tokens error: aborting due to previous error diff --git a/src/test/ui/parser/range-3.stderr b/src/test/ui/parser/range-3.stderr index 92c33487ee4..f866ea59983 100644 --- a/src/test/ui/parser/range-3.stderr +++ b/src/test/ui/parser/range-3.stderr @@ -2,7 +2,7 @@ error: expected one of `.`, `;`, `?`, or an operator, found `..` --> $DIR/range-3.rs:4:17 | LL | let r = 1..2..3; - | ^^ expected one of `.`, `;`, `?`, or an operator here + | ^^ expected one of `.`, `;`, `?`, or an operator error: aborting due to previous error diff --git a/src/test/ui/parser/range-4.stderr b/src/test/ui/parser/range-4.stderr index 90ec46165e7..dcb85170c1d 100644 --- a/src/test/ui/parser/range-4.stderr +++ b/src/test/ui/parser/range-4.stderr @@ -2,7 +2,7 @@ error: expected one of `.`, `;`, `?`, or an operator, found `..` --> $DIR/range-4.rs:4:16 | LL | let r = ..1..2; - | ^^ expected one of `.`, `;`, `?`, or an operator here + | ^^ expected one of `.`, `;`, `?`, or an operator error: aborting due to previous error diff --git a/src/test/ui/parser/raw-str-unbalanced.stderr b/src/test/ui/parser/raw-str-unbalanced.stderr index 26910ff64f5..ddb75722bef 100644 --- a/src/test/ui/parser/raw-str-unbalanced.stderr +++ b/src/test/ui/parser/raw-str-unbalanced.stderr @@ -2,7 +2,7 @@ error: expected one of `.`, `;`, `?`, or an operator, found `#` --> $DIR/raw-str-unbalanced.rs:3:9 | LL | "## - | ^ expected one of `.`, `;`, `?`, or an operator here + | ^ expected one of `.`, `;`, `?`, or an operator error: aborting due to previous error diff --git a/src/test/ui/parser/raw/raw-literal-keywords.stderr b/src/test/ui/parser/raw/raw-literal-keywords.stderr index 4cea605be6f..fd8eda3770d 100644 --- a/src/test/ui/parser/raw/raw-literal-keywords.stderr +++ b/src/test/ui/parser/raw/raw-literal-keywords.stderr @@ -2,19 +2,19 @@ error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found --> $DIR/raw-literal-keywords.rs:2:10 | LL | r#if true { } - | ^^^^ expected one of 8 possible tokens here + | ^^^^ expected one of 8 possible tokens error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found `Test` --> $DIR/raw-literal-keywords.rs:6:14 | LL | r#struct Test; - | ^^^^ expected one of 8 possible tokens here + | ^^^^ expected one of 8 possible tokens error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found `Test` --> $DIR/raw-literal-keywords.rs:10:13 | LL | r#union Test; - | ^^^^ expected one of 8 possible tokens here + | ^^^^ expected one of 8 possible tokens error[E0425]: cannot find value `if` in this scope --> $DIR/raw-literal-keywords.rs:14:13 diff --git a/src/test/ui/parser/recover-enum2.stderr b/src/test/ui/parser/recover-enum2.stderr index 2311887a6fb..ee29f06638f 100644 --- a/src/test/ui/parser/recover-enum2.stderr +++ b/src/test/ui/parser/recover-enum2.stderr @@ -8,7 +8,7 @@ error: expected one of `!`, `(`, `)`, `+`, `,`, `::`, or `<`, found `{` --> $DIR/recover-enum2.rs:25:22 | LL | Nope(i32 {}) - | ^ expected one of 7 possible tokens here + | ^ expected one of 7 possible tokens error: aborting due to 2 previous errors diff --git a/src/test/ui/parser/recover-for-loop-parens-around-head.stderr b/src/test/ui/parser/recover-for-loop-parens-around-head.stderr index 1a1f395ee21..ccabfbded8b 100644 --- a/src/test/ui/parser/recover-for-loop-parens-around-head.stderr +++ b/src/test/ui/parser/recover-for-loop-parens-around-head.stderr @@ -2,7 +2,7 @@ error: expected one of `)`, `,`, `@`, or `|`, found keyword `in` --> $DIR/recover-for-loop-parens-around-head.rs:10:16 | LL | for ( elem in vec ) { - | ^^ expected one of `)`, `,`, `@`, or `|` here + | ^^ expected one of `)`, `,`, `@`, or `|` error: unexpected closing `)` --> $DIR/recover-for-loop-parens-around-head.rs:10:23 diff --git a/src/test/ui/parser/removed-syntax-closure-lifetime.stderr b/src/test/ui/parser/removed-syntax-closure-lifetime.stderr index f52988cdb20..a100f689fb8 100644 --- a/src/test/ui/parser/removed-syntax-closure-lifetime.stderr +++ b/src/test/ui/parser/removed-syntax-closure-lifetime.stderr @@ -2,7 +2,7 @@ error: expected one of `!`, `(`, `+`, `,`, `::`, `<`, or `>`, found `/` --> $DIR/removed-syntax-closure-lifetime.rs:1:22 | LL | type closure = Box; - | ^ expected one of 7 possible tokens here + | ^ expected one of 7 possible tokens error: aborting due to previous error diff --git a/src/test/ui/parser/removed-syntax-enum-newtype.stderr b/src/test/ui/parser/removed-syntax-enum-newtype.stderr index a6d0ff4eaf2..2daa6249b4c 100644 --- a/src/test/ui/parser/removed-syntax-enum-newtype.stderr +++ b/src/test/ui/parser/removed-syntax-enum-newtype.stderr @@ -2,7 +2,7 @@ error: expected one of `<`, `where`, or `{`, found `=` --> $DIR/removed-syntax-enum-newtype.rs:1:8 | LL | enum e = isize; - | ^ expected one of `<`, `where`, or `{` here + | ^ expected one of `<`, `where`, or `{` error: aborting due to previous error diff --git a/src/test/ui/parser/removed-syntax-fixed-vec.stderr b/src/test/ui/parser/removed-syntax-fixed-vec.stderr index ca6969d1e87..a2b97544f9e 100644 --- a/src/test/ui/parser/removed-syntax-fixed-vec.stderr +++ b/src/test/ui/parser/removed-syntax-fixed-vec.stderr @@ -2,7 +2,7 @@ error: expected one of `!`, `(`, `+`, `::`, `;`, `<`, or `]`, found `*` --> $DIR/removed-syntax-fixed-vec.rs:1:17 | LL | type v = [isize * 3]; - | ^ expected one of 7 possible tokens here + | ^ expected one of 7 possible tokens error: aborting due to previous error diff --git a/src/test/ui/parser/removed-syntax-ptr-lifetime.stderr b/src/test/ui/parser/removed-syntax-ptr-lifetime.stderr index 7beef9883bd..5b388ff4ce0 100644 --- a/src/test/ui/parser/removed-syntax-ptr-lifetime.stderr +++ b/src/test/ui/parser/removed-syntax-ptr-lifetime.stderr @@ -2,7 +2,7 @@ error: expected one of `!`, `(`, `::`, `;`, or `<`, found `/` --> $DIR/removed-syntax-ptr-lifetime.rs:1:22 | LL | type bptr = &lifetime/isize; - | ^ expected one of `!`, `(`, `::`, `;`, or `<` here + | ^ expected one of `!`, `(`, `::`, `;`, or `<` error: aborting due to previous error diff --git a/src/test/ui/parser/removed-syntax-static-fn.stderr b/src/test/ui/parser/removed-syntax-static-fn.stderr index af148e69711..dfadefee23c 100644 --- a/src/test/ui/parser/removed-syntax-static-fn.stderr +++ b/src/test/ui/parser/removed-syntax-static-fn.stderr @@ -2,7 +2,7 @@ error: expected one of `async`, `const`, `crate`, `default`, `extern`, `fn`, `pu --> $DIR/removed-syntax-static-fn.rs:4:5 | LL | impl S { - | - expected one of 10 possible tokens here + | - expected one of 10 possible tokens LL | static fn f() {} | ^^^^^^ unexpected token diff --git a/src/test/ui/parser/removed-syntax-uniq-mut-ty.stderr b/src/test/ui/parser/removed-syntax-uniq-mut-ty.stderr index 9c47e3db67d..0703caf5bed 100644 --- a/src/test/ui/parser/removed-syntax-uniq-mut-ty.stderr +++ b/src/test/ui/parser/removed-syntax-uniq-mut-ty.stderr @@ -2,7 +2,7 @@ error: expected one of `>`, const, lifetime, or type, found keyword `mut` --> $DIR/removed-syntax-uniq-mut-ty.rs:1:20 | LL | type mut_box = Box; - | ^^^ expected one of `>`, const, lifetime, or type here + | ^^^ expected one of `>`, const, lifetime, or type error: aborting due to previous error diff --git a/src/test/ui/parser/removed-syntax-with-1.stderr b/src/test/ui/parser/removed-syntax-with-1.stderr index a157873916a..193138d7460 100644 --- a/src/test/ui/parser/removed-syntax-with-1.stderr +++ b/src/test/ui/parser/removed-syntax-with-1.stderr @@ -2,7 +2,7 @@ error: expected one of `,`, `.`, `?`, `}`, or an operator, found `with` --> $DIR/removed-syntax-with-1.rs:8:25 | LL | let b = S { foo: () with a, bar: () }; - | - ^^^^ expected one of `,`, `.`, `?`, `}`, or an operator here + | - ^^^^ expected one of `,`, `.`, `?`, `}`, or an operator | | | while parsing this struct diff --git a/src/test/ui/parser/removed-syntax-with-2.stderr b/src/test/ui/parser/removed-syntax-with-2.stderr index 7717b49d3a2..024c97cc9c1 100644 --- a/src/test/ui/parser/removed-syntax-with-2.stderr +++ b/src/test/ui/parser/removed-syntax-with-2.stderr @@ -2,7 +2,7 @@ error: expected one of `,` or `}`, found `a` --> $DIR/removed-syntax-with-2.rs:8:31 | LL | let b = S { foo: (), with a }; - | - ^ expected one of `,` or `}` here + | - ^ expected one of `,` or `}` | | | while parsing this struct diff --git a/src/test/ui/parser/underscore_item_not_const.stderr b/src/test/ui/parser/underscore_item_not_const.stderr index 8814aa35271..ebf1ff9ff1e 100644 --- a/src/test/ui/parser/underscore_item_not_const.stderr +++ b/src/test/ui/parser/underscore_item_not_const.stderr @@ -86,7 +86,7 @@ error: expected one of `!` or `::`, found reserved identifier `_` --> $DIR/underscore_item_not_const.rs:28:7 | LL | union _ { f: u8 } - | ^ expected one of `!` or `::` here + | ^ expected one of `!` or `::` error: aborting due to 15 previous errors diff --git a/src/test/ui/parser/use-as-where-use-ends-with-mod-sep.stderr b/src/test/ui/parser/use-as-where-use-ends-with-mod-sep.stderr index c73e17d2fc9..7a461cf630c 100644 --- a/src/test/ui/parser/use-as-where-use-ends-with-mod-sep.stderr +++ b/src/test/ui/parser/use-as-where-use-ends-with-mod-sep.stderr @@ -13,7 +13,7 @@ error: expected one of `::`, `;`, or `as`, found `foo` --> $DIR/use-as-where-use-ends-with-mod-sep.rs:1:19 | LL | use std::any:: as foo; - | ^^^ expected one of `::`, `;`, or `as` here + | ^^^ expected one of `::`, `;`, or `as` error: aborting due to 2 previous errors diff --git a/src/test/ui/resolve/token-error-correct-3.stderr b/src/test/ui/resolve/token-error-correct-3.stderr index 57dd7c9f034..dd0e2597850 100644 --- a/src/test/ui/resolve/token-error-correct-3.stderr +++ b/src/test/ui/resolve/token-error-correct-3.stderr @@ -10,7 +10,7 @@ error: expected one of `.`, `;`, `?`, `}`, or an operator, found `)` --> $DIR/token-error-correct-3.rs:18:9 | LL | fs::create_dir_all(path.as_ref()).map(|()| true) - | - expected one of `.`, `;`, `?`, `}`, or an operator here + | - expected one of `.`, `;`, `?`, `}`, or an operator LL | } else { | ^ unexpected token diff --git a/src/test/ui/rfc-2497-if-let-chains/disallowed-positions.stderr b/src/test/ui/rfc-2497-if-let-chains/disallowed-positions.stderr index ad4686c1915..65de150b100 100644 --- a/src/test/ui/rfc-2497-if-let-chains/disallowed-positions.stderr +++ b/src/test/ui/rfc-2497-if-let-chains/disallowed-positions.stderr @@ -2,7 +2,7 @@ error: expected one of `,` or `>`, found `&&` --> $DIR/disallowed-positions.rs:242:14 | LL | true && let 1 = 1 - | ^^ expected one of `,` or `>` here + | ^^ expected one of `,` or `>` error: `let` expressions are not supported here --> $DIR/disallowed-positions.rs:32:9 diff --git a/src/test/ui/rfc-2565-param-attrs/param-attrs-2018.stderr b/src/test/ui/rfc-2565-param-attrs/param-attrs-2018.stderr index e4248f3b974..1e51567a9b1 100644 --- a/src/test/ui/rfc-2565-param-attrs/param-attrs-2018.stderr +++ b/src/test/ui/rfc-2565-param-attrs/param-attrs-2018.stderr @@ -2,7 +2,7 @@ error: expected one of `:`, `@`, or `|`, found `)` --> $DIR/param-attrs-2018.rs:3:41 | LL | trait Trait2015 { fn foo(#[allow(C)] i32); } - | ^ expected one of `:`, `@`, or `|` here + | ^ expected one of `:`, `@`, or `|` | = note: anonymous parameters are removed in the 2018 edition (see RFC 1685) help: if this is a `self` type, give it a parameter name diff --git a/src/test/ui/rfc1598-generic-associated-types/empty_generics.stderr b/src/test/ui/rfc1598-generic-associated-types/empty_generics.stderr index 749032dbcc2..9c8d3f192da 100644 --- a/src/test/ui/rfc1598-generic-associated-types/empty_generics.stderr +++ b/src/test/ui/rfc1598-generic-associated-types/empty_generics.stderr @@ -2,7 +2,7 @@ error: expected one of `>`, `const`, identifier, or lifetime, found `,` --> $DIR/empty_generics.rs:5:14 | LL | type Bar<,>; - | ^ expected one of `>`, `const`, identifier, or lifetime here + | ^ expected one of `>`, `const`, identifier, or lifetime warning: the feature `generic_associated_types` is incomplete and may cause the compiler to crash --> $DIR/empty_generics.rs:1:12 diff --git a/src/test/ui/similar-tokens.stderr b/src/test/ui/similar-tokens.stderr index 3113d4a872d..d3d5b4a6d1e 100644 --- a/src/test/ui/similar-tokens.stderr +++ b/src/test/ui/similar-tokens.stderr @@ -2,7 +2,7 @@ error: expected one of `,`, `::`, `as`, or `}`, found `.` --> $DIR/similar-tokens.rs:7:10 | LL | use x::{A. B}; - | ^ expected one of `,`, `::`, `as`, or `}` here + | ^ expected one of `,`, `::`, `as`, or `}` error: aborting due to previous error diff --git a/src/test/ui/span/issue-34264.stderr b/src/test/ui/span/issue-34264.stderr index 8d4a66f142d..26d686f6f50 100644 --- a/src/test/ui/span/issue-34264.stderr +++ b/src/test/ui/span/issue-34264.stderr @@ -2,7 +2,7 @@ error: expected one of `:`, `@`, or `|`, found `<` --> $DIR/issue-34264.rs:1:14 | LL | fn foo(Option, String) {} - | ^ expected one of `:`, `@`, or `|` here + | ^ expected one of `:`, `@`, or `|` | = note: anonymous parameters are removed in the 2018 edition (see RFC 1685) help: if this is a type, explicitly ignore the parameter name @@ -14,7 +14,7 @@ error: expected one of `:`, `@`, or `|`, found `)` --> $DIR/issue-34264.rs:1:27 | LL | fn foo(Option, String) {} - | ^ expected one of `:`, `@`, or `|` here + | ^ expected one of `:`, `@`, or `|` | = note: anonymous parameters are removed in the 2018 edition (see RFC 1685) help: if this was a parameter name, give it a type @@ -30,7 +30,7 @@ error: expected one of `:`, `@`, or `|`, found `,` --> $DIR/issue-34264.rs:3:9 | LL | fn bar(x, y: usize) {} - | ^ expected one of `:`, `@`, or `|` here + | ^ expected one of `:`, `@`, or `|` | = note: anonymous parameters are removed in the 2018 edition (see RFC 1685) help: if this was a parameter name, give it a type diff --git a/src/test/ui/suggestions/issue-64252-self-type.stderr b/src/test/ui/suggestions/issue-64252-self-type.stderr index fa28a0d684e..4abffb1ad79 100644 --- a/src/test/ui/suggestions/issue-64252-self-type.stderr +++ b/src/test/ui/suggestions/issue-64252-self-type.stderr @@ -2,7 +2,7 @@ error: expected one of `:`, `@`, or `|`, found `<` --> $DIR/issue-64252-self-type.rs:4:15 | LL | pub fn foo(Box) { } - | ^ expected one of `:`, `@`, or `|` here + | ^ expected one of `:`, `@`, or `|` | = note: anonymous parameters are removed in the 2018 edition (see RFC 1685) help: if this is a type, explicitly ignore the parameter name @@ -14,7 +14,7 @@ error: expected one of `:`, `@`, or `|`, found `<` --> $DIR/issue-64252-self-type.rs:10:15 | LL | fn bar(Box) { } - | ^ expected one of `:`, `@`, or `|` here + | ^ expected one of `:`, `@`, or `|` | = note: anonymous parameters are removed in the 2018 edition (see RFC 1685) help: if this is a `self` type, give it a parameter name diff --git a/src/test/ui/tuple/tuple-struct-fields/test.stderr b/src/test/ui/tuple/tuple-struct-fields/test.stderr index 295f0b146dd..94f39f3b9f1 100644 --- a/src/test/ui/tuple/tuple-struct-fields/test.stderr +++ b/src/test/ui/tuple/tuple-struct-fields/test.stderr @@ -2,7 +2,7 @@ error: expected one of `)` or `,`, found `(` --> $DIR/test.rs:4:26 | LL | struct S2(pub((foo)) ()); - | ^ expected one of `)` or `,` here + | ^ expected one of `)` or `,` error[E0412]: cannot find type `foo` in this scope --> $DIR/test.rs:4:20 diff --git a/src/test/ui/tuple/tuple-struct-fields/test2.stderr b/src/test/ui/tuple/tuple-struct-fields/test2.stderr index 78176c67ed2..9a64ed97ae1 100644 --- a/src/test/ui/tuple/tuple-struct-fields/test2.stderr +++ b/src/test/ui/tuple/tuple-struct-fields/test2.stderr @@ -2,7 +2,7 @@ error: expected one of `)` or `,`, found `(` --> $DIR/test2.rs:5:26 | LL | struct S3(pub $t ()); - | ^ expected one of `)` or `,` here + | ^ expected one of `)` or `,` ... LL | define_struct! { (foo) } | ------------------------ in this macro invocation diff --git a/src/test/ui/tuple/tuple-struct-fields/test3.stderr b/src/test/ui/tuple/tuple-struct-fields/test3.stderr index e105aad09e6..89ae784882d 100644 --- a/src/test/ui/tuple/tuple-struct-fields/test3.stderr +++ b/src/test/ui/tuple/tuple-struct-fields/test3.stderr @@ -2,7 +2,7 @@ error: expected one of `)` or `,`, found `(` --> $DIR/test3.rs:5:27 | LL | struct S3(pub($t) ()); - | ^ expected one of `)` or `,` here + | ^ expected one of `)` or `,` ... LL | define_struct! { foo } | ---------------------- in this macro invocation diff --git a/src/test/ui/type/ascription/issue-54516.stderr b/src/test/ui/type/ascription/issue-54516.stderr index 97942904a0f..47e3c78459d 100644 --- a/src/test/ui/type/ascription/issue-54516.stderr +++ b/src/test/ui/type/ascription/issue-54516.stderr @@ -2,7 +2,7 @@ error: expected one of `!`, `,`, or `::`, found `(` --> $DIR/issue-54516.rs:4:58 | LL | println!("{}", std::mem:size_of::>()); - | - ^ expected one of `!`, `,`, or `::` here + | - ^ expected one of `!`, `,`, or `::` | | | help: maybe write a path separator here: `::` | diff --git a/src/test/ui/type/ascription/issue-60933.stderr b/src/test/ui/type/ascription/issue-60933.stderr index c2fc7bbcfc8..c47042bbe59 100644 --- a/src/test/ui/type/ascription/issue-60933.stderr +++ b/src/test/ui/type/ascription/issue-60933.stderr @@ -2,7 +2,7 @@ error: expected one of `!`, `::`, or `;`, found `(` --> $DIR/issue-60933.rs:2:43 | LL | let u: usize = std::mem:size_of::(); - | - ^ expected one of `!`, `::`, or `;` here + | - ^ expected one of `!`, `::`, or `;` | | | help: maybe write a path separator here: `::` | diff --git a/src/test/ui/unsafe/unsafe-block-without-braces.stderr b/src/test/ui/unsafe/unsafe-block-without-braces.stderr index 34a90352e92..637fdeead36 100644 --- a/src/test/ui/unsafe/unsafe-block-without-braces.stderr +++ b/src/test/ui/unsafe/unsafe-block-without-braces.stderr @@ -2,7 +2,7 @@ error: expected one of `extern`, `fn`, or `{`, found `std` --> $DIR/unsafe-block-without-braces.rs:3:9 | LL | unsafe //{ - | - expected one of `extern`, `fn`, or `{` here + | - expected one of `extern`, `fn`, or `{` LL | std::mem::transmute::(1.0); | ^^^ unexpected token From 15ec8f7c521461bfa64729d859e64f5415ddb4fd Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sat, 2 Nov 2019 17:46:11 +0100 Subject: [PATCH 10/15] rename Memory::get methods to get_raw to indicate their unchecked nature --- .../interpret/intrinsics/caller_location.rs | 3 +- src/librustc_mir/interpret/memory.rs | 32 +++++++++++-------- src/librustc_mir/interpret/operand.rs | 6 ++-- src/librustc_mir/interpret/place.rs | 6 ++-- src/librustc_mir/interpret/snapshot.rs | 2 +- src/librustc_mir/interpret/terminator.rs | 2 +- src/librustc_mir/interpret/traits.rs | 31 ++++++++---------- src/librustc_mir/interpret/validity.rs | 5 ++- 8 files changed, 45 insertions(+), 42 deletions(-) diff --git a/src/librustc_mir/interpret/intrinsics/caller_location.rs b/src/librustc_mir/interpret/intrinsics/caller_location.rs index 249d2f9ff53..88bfcd63129 100644 --- a/src/librustc_mir/interpret/intrinsics/caller_location.rs +++ b/src/librustc_mir/interpret/intrinsics/caller_location.rs @@ -37,7 +37,8 @@ pub fn alloc_caller_location( let col_out = self.force_ptr(self.mplace_field(location, 2)?.ptr)?; let layout = &self.tcx.data_layout; - let alloc = self.memory.get_mut(file_ptr_out.alloc_id)?; + // We just allocated this, so we can skip the bounds checks. + let alloc = self.memory.get_raw_mut(file_ptr_out.alloc_id)?; alloc.write_scalar(layout, file_ptr_out, file.into(), ptr_size)?; alloc.write_scalar(layout, file_len_out, file_len.into(), ptr_size)?; diff --git a/src/librustc_mir/interpret/memory.rs b/src/librustc_mir/interpret/memory.rs index 47b91824833..6d4ef93aafa 100644 --- a/src/librustc_mir/interpret/memory.rs +++ b/src/librustc_mir/interpret/memory.rs @@ -210,7 +210,7 @@ pub fn reallocate( let new_ptr = self.allocate(new_size, new_align, kind); let old_size = match old_size_and_align { Some((size, _align)) => size, - None => self.get(ptr.alloc_id)?.size, + None => self.get_raw(ptr.alloc_id)?.size, }; self.copy( ptr, @@ -480,7 +480,9 @@ fn get_static_alloc( ).0) } - pub fn get( + /// Gives raw access to the `Allocation`, without bounds or alignment checks. + /// Use the higher-level, `PlaceTy`- and `OpTy`-based APIs in `InterpCtx` instead! + pub fn get_raw( &self, id: AllocId, ) -> InterpResult<'tcx, &Allocation> { @@ -513,7 +515,9 @@ pub fn get( } } - pub fn get_mut( + /// Gives raw mutable access to the `Allocation`, without bounds or alignment checks. + /// Use the higher-level, `PlaceTy`- and `OpTy`-based APIs in `InterpCtx` instead! + pub fn get_raw_mut( &mut self, id: AllocId, ) -> InterpResult<'tcx, &mut Allocation> { @@ -555,7 +559,7 @@ pub fn get_size_and_align( liveness: AllocCheck, ) -> InterpResult<'static, (Size, Align)> { // # Regular allocations - // Don't use `self.get` here as that will + // Don't use `self.get_raw` here as that will // a) cause cycles in case `id` refers to a static // b) duplicate a static's allocation in miri if let Some((_, alloc)) = self.alloc_map.get(id) { @@ -627,7 +631,7 @@ pub fn get_fn( } pub fn mark_immutable(&mut self, id: AllocId) -> InterpResult<'tcx> { - self.get_mut(id)?.mutability = Mutability::Immutable; + self.get_raw_mut(id)?.mutability = Mutability::Immutable; Ok(()) } @@ -776,7 +780,7 @@ pub fn read_bytes( Some(ptr) => ptr, None => return Ok(&[]), // zero-sized access }; - self.get(ptr.alloc_id)?.get_bytes(self, ptr, size) + self.get_raw(ptr.alloc_id)?.get_bytes(self, ptr, size) } /// Reads a 0-terminated sequence of bytes from memory. Returns them as a slice. @@ -784,7 +788,7 @@ pub fn read_bytes( /// Performs appropriate bounds checks. pub fn read_c_str(&self, ptr: Scalar) -> InterpResult<'tcx, &[u8]> { let ptr = self.force_ptr(ptr)?; // We need to read at least 1 byte, so we *need* a ptr. - self.get(ptr.alloc_id)?.read_c_str(self, ptr) + self.get_raw(ptr.alloc_id)?.read_c_str(self, ptr) } /// Writes the given stream of bytes into memory. @@ -804,7 +808,7 @@ pub fn write_bytes( None => return Ok(()), // zero-sized access }; let tcx = self.tcx.tcx; - self.get_mut(ptr.alloc_id)?.write_bytes(&tcx, ptr, src) + self.get_raw_mut(ptr.alloc_id)?.write_bytes(&tcx, ptr, src) } /// Expects the caller to have checked bounds and alignment. @@ -832,16 +836,16 @@ pub fn copy_repeatedly( // since we don't want to keep any relocations at the target. // (`get_bytes_with_undef_and_ptr` below checks that there are no // relocations overlapping the edges; those would not be handled correctly). - let relocations = self.get(src.alloc_id)? + let relocations = self.get_raw(src.alloc_id)? .prepare_relocation_copy(self, src, size, dest, length); let tcx = self.tcx.tcx; // This checks relocation edges on the src. - let src_bytes = self.get(src.alloc_id)? + let src_bytes = self.get_raw(src.alloc_id)? .get_bytes_with_undef_and_ptr(&tcx, src, size)? .as_ptr(); - let dest_bytes = self.get_mut(dest.alloc_id)? + let dest_bytes = self.get_raw_mut(dest.alloc_id)? .get_bytes_mut(&tcx, dest, size * length)? .as_mut_ptr(); @@ -880,7 +884,7 @@ pub fn copy_repeatedly( // copy definedness to the destination self.copy_undef_mask(src, dest, size, length)?; // copy the relocations to the destination - self.get_mut(dest.alloc_id)?.mark_relocation_range(relocations); + self.get_raw_mut(dest.alloc_id)?.mark_relocation_range(relocations); Ok(()) } @@ -899,11 +903,11 @@ fn copy_undef_mask( // The bits have to be saved locally before writing to dest in case src and dest overlap. assert_eq!(size.bytes() as usize as u64, size.bytes()); - let src_alloc = self.get(src.alloc_id)?; + let src_alloc = self.get_raw(src.alloc_id)?; let compressed = src_alloc.compress_undef_range(src, size); // now fill in all the data - let dest_allocation = self.get_mut(dest.alloc_id)?; + let dest_allocation = self.get_raw_mut(dest.alloc_id)?; dest_allocation.mark_compressed_undef_range(&compressed, dest, size, repeat); Ok(()) diff --git a/src/librustc_mir/interpret/operand.rs b/src/librustc_mir/interpret/operand.rs index d80ad3848d2..79762b87b0a 100644 --- a/src/librustc_mir/interpret/operand.rs +++ b/src/librustc_mir/interpret/operand.rs @@ -248,7 +248,7 @@ fn try_read_immediate_from_mplace( match mplace.layout.abi { layout::Abi::Scalar(..) => { let scalar = self.memory - .get(ptr.alloc_id)? + .get_raw(ptr.alloc_id)? .read_scalar(self, ptr, mplace.layout.size)?; Ok(Some(ImmTy { imm: scalar.into(), @@ -266,10 +266,10 @@ fn try_read_immediate_from_mplace( assert!(b_offset.bytes() > 0); // we later use the offset to tell apart the fields let b_ptr = ptr.offset(b_offset, self)?; let a_val = self.memory - .get(ptr.alloc_id)? + .get_raw(ptr.alloc_id)? .read_scalar(self, a_ptr, a_size)?; let b_val = self.memory - .get(ptr.alloc_id)? + .get_raw(ptr.alloc_id)? .read_scalar(self, b_ptr, b_size)?; Ok(Some(ImmTy { imm: Immediate::ScalarPair(a_val, b_val), diff --git a/src/librustc_mir/interpret/place.rs b/src/librustc_mir/interpret/place.rs index 36e58d356d1..04effc2ea2d 100644 --- a/src/librustc_mir/interpret/place.rs +++ b/src/librustc_mir/interpret/place.rs @@ -808,7 +808,7 @@ fn write_immediate_to_mplace_no_validate( _ => bug!("write_immediate_to_mplace: invalid Scalar layout: {:#?}", dest.layout) } - self.memory.get_mut(ptr.alloc_id)?.write_scalar( + self.memory.get_raw_mut(ptr.alloc_id)?.write_scalar( tcx, ptr, scalar, dest.layout.size ) } @@ -830,10 +830,10 @@ fn write_immediate_to_mplace_no_validate( // fields do not match the `ScalarPair` components. self.memory - .get_mut(ptr.alloc_id)? + .get_raw_mut(ptr.alloc_id)? .write_scalar(tcx, ptr, a_val, a_size)?; self.memory - .get_mut(b_ptr.alloc_id)? + .get_raw_mut(b_ptr.alloc_id)? .write_scalar(tcx, b_ptr, b_val, b_size) } } diff --git a/src/librustc_mir/interpret/snapshot.rs b/src/librustc_mir/interpret/snapshot.rs index 7ce151e087a..1df98f079cc 100644 --- a/src/librustc_mir/interpret/snapshot.rs +++ b/src/librustc_mir/interpret/snapshot.rs @@ -392,7 +392,7 @@ impl<'b, 'mir, 'tcx> SnapshotContext<'b> for Memory<'mir, 'tcx, CompileTimeInterpreter<'mir, 'tcx>> { fn resolve(&'b self, id: &AllocId) -> Option<&'b Allocation> { - self.get(*id).ok() + self.get_raw(*id).ok() } } diff --git a/src/librustc_mir/interpret/terminator.rs b/src/librustc_mir/interpret/terminator.rs index d90f2058aa7..e10bb85d52d 100644 --- a/src/librustc_mir/interpret/terminator.rs +++ b/src/librustc_mir/interpret/terminator.rs @@ -445,7 +445,7 @@ fn eval_fn_call( ptr_size, self.tcx.data_layout.pointer_align.abi, )?.expect("cannot be a ZST"); - let fn_ptr = self.memory.get(vtable_slot.alloc_id)? + let fn_ptr = self.memory.get_raw(vtable_slot.alloc_id)? .read_ptr_sized(self, vtable_slot)?.not_undef()?; let drop_fn = self.memory.get_fn(fn_ptr)?; diff --git a/src/librustc_mir/interpret/traits.rs b/src/librustc_mir/interpret/traits.rs index 10b767ebba1..c15425321ec 100644 --- a/src/librustc_mir/interpret/traits.rs +++ b/src/librustc_mir/interpret/traits.rs @@ -63,35 +63,30 @@ pub fn get_vtable( let drop = Instance::resolve_drop_in_place(*tcx, ty); let drop = self.memory.create_fn_alloc(FnVal::Instance(drop)); - // no need to do any alignment checks on the memory accesses below, because we know the + // No need to do any alignment checks on the memory accesses below, because we know the // allocation is correctly aligned as we created it above. Also we're only offsetting by // multiples of `ptr_align`, which means that it will stay aligned to `ptr_align`. - self.memory - .get_mut(vtable.alloc_id)? - .write_ptr_sized(tcx, vtable, Scalar::Ptr(drop).into())?; + let vtable_alloc = self.memory.get_raw_mut(vtable.alloc_id)?; + vtable_alloc.write_ptr_sized(tcx, vtable, Scalar::Ptr(drop).into())?; - let size_ptr = vtable.offset(ptr_size, self)?; - self.memory - .get_mut(size_ptr.alloc_id)? - .write_ptr_sized(tcx, size_ptr, Scalar::from_uint(size, ptr_size).into())?; - let align_ptr = vtable.offset(ptr_size * 2, self)?; - self.memory - .get_mut(align_ptr.alloc_id)? - .write_ptr_sized(tcx, align_ptr, Scalar::from_uint(align, ptr_size).into())?; + let size_ptr = vtable.offset(ptr_size, tcx)?; + vtable_alloc.write_ptr_sized(tcx, size_ptr, Scalar::from_uint(size, ptr_size).into())?; + let align_ptr = vtable.offset(ptr_size * 2, tcx)?; + vtable_alloc.write_ptr_sized(tcx, align_ptr, Scalar::from_uint(align, ptr_size).into())?; for (i, method) in methods.iter().enumerate() { if let Some((def_id, substs)) = *method { // resolve for vtable: insert shims where needed let instance = ty::Instance::resolve_for_vtable( - *self.tcx, + *tcx, self.param_env, def_id, substs, ).ok_or_else(|| err_inval!(TooGeneric))?; let fn_ptr = self.memory.create_fn_alloc(FnVal::Instance(instance)); - let method_ptr = vtable.offset(ptr_size * (3 + i as u64), self)?; - self.memory - .get_mut(method_ptr.alloc_id)? + // We cannot use `vtable_allic` as we are creating fn ptrs in this loop. + let method_ptr = vtable.offset(ptr_size * (3 + i as u64), tcx)?; + self.memory.get_raw_mut(vtable.alloc_id)? .write_ptr_sized(tcx, method_ptr, Scalar::Ptr(fn_ptr).into())?; } } @@ -114,7 +109,7 @@ pub fn read_drop_type_from_vtable( self.tcx.data_layout.pointer_align.abi, )?.expect("cannot be a ZST"); let drop_fn = self.memory - .get(vtable.alloc_id)? + .get_raw(vtable.alloc_id)? .read_ptr_sized(self, vtable)? .not_undef()?; // We *need* an instance here, no other kind of function value, to be able @@ -140,7 +135,7 @@ pub fn read_size_and_align_from_vtable( 3*pointer_size, self.tcx.data_layout.pointer_align.abi, )?.expect("cannot be a ZST"); - let alloc = self.memory.get(vtable.alloc_id)?; + let alloc = self.memory.get_raw(vtable.alloc_id)?; let size = alloc.read_ptr_sized( self, vtable.offset(pointer_size, self)? diff --git a/src/librustc_mir/interpret/validity.rs b/src/librustc_mir/interpret/validity.rs index 8cb2f6c3462..dedccbaa3d7 100644 --- a/src/librustc_mir/interpret/validity.rs +++ b/src/librustc_mir/interpret/validity.rs @@ -586,6 +586,8 @@ fn visit_aggregate( _ => false, } } => { + // Optimized handling for arrays of integer/float type. + // bailing out for zsts is ok, since the array element type can only be int/float if op.layout.is_zst() { return Ok(()); @@ -605,6 +607,7 @@ fn visit_aggregate( // Size is not 0, get a pointer. let ptr = self.ecx.force_ptr(mplace.ptr)?; + // This is the optimization: we just check the entire range at once. // NOTE: Keep this in sync with the handling of integer and float // types above, in `visit_primitive`. // In run-time mode, we accept pointers in here. This is actually more @@ -614,7 +617,7 @@ fn visit_aggregate( // to reject those pointers, we just do not have the machinery to // talk about parts of a pointer. // We also accept undef, for consistency with the slow path. - match self.ecx.memory.get(ptr.alloc_id)?.check_bytes( + match self.ecx.memory.get_raw(ptr.alloc_id)?.check_bytes( self.ecx, ptr, size, From 900fc9a2f045116a7362aa25452c9f2091ed2777 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Wed, 6 Nov 2019 13:00:14 +0100 Subject: [PATCH 11/15] miri: Rename to_{u,i}size to to_machine_{u,i}size Having a function `to_usize` that does not return a usize is somewhat confusing --- src/librustc/mir/interpret/value.rs | 12 ++++++------ src/librustc_mir/const_eval.rs | 2 +- src/librustc_mir/interpret/eval_context.rs | 2 +- src/librustc_mir/interpret/intern.rs | 2 +- src/librustc_mir/interpret/intrinsics.rs | 4 ++-- src/librustc_mir/interpret/memory.rs | 2 +- src/librustc_mir/interpret/place.rs | 2 +- src/librustc_mir/interpret/validity.rs | 2 +- 8 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/librustc/mir/interpret/value.rs b/src/librustc/mir/interpret/value.rs index ac16b8b884c..7b29fb26e74 100644 --- a/src/librustc/mir/interpret/value.rs +++ b/src/librustc/mir/interpret/value.rs @@ -439,7 +439,7 @@ pub fn to_u64(self) -> InterpResult<'static, u64> { Ok(b as u64) } - pub fn to_usize(self, cx: &impl HasDataLayout) -> InterpResult<'static, u64> { + pub fn to_machine_usize(self, cx: &impl HasDataLayout) -> InterpResult<'static, u64> { let b = self.to_bits(cx.data_layout().pointer_size)?; Ok(b as u64) } @@ -465,7 +465,7 @@ pub fn to_i64(self) -> InterpResult<'static, i64> { Ok(b as i64) } - pub fn to_isize(self, cx: &impl HasDataLayout) -> InterpResult<'static, i64> { + pub fn to_machine_isize(self, cx: &impl HasDataLayout) -> InterpResult<'static, i64> { let sz = cx.data_layout().pointer_size; let b = self.to_bits(sz)?; let b = sign_extend(b, sz) as i128; @@ -592,8 +592,8 @@ pub fn to_u64(self) -> InterpResult<'tcx, u64> { } #[inline(always)] - pub fn to_usize(self, cx: &impl HasDataLayout) -> InterpResult<'tcx, u64> { - self.not_undef()?.to_usize(cx) + pub fn to_machine_usize(self, cx: &impl HasDataLayout) -> InterpResult<'tcx, u64> { + self.not_undef()?.to_machine_usize(cx) } #[inline(always)] @@ -612,8 +612,8 @@ pub fn to_i64(self) -> InterpResult<'tcx, i64> { } #[inline(always)] - pub fn to_isize(self, cx: &impl HasDataLayout) -> InterpResult<'tcx, i64> { - self.not_undef()?.to_isize(cx) + pub fn to_machine_isize(self, cx: &impl HasDataLayout) -> InterpResult<'tcx, i64> { + self.not_undef()?.to_machine_isize(cx) } } diff --git a/src/librustc_mir/const_eval.rs b/src/librustc_mir/const_eval.rs index 89bdf7391c3..707ad151182 100644 --- a/src/librustc_mir/const_eval.rs +++ b/src/librustc_mir/const_eval.rs @@ -118,7 +118,7 @@ fn op_to_const<'tcx>( 0, ), }; - let len = b.to_usize(&ecx.tcx.tcx).unwrap(); + let len = b.to_machine_usize(&ecx.tcx.tcx).unwrap(); let start = start.try_into().unwrap(); let len: usize = len.try_into().unwrap(); ConstValue::Slice { diff --git a/src/librustc_mir/interpret/eval_context.rs b/src/librustc_mir/interpret/eval_context.rs index d929e958f05..8e901068a8d 100644 --- a/src/librustc_mir/interpret/eval_context.rs +++ b/src/librustc_mir/interpret/eval_context.rs @@ -447,7 +447,7 @@ pub(super) fn size_and_align_of( } ty::Slice(_) | ty::Str => { - let len = metadata.expect("slice fat ptr must have vtable").to_usize(self)?; + let len = metadata.expect("slice fat ptr must have length").to_machine_usize(self)?; let elem = layout.field(self, 0)?; // Make sure the slice is not too big. diff --git a/src/librustc_mir/interpret/intern.rs b/src/librustc_mir/interpret/intern.rs index 2171ceaa452..a7de533506c 100644 --- a/src/librustc_mir/interpret/intern.rs +++ b/src/librustc_mir/interpret/intern.rs @@ -228,7 +228,7 @@ fn visit_primitive(&mut self, mplace: MPlaceTy<'tcx>) -> InterpResult<'tcx> { ty::Array(_, n) if n.eval_usize(self.ecx.tcx.tcx, self.ecx.param_env) == 0 => {} ty::Slice(_) - if mplace.meta.unwrap().to_usize(self.ecx)? == 0 => {} + if mplace.meta.unwrap().to_machine_usize(self.ecx)? == 0 => {} _ => bug!("const qualif failed to prevent mutable references"), } }, diff --git a/src/librustc_mir/interpret/intrinsics.rs b/src/librustc_mir/interpret/intrinsics.rs index 1b5cc2f0948..39f10d8e604 100644 --- a/src/librustc_mir/interpret/intrinsics.rs +++ b/src/librustc_mir/interpret/intrinsics.rs @@ -263,8 +263,8 @@ pub fn emulate_intrinsic( // This is the dual to the special exception for offset-by-0 // in the inbounds pointer offset operation (see the Miri code, `src/operator.rs`). if a.is_bits() && b.is_bits() { - let a = a.to_usize(self)?; - let b = b.to_usize(self)?; + let a = a.to_machine_usize(self)?; + let b = b.to_machine_usize(self)?; if a == b && a != 0 { self.write_scalar(Scalar::from_int(0, isize_layout.size), dest)?; return Ok(true); diff --git a/src/librustc_mir/interpret/memory.rs b/src/librustc_mir/interpret/memory.rs index 47b91824833..fce2aadd7fe 100644 --- a/src/librustc_mir/interpret/memory.rs +++ b/src/librustc_mir/interpret/memory.rs @@ -915,7 +915,7 @@ pub fn force_ptr( ) -> InterpResult<'tcx, Pointer> { match scalar { Scalar::Ptr(ptr) => Ok(ptr), - _ => M::int_to_ptr(&self, scalar.to_usize(self)?) + _ => M::int_to_ptr(&self, scalar.to_machine_usize(self)?) } } diff --git a/src/librustc_mir/interpret/place.rs b/src/librustc_mir/interpret/place.rs index 36e58d356d1..d45cb9f7c81 100644 --- a/src/librustc_mir/interpret/place.rs +++ b/src/librustc_mir/interpret/place.rs @@ -195,7 +195,7 @@ pub(super) fn len(self, cx: &impl HasDataLayout) -> InterpResult<'tcx, u64> { // We need to consult `meta` metadata match self.layout.ty.kind { ty::Slice(..) | ty::Str => - return self.mplace.meta.unwrap().to_usize(cx), + return self.mplace.meta.unwrap().to_machine_usize(cx), _ => bug!("len not supported on unsized type {:?}", self.layout.ty), } } else { diff --git a/src/librustc_mir/interpret/validity.rs b/src/librustc_mir/interpret/validity.rs index 8cb2f6c3462..3eb5fa18f93 100644 --- a/src/librustc_mir/interpret/validity.rs +++ b/src/librustc_mir/interpret/validity.rs @@ -282,7 +282,7 @@ fn check_wide_ptr_meta( // FIXME: More checks for the vtable. } ty::Slice(..) | ty::Str => { - let _len = try_validation!(meta.unwrap().to_usize(self.ecx), + let _len = try_validation!(meta.unwrap().to_machine_usize(self.ecx), "non-integer slice length in wide pointer", self.path); // We do not check that `len * elem_size <= isize::MAX`: // that is only required for references, and there it falls out of the From 30d7279628b2e4e3f9dc7efd2a9d2d7018f48a5c Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Thu, 7 Nov 2019 12:57:52 +0100 Subject: [PATCH 12/15] hir::ItemKind::Fn: use hir::MethodSig --- src/librustc/hir/intravisit.rs | 6 ++--- src/librustc/hir/lowering/item.rs | 11 +++----- src/librustc/hir/map/blocks.rs | 6 ++--- src/librustc/hir/map/mod.rs | 14 +++++----- src/librustc/hir/mod.rs | 4 +-- src/librustc/hir/print.rs | 6 ++--- .../nice_region_error/find_anon_type.rs | 6 ++--- src/librustc/middle/reachable.rs | 6 ++--- src/librustc/middle/resolve_lifetime.rs | 8 +++--- src/librustc/traits/error_reporting.rs | 26 +++++++++---------- src/librustc_metadata/rmeta/encoder.rs | 10 +++---- src/librustc_mir/build/mod.rs | 7 ++++- src/librustc_mir/transform/check_unsafety.rs | 4 +-- src/librustc_typeck/check/mod.rs | 26 ++++++++----------- src/librustc_typeck/collect.rs | 14 +++++----- src/librustdoc/visit_ast.rs | 4 +-- 16 files changed, 77 insertions(+), 81 deletions(-) diff --git a/src/librustc/hir/intravisit.rs b/src/librustc/hir/intravisit.rs index 920635d8387..72de8ccd952 100644 --- a/src/librustc/hir/intravisit.rs +++ b/src/librustc/hir/intravisit.rs @@ -481,13 +481,13 @@ pub fn walk_item<'v, V: Visitor<'v>>(visitor: &mut V, item: &'v Item) { visitor.visit_ty(typ); visitor.visit_nested_body(body); } - ItemKind::Fn(ref declaration, header, ref generics, body_id) => { + ItemKind::Fn(ref sig, ref generics, body_id) => { visitor.visit_fn(FnKind::ItemFn(item.ident, generics, - header, + sig.header, &item.vis, &item.attrs), - declaration, + &sig.decl, body_id, item.span, item.hir_id) diff --git a/src/librustc/hir/lowering/item.rs b/src/librustc/hir/lowering/item.rs index 5fe463d783f..5bc9fcb12f1 100644 --- a/src/librustc/hir/lowering/item.rs +++ b/src/librustc/hir/lowering/item.rs @@ -317,7 +317,7 @@ fn lower_item_kind( // declaration (decl), not the return types. let body_id = this.lower_maybe_async_body(&decl, header.asyncness.node, body); - let (generics, fn_decl) = this.add_in_band_defs( + let (generics, decl) = this.add_in_band_defs( generics, fn_def_id, AnonymousLifetimeMode::PassThrough, @@ -328,13 +328,8 @@ fn lower_item_kind( header.asyncness.node.opt_return_id() ), ); - - hir::ItemKind::Fn( - fn_decl, - this.lower_fn_header(header), - generics, - body_id, - ) + let sig = hir::MethodSig { decl, header: this.lower_fn_header(header) }; + hir::ItemKind::Fn(sig, generics, body_id) }) } ItemKind::Mod(ref m) => hir::ItemKind::Mod(self.lower_mod(m)), diff --git a/src/librustc/hir/map/blocks.rs b/src/librustc/hir/map/blocks.rs index f670d5abe85..b2f4a015711 100644 --- a/src/librustc/hir/map/blocks.rs +++ b/src/librustc/hir/map/blocks.rs @@ -219,16 +219,16 @@ fn handle(self, item_fn: I, method: M, closure: C) -> A where { match self.node { map::Node::Item(i) => match i.kind { - ast::ItemKind::Fn(ref decl, header, ref generics, block) => + ast::ItemKind::Fn(ref sig, ref generics, block) => item_fn(ItemFnParts { id: i.hir_id, ident: i.ident, - decl: &decl, + decl: &sig.decl, body: block, vis: &i.vis, span: i.span, attrs: &i.attrs, - header, + header: sig.header, generics, }), _ => bug!("item FnLikeNode that is not fn-like"), diff --git a/src/librustc/hir/map/mod.rs b/src/librustc/hir/map/mod.rs index acadd77cc36..d7b1676c1d4 100644 --- a/src/librustc/hir/map/mod.rs +++ b/src/librustc/hir/map/mod.rs @@ -49,21 +49,21 @@ fn fn_decl(&self) -> Option<&'hir FnDecl> { match self.node { Node::Item(ref item) => { match item.kind { - ItemKind::Fn(ref fn_decl, _, _, _) => Some(fn_decl), + ItemKind::Fn(ref sig, _, _) => Some(&sig.decl), _ => None, } } Node::TraitItem(ref item) => { match item.kind { - TraitItemKind::Method(ref method_sig, _) => Some(&method_sig.decl), + TraitItemKind::Method(ref sig, _) => Some(&sig.decl), _ => None } } Node::ImplItem(ref item) => { match item.kind { - ImplItemKind::Method(ref method_sig, _) => Some(&method_sig.decl), + ImplItemKind::Method(ref sig, _) => Some(&sig.decl), _ => None, } } @@ -85,7 +85,7 @@ fn associated_body(self) -> Option { match item.kind { ItemKind::Const(_, body) | ItemKind::Static(.., body) | - ItemKind::Fn(_, _, _, body) => Some(body), + ItemKind::Fn(.., body) => Some(body), _ => None, } } @@ -605,7 +605,7 @@ pub fn get_generics(&self, id: DefId) -> Option<&'hir Generics> { Node::TraitItem(ref trait_item) => Some(&trait_item.generics), Node::Item(ref item) => { match item.kind { - ItemKind::Fn(_, _, ref generics, _) | + ItemKind::Fn(_, ref generics, _) | ItemKind::TyAlias(_, ref generics) | ItemKind::Enum(_, ref generics) | ItemKind::Struct(_, ref generics) | @@ -702,9 +702,9 @@ pub fn is_const_context(&self, hir_id: HirId) -> bool { .. }) => true, Node::Item(&Item { - kind: ItemKind::Fn(_, header, ..), + kind: ItemKind::Fn(ref sig, ..), .. - }) => header.constness == Constness::Const, + }) => sig.header.constness == Constness::Const, _ => false, } } diff --git a/src/librustc/hir/mod.rs b/src/librustc/hir/mod.rs index d409ca6f3c5..93503c15094 100644 --- a/src/librustc/hir/mod.rs +++ b/src/librustc/hir/mod.rs @@ -2534,7 +2534,7 @@ pub enum ItemKind { /// A `const` item. Const(P, BodyId), /// A function declaration. - Fn(P, FnHeader, Generics, BodyId), + Fn(MethodSig, Generics, BodyId), /// A module. Mod(Mod), /// An external module, e.g. `extern { .. }`. @@ -2599,7 +2599,7 @@ pub fn adt_kind(&self) -> Option { pub fn generics(&self) -> Option<&Generics> { Some(match *self { - ItemKind::Fn(_, _, ref generics, _) | + ItemKind::Fn(_, ref generics, _) | ItemKind::TyAlias(_, ref generics) | ItemKind::OpaqueTy(OpaqueTy { ref generics, impl_trait_fn: None, .. }) | ItemKind::Enum(_, ref generics) | diff --git a/src/librustc/hir/print.rs b/src/librustc/hir/print.rs index a25c111b598..69d2a9ad281 100644 --- a/src/librustc/hir/print.rs +++ b/src/librustc/hir/print.rs @@ -533,10 +533,10 @@ pub fn print_item(&mut self, item: &hir::Item) { self.s.word(";"); self.end(); // end the outer cbox } - hir::ItemKind::Fn(ref decl, header, ref param_names, body) => { + hir::ItemKind::Fn(ref sig, ref param_names, body) => { self.head(""); - self.print_fn(decl, - header, + self.print_fn(&sig.decl, + sig.header, Some(item.ident.name), param_names, &item.vis, diff --git a/src/librustc/infer/error_reporting/nice_region_error/find_anon_type.rs b/src/librustc/infer/error_reporting/nice_region_error/find_anon_type.rs index f4751e591bf..db5557204e4 100644 --- a/src/librustc/infer/error_reporting/nice_region_error/find_anon_type.rs +++ b/src/librustc/infer/error_reporting/nice_region_error/find_anon_type.rs @@ -31,10 +31,10 @@ pub(super) fn find_anon_type( if let Some(hir_id) = self.tcx().hir().as_local_hir_id(def_id) { let fndecl = match self.tcx().hir().get(hir_id) { Node::Item(&hir::Item { - kind: hir::ItemKind::Fn(ref fndecl, ..), + kind: hir::ItemKind::Fn(ref m, ..), .. - }) => &fndecl, - Node::TraitItem(&hir::TraitItem { + }) + | Node::TraitItem(&hir::TraitItem { kind: hir::TraitItemKind::Method(ref m, ..), .. }) diff --git a/src/librustc/middle/reachable.rs b/src/librustc/middle/reachable.rs index 8be64bf64b5..f77f5a72e60 100644 --- a/src/librustc/middle/reachable.rs +++ b/src/librustc/middle/reachable.rs @@ -33,7 +33,7 @@ fn item_might_be_inlined(tcx: TyCtxt<'tcx>, item: &hir::Item, attrs: CodegenFnAt } match item.kind { - hir::ItemKind::Fn(_, header, ..) if header.is_const() => { + hir::ItemKind::Fn(ref sig, ..) if sig.header.is_const() => { return true; } hir::ItemKind::Impl(..) | @@ -225,8 +225,8 @@ fn propagate_node(&mut self, node: &Node<'tcx>, // If we are building an executable, only explicitly extern // types need to be exported. if let Node::Item(item) = *node { - let reachable = if let hir::ItemKind::Fn(_, header, ..) = item.kind { - header.abi != Abi::Rust + let reachable = if let hir::ItemKind::Fn(ref sig, ..) = item.kind { + sig.header.abi != Abi::Rust } else { false }; diff --git a/src/librustc/middle/resolve_lifetime.rs b/src/librustc/middle/resolve_lifetime.rs index 488d6332f7e..f37d9b2827b 100644 --- a/src/librustc/middle/resolve_lifetime.rs +++ b/src/librustc/middle/resolve_lifetime.rs @@ -460,8 +460,8 @@ fn visit_nested_body(&mut self, body: hir::BodyId) { fn visit_item(&mut self, item: &'tcx hir::Item) { match item.kind { - hir::ItemKind::Fn(ref decl, _, ref generics, _) => { - self.visit_early_late(None, decl, generics, |this| { + hir::ItemKind::Fn(ref sig, ref generics, _) => { + self.visit_early_late(None, &sig.decl, generics, |this| { intravisit::walk_item(this, item); }); } @@ -1524,8 +1524,8 @@ fn suggest_eliding_single_use_lifetime( { match parent { Node::Item(item) => { - if let hir::ItemKind::Fn(decl, _, _, _) = &item.kind { - find_arg_use_span(&decl.inputs); + if let hir::ItemKind::Fn(sig, _, _) = &item.kind { + find_arg_use_span(&sig.decl.inputs); } }, Node::ImplItem(impl_item) => { diff --git a/src/librustc/traits/error_reporting.rs b/src/librustc/traits/error_reporting.rs index fe18a14d890..54c01034221 100644 --- a/src/librustc/traits/error_reporting.rs +++ b/src/librustc/traits/error_reporting.rs @@ -383,9 +383,9 @@ fn describe_enclosure(&self, hir_id: hir::HirId) -> Option<&'static str> { let hir = &self.tcx.hir(); let node = hir.find(hir_id)?; if let hir::Node::Item( - hir::Item{kind: hir::ItemKind::Fn(_ ,fn_header ,_ , body_id), .. }) = &node { + hir::Item{kind: hir::ItemKind::Fn(sig, _, body_id), .. }) = &node { self.describe_generator(*body_id).or_else(|| - Some(if let hir::FnHeader{ asyncness: hir::IsAsync::Async, .. } = fn_header { + Some(if let hir::FnHeader{ asyncness: hir::IsAsync::Async, .. } = sig.header { "an async function" } else { "a function" @@ -1081,7 +1081,7 @@ fn suggest_restricting_param_bound( } hir::Node::Item(hir::Item { - kind: hir::ItemKind::Fn(_, _, generics, _), .. + kind: hir::ItemKind::Fn(_, generics, _), .. }) | hir::Node::TraitItem(hir::TraitItem { generics, @@ -1112,7 +1112,7 @@ fn suggest_restricting_param_bound( kind: hir::ItemKind::Impl(_, _, _, generics, ..), span, .. }) | hir::Node::Item(hir::Item { - kind: hir::ItemKind::Fn(_, _, generics, _), span, .. + kind: hir::ItemKind::Fn(_, generics, _), span, .. }) | hir::Node::Item(hir::Item { kind: hir::ItemKind::TyAlias(_, generics), span, .. @@ -1436,12 +1436,12 @@ fn suggest_semicolon_removal( let parent_node = hir.get_parent_node(obligation.cause.body_id); let node = hir.find(parent_node); if let Some(hir::Node::Item(hir::Item { - kind: hir::ItemKind::Fn(decl, _, _, body_id), + kind: hir::ItemKind::Fn(sig, _, body_id), .. })) = node { let body = hir.body(*body_id); if let hir::ExprKind::Block(blk, _) = &body.value.kind { - if decl.output.span().overlaps(span) && blk.expr.is_none() && + if sig.decl.output.span().overlaps(span) && blk.expr.is_none() && "()" == &trait_ref.self_ty().to_string() { // FIXME(estebank): When encountering a method with a trait @@ -1493,20 +1493,20 @@ pub fn get_fn_like_arguments(&self, node: Node<'_>) -> (Span, Vec) { } Node::Item(&hir::Item { span, - kind: hir::ItemKind::Fn(ref decl, ..), + kind: hir::ItemKind::Fn(ref sig, ..), .. }) | Node::ImplItem(&hir::ImplItem { span, - kind: hir::ImplItemKind::Method(hir::MethodSig { ref decl, .. }, _), + kind: hir::ImplItemKind::Method(ref sig, _), .. }) | Node::TraitItem(&hir::TraitItem { span, - kind: hir::TraitItemKind::Method(hir::MethodSig { ref decl, .. }, _), + kind: hir::TraitItemKind::Method(ref sig, _), .. }) => { - (self.tcx.sess.source_map().def_span(span), decl.inputs.iter() + (self.tcx.sess.source_map().def_span(span), sig.decl.inputs.iter() .map(|arg| match arg.clone().kind { hir::TyKind::Tup(ref tys) => ArgKind::Tuple( Some(arg.span), @@ -2040,11 +2040,11 @@ fn note_obligation_cause_for_async_await( .and_then(|parent_did| self.tcx.hir().get_if_local(parent_did)); debug!("note_obligation_cause_for_async_await: parent_node={:?}", parent_node); if let Some(hir::Node::Item(hir::Item { - kind: hir::ItemKind::Fn(_, header, _, _), + kind: hir::ItemKind::Fn(sig, _, _), .. })) = parent_node { - debug!("note_obligation_cause_for_async_await: header={:?}", header); - if header.asyncness != hir::IsAsync::Async { + debug!("note_obligation_cause_for_async_await: header={:?}", sig.header); + if sig.header.asyncness != hir::IsAsync::Async { return false; } } diff --git a/src/librustc_metadata/rmeta/encoder.rs b/src/librustc_metadata/rmeta/encoder.rs index afc81649e37..c6677ea3534 100644 --- a/src/librustc_metadata/rmeta/encoder.rs +++ b/src/librustc_metadata/rmeta/encoder.rs @@ -1095,10 +1095,10 @@ fn encode_info_for_item(&mut self, def_id: DefId, item: &'tcx hir::Item) { self.encode_rendered_const_for_body(body_id) ) } - hir::ItemKind::Fn(_, header, .., body) => { + hir::ItemKind::Fn(ref sig, .., body) => { let data = FnData { - asyncness: header.asyncness, - constness: header.constness, + asyncness: sig.header.asyncness, + constness: sig.header.constness, param_names: self.encode_fn_param_names_for_body(body), }; @@ -1284,14 +1284,14 @@ fn encode_info_for_item(&mut self, def_id: DefId, item: &'tcx hir::Item) { let mir = match item.kind { hir::ItemKind::Static(..) | hir::ItemKind::Const(..) => true, - hir::ItemKind::Fn(_, header, ..) => { + hir::ItemKind::Fn(ref sig, ..) => { let generics = tcx.generics_of(def_id); let needs_inline = (generics.requires_monomorphization(tcx) || tcx.codegen_fn_attrs(def_id).requests_inline()) && !self.metadata_output_only(); let always_encode_mir = self.tcx.sess.opts.debugging_opts.always_encode_mir; - needs_inline || header.constness == hir::Constness::Const || always_encode_mir + needs_inline || sig.header.constness == hir::Constness::Const || always_encode_mir } _ => false, }; diff --git a/src/librustc_mir/build/mod.rs b/src/librustc_mir/build/mod.rs index ffb70180bbb..59301619b4b 100644 --- a/src/librustc_mir/build/mod.rs +++ b/src/librustc_mir/build/mod.rs @@ -30,7 +30,12 @@ pub fn mir_build(tcx: TyCtxt<'_>, def_id: DefId) -> Body<'_> { // Figure out what primary body this item has. let (body_id, return_ty_span) = match tcx.hir().get(id) { Node::Expr(hir::Expr { kind: hir::ExprKind::Closure(_, decl, body_id, _, _), .. }) - | Node::Item(hir::Item { kind: hir::ItemKind::Fn(decl, _, _, body_id), .. }) + | Node::Item( + hir::Item { + kind: hir::ItemKind::Fn(hir::MethodSig { decl, .. }, _, body_id), + .. + } + ) | Node::ImplItem( hir::ImplItem { kind: hir::ImplItemKind::Method(hir::MethodSig { decl, .. }, body_id), diff --git a/src/librustc_mir/transform/check_unsafety.rs b/src/librustc_mir/transform/check_unsafety.rs index 7d550716858..4b57cb75cea 100644 --- a/src/librustc_mir/transform/check_unsafety.rs +++ b/src/librustc_mir/transform/check_unsafety.rs @@ -576,10 +576,10 @@ fn is_enclosed( if used_unsafe.contains(&parent_id) { Some(("block".to_string(), parent_id)) } else if let Some(Node::Item(&hir::Item { - kind: hir::ItemKind::Fn(_, header, _, _), + kind: hir::ItemKind::Fn(ref sig, _, _), .. })) = tcx.hir().find(parent_id) { - match header.unsafety { + match sig.header.unsafety { hir::Unsafety::Unsafe => Some(("fn".to_string(), parent_id)), hir::Unsafety::Normal => None, } diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index fe2c7a200d2..39a7996df0c 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -815,8 +815,8 @@ fn primary_body_of( hir::ItemKind::Const(ref ty, body) | hir::ItemKind::Static(ref ty, _, body) => Some((body, Some(ty), None, None)), - hir::ItemKind::Fn(ref decl, ref header, .., body) => - Some((body, None, Some(header), Some(decl))), + hir::ItemKind::Fn(ref sig, .., body) => + Some((body, None, Some(&sig.header), Some(&sig.decl))), _ => None, } @@ -1297,7 +1297,7 @@ fn check_fn<'a, 'tcx>( } if let Node::Item(item) = fcx.tcx.hir().get(fn_id) { - if let ItemKind::Fn(_, _, ref generics, _) = item.kind { + if let ItemKind::Fn(_, ref generics, _) = item.kind { if !generics.params.is_empty() { fcx.tcx.sess.span_err( span, @@ -1345,7 +1345,7 @@ fn check_fn<'a, 'tcx>( } if let Node::Item(item) = fcx.tcx.hir().get(fn_id) { - if let ItemKind::Fn(_, _, ref generics, _) = item.kind { + if let ItemKind::Fn(_, ref generics, _) = item.kind { if !generics.params.is_empty() { fcx.tcx.sess.span_err( span, @@ -4278,7 +4278,7 @@ fn parent_item_span(&self, id: hir::HirId) -> Option { let node = self.tcx.hir().get(self.tcx.hir().get_parent_item(id)); match node { Node::Item(&hir::Item { - kind: hir::ItemKind::Fn(_, _, _, body_id), .. + kind: hir::ItemKind::Fn(_, _, body_id), .. }) | Node::ImplItem(&hir::ImplItem { kind: hir::ImplItemKind::Method(_, body_id), .. @@ -4303,23 +4303,19 @@ fn get_parent_fn_decl(&self, blk_id: hir::HirId) -> Option<(&'tcx hir::FnDecl, a fn get_node_fn_decl(&self, node: Node<'tcx>) -> Option<(&'tcx hir::FnDecl, ast::Ident, bool)> { match node { Node::Item(&hir::Item { - ident, kind: hir::ItemKind::Fn(ref decl, ..), .. + ident, kind: hir::ItemKind::Fn(ref sig, ..), .. }) => { // This is less than ideal, it will not suggest a return type span on any // method called `main`, regardless of whether it is actually the entry point, // but it will still present it as the reason for the expected type. - Some((decl, ident, ident.name != sym::main)) + Some((&sig.decl, ident, ident.name != sym::main)) } Node::TraitItem(&hir::TraitItem { - ident, kind: hir::TraitItemKind::Method(hir::MethodSig { - ref decl, .. - }, ..), .. - }) => Some((decl, ident, true)), + ident, kind: hir::TraitItemKind::Method(ref sig, ..), .. + }) => Some((&sig.decl, ident, true)), Node::ImplItem(&hir::ImplItem { - ident, kind: hir::ImplItemKind::Method(hir::MethodSig { - ref decl, .. - }, ..), .. - }) => Some((decl, ident, false)), + ident, kind: hir::ImplItemKind::Method(ref sig, ..), .. + }) => Some((&sig.decl, ident, false)), _ => None, } } diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs index ef84f1cb20f..68fd29d04e3 100644 --- a/src/librustc_typeck/collect.rs +++ b/src/librustc_typeck/collect.rs @@ -885,8 +885,8 @@ fn has_late_bound_regions<'tcx>( _ => None, }, Node::Item(item) => match item.kind { - hir::ItemKind::Fn(ref fn_decl, .., ref generics, _) => { - has_late_bound_regions(tcx, generics, fn_decl) + hir::ItemKind::Fn(ref sig, .., ref generics, _) => { + has_late_bound_regions(tcx, generics, &sig.decl) } _ => None, }, @@ -1779,17 +1779,17 @@ fn fn_sig(tcx: TyCtxt<'_>, def_id: DefId) -> ty::PolyFnSig<'_> { match tcx.hir().get(hir_id) { TraitItem(hir::TraitItem { - kind: TraitItemKind::Method(MethodSig { header, decl }, TraitMethod::Provided(_)), + kind: TraitItemKind::Method(sig, TraitMethod::Provided(_)), .. }) | ImplItem(hir::ImplItem { - kind: ImplItemKind::Method(MethodSig { header, decl }, _), + kind: ImplItemKind::Method(sig, _), .. }) | Item(hir::Item { - kind: ItemKind::Fn(decl, header, _, _), + kind: ItemKind::Fn(sig, _, _), .. - }) => match get_infer_ret_ty(&decl.output) { + }) => match get_infer_ret_ty(&sig.decl.output) { Some(ty) => { let fn_sig = tcx.typeck_tables_of(def_id).liberated_fn_sigs()[hir_id]; let mut diag = bad_placeholder_type(tcx, ty.span); @@ -1805,7 +1805,7 @@ fn fn_sig(tcx: TyCtxt<'_>, def_id: DefId) -> ty::PolyFnSig<'_> { diag.emit(); ty::Binder::bind(fn_sig) }, - None => AstConv::ty_of_fn(&icx, header.unsafety, header.abi, decl) + None => AstConv::ty_of_fn(&icx, sig.header.unsafety, sig.header.abi, &sig.decl) }, TraitItem(hir::TraitItem { diff --git a/src/librustdoc/visit_ast.rs b/src/librustdoc/visit_ast.rs index 5a83569f02a..aea9b7c38ef 100644 --- a/src/librustdoc/visit_ast.rs +++ b/src/librustdoc/visit_ast.rs @@ -438,8 +438,8 @@ fn visit_item(&mut self, item: &'tcx hir::Item, om.structs.push(self.visit_variant_data(item, ident.name, sd, gen)), hir::ItemKind::Union(ref sd, ref gen) => om.unions.push(self.visit_union_data(item, ident.name, sd, gen)), - hir::ItemKind::Fn(ref fd, header, ref gen, body) => - self.visit_fn(om, item, ident.name, &**fd, header, gen, body), + hir::ItemKind::Fn(ref sig, ref gen, body) => + self.visit_fn(om, item, ident.name, &sig.decl, sig.header, gen, body), hir::ItemKind::TyAlias(ref ty, ref gen) => { let t = Typedef { ty, From 27511b22dfb08c98e53a8f672b2789d4de872f55 Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Thu, 7 Nov 2019 13:06:52 +0100 Subject: [PATCH 13/15] hir::MethodSig -> hir::FnSig --- src/librustc/hir/intravisit.rs | 2 +- src/librustc/hir/lowering/item.rs | 6 +++--- src/librustc/hir/map/blocks.rs | 12 ++++++------ src/librustc/hir/mod.rs | 11 ++++++----- src/librustc/hir/print.rs | 2 +- src/librustc_mir/build/mod.rs | 6 +++--- src/librustc_mir/monomorphize/collector.rs | 2 +- src/librustc_typeck/check/wfcheck.rs | 6 +++--- src/librustc_typeck/collect.rs | 2 +- src/librustdoc/clean/mod.rs | 2 +- 10 files changed, 26 insertions(+), 25 deletions(-) diff --git a/src/librustc/hir/intravisit.rs b/src/librustc/hir/intravisit.rs index 72de8ccd952..29e3f713276 100644 --- a/src/librustc/hir/intravisit.rs +++ b/src/librustc/hir/intravisit.rs @@ -45,7 +45,7 @@ pub enum FnKind<'a> { ItemFn(Ident, &'a Generics, FnHeader, &'a Visibility, &'a [Attribute]), /// `fn foo(&self)` - Method(Ident, &'a MethodSig, Option<&'a Visibility>, &'a [Attribute]), + Method(Ident, &'a FnSig, Option<&'a Visibility>, &'a [Attribute]), /// `|x, y| {}` Closure(&'a [Attribute]), diff --git a/src/librustc/hir/lowering/item.rs b/src/librustc/hir/lowering/item.rs index 5bc9fcb12f1..a01f59eea0b 100644 --- a/src/librustc/hir/lowering/item.rs +++ b/src/librustc/hir/lowering/item.rs @@ -328,7 +328,7 @@ fn lower_item_kind( header.asyncness.node.opt_return_id() ), ); - let sig = hir::MethodSig { decl, header: this.lower_fn_header(header) }; + let sig = hir::FnSig { decl, header: this.lower_fn_header(header) }; hir::ItemKind::Fn(sig, generics, body_id) }) } @@ -1259,7 +1259,7 @@ fn lower_method_sig( fn_def_id: DefId, impl_trait_return_allow: bool, is_async: Option, - ) -> (hir::Generics, hir::MethodSig) { + ) -> (hir::Generics, hir::FnSig) { let header = self.lower_fn_header(sig.header); let (generics, decl) = self.add_in_band_defs( generics, @@ -1272,7 +1272,7 @@ fn lower_method_sig( is_async, ), ); - (generics, hir::MethodSig { header, decl }) + (generics, hir::FnSig { header, decl }) } fn lower_is_auto(&mut self, a: IsAuto) -> hir::IsAuto { diff --git a/src/librustc/hir/map/blocks.rs b/src/librustc/hir/map/blocks.rs index b2f4a015711..f25f3b5741a 100644 --- a/src/librustc/hir/map/blocks.rs +++ b/src/librustc/hir/map/blocks.rs @@ -158,25 +158,25 @@ pub fn from_node(node: Node<'_>) -> Option> { pub fn body(self) -> ast::BodyId { self.handle(|i: ItemFnParts<'a>| i.body, - |_, _, _: &'a ast::MethodSig, _, body: ast::BodyId, _, _| body, + |_, _, _: &'a ast::FnSig, _, body: ast::BodyId, _, _| body, |c: ClosureParts<'a>| c.body) } pub fn decl(self) -> &'a FnDecl { self.handle(|i: ItemFnParts<'a>| &*i.decl, - |_, _, sig: &'a ast::MethodSig, _, _, _, _| &sig.decl, + |_, _, sig: &'a ast::FnSig, _, _, _, _| &sig.decl, |c: ClosureParts<'a>| c.decl) } pub fn span(self) -> Span { self.handle(|i: ItemFnParts<'_>| i.span, - |_, _, _: &'a ast::MethodSig, _, _, span, _| span, + |_, _, _: &'a ast::FnSig, _, _, span, _| span, |c: ClosureParts<'_>| c.span) } pub fn id(self) -> ast::HirId { self.handle(|i: ItemFnParts<'_>| i.id, - |id, _, _: &'a ast::MethodSig, _, _, _, _| id, + |id, _, _: &'a ast::FnSig, _, _, _, _| id, |c: ClosureParts<'_>| c.id) } @@ -199,7 +199,7 @@ pub fn kind(self) -> FnKind<'a> { let closure = |c: ClosureParts<'a>| { FnKind::Closure(c.attrs) }; - let method = |_, ident: Ident, sig: &'a ast::MethodSig, vis, _, _, attrs| { + let method = |_, ident: Ident, sig: &'a ast::FnSig, vis, _, _, attrs| { FnKind::Method(ident, sig, vis, attrs) }; self.handle(item, method, closure) @@ -209,7 +209,7 @@ fn handle(self, item_fn: I, method: M, closure: C) -> A where I: FnOnce(ItemFnParts<'a>) -> A, M: FnOnce(ast::HirId, Ident, - &'a ast::MethodSig, + &'a ast::FnSig, Option<&'a ast::Visibility>, ast::BodyId, Span, diff --git a/src/librustc/hir/mod.rs b/src/librustc/hir/mod.rs index 93503c15094..83f68e210bd 100644 --- a/src/librustc/hir/mod.rs +++ b/src/librustc/hir/mod.rs @@ -1876,9 +1876,10 @@ pub struct MutTy { pub mutbl: Mutability, } -/// Represents a method's signature in a trait declaration or implementation. +/// Represents a function's signature in a trait declaration, +/// trait implementation, or a free function. #[derive(RustcEncodable, RustcDecodable, Debug, HashStable)] -pub struct MethodSig { +pub struct FnSig { pub header: FnHeader, pub decl: P, } @@ -1921,7 +1922,7 @@ pub enum TraitItemKind { /// An associated constant with an optional value (otherwise `impl`s must contain a value). Const(P, Option), /// A method with an optional body. - Method(MethodSig, TraitMethod), + Method(FnSig, TraitMethod), /// An associated type with (possibly empty) bounds and optional concrete /// type. Type(GenericBounds, Option>), @@ -1955,7 +1956,7 @@ pub enum ImplItemKind { /// of the expression. Const(P, BodyId), /// A method implementation with the given signature and body. - Method(MethodSig, BodyId), + Method(FnSig, BodyId), /// An associated type. TyAlias(P), /// An associated `type = impl Trait`. @@ -2534,7 +2535,7 @@ pub enum ItemKind { /// A `const` item. Const(P, BodyId), /// A function declaration. - Fn(MethodSig, Generics, BodyId), + Fn(FnSig, Generics, BodyId), /// A module. Mod(Mod), /// An external module, e.g. `extern { .. }`. diff --git a/src/librustc/hir/print.rs b/src/librustc/hir/print.rs index 69d2a9ad281..d5fdde87329 100644 --- a/src/librustc/hir/print.rs +++ b/src/librustc/hir/print.rs @@ -835,7 +835,7 @@ pub fn print_variant(&mut self, v: &hir::Variant) { } pub fn print_method_sig(&mut self, ident: ast::Ident, - m: &hir::MethodSig, + m: &hir::FnSig, generics: &hir::Generics, vis: &hir::Visibility, arg_names: &[ast::Ident], diff --git a/src/librustc_mir/build/mod.rs b/src/librustc_mir/build/mod.rs index 59301619b4b..e2541eeedbc 100644 --- a/src/librustc_mir/build/mod.rs +++ b/src/librustc_mir/build/mod.rs @@ -32,20 +32,20 @@ pub fn mir_build(tcx: TyCtxt<'_>, def_id: DefId) -> Body<'_> { Node::Expr(hir::Expr { kind: hir::ExprKind::Closure(_, decl, body_id, _, _), .. }) | Node::Item( hir::Item { - kind: hir::ItemKind::Fn(hir::MethodSig { decl, .. }, _, body_id), + kind: hir::ItemKind::Fn(hir::FnSig { decl, .. }, _, body_id), .. } ) | Node::ImplItem( hir::ImplItem { - kind: hir::ImplItemKind::Method(hir::MethodSig { decl, .. }, body_id), + kind: hir::ImplItemKind::Method(hir::FnSig { decl, .. }, body_id), .. } ) | Node::TraitItem( hir::TraitItem { kind: hir::TraitItemKind::Method( - hir::MethodSig { decl, .. }, + hir::FnSig { decl, .. }, hir::TraitMethod::Provided(body_id), ), .. diff --git a/src/librustc_mir/monomorphize/collector.rs b/src/librustc_mir/monomorphize/collector.rs index 5e31b80bec6..49cdd914234 100644 --- a/src/librustc_mir/monomorphize/collector.rs +++ b/src/librustc_mir/monomorphize/collector.rs @@ -1071,7 +1071,7 @@ fn visit_trait_item(&mut self, _: &'v hir::TraitItem) { fn visit_impl_item(&mut self, ii: &'v hir::ImplItem) { match ii.kind { - hir::ImplItemKind::Method(hir::MethodSig { .. }, _) => { + hir::ImplItemKind::Method(hir::FnSig { .. }, _) => { let def_id = self.tcx.hir().local_def_id(ii.hir_id); self.push_if_root(def_id); } diff --git a/src/librustc_typeck/check/wfcheck.rs b/src/librustc_typeck/check/wfcheck.rs index 49b33ad4668..5b25d8f25a9 100644 --- a/src/librustc_typeck/check/wfcheck.rs +++ b/src/librustc_typeck/check/wfcheck.rs @@ -190,7 +190,7 @@ fn check_associated_item( tcx: TyCtxt<'_>, item_id: hir::HirId, span: Span, - sig_if_method: Option<&hir::MethodSig>, + sig_if_method: Option<&hir::FnSig>, ) { debug!("check_associated_item: {:?}", item_id); @@ -783,7 +783,7 @@ fn check_opaque_types<'fcx, 'tcx>( fn check_method_receiver<'fcx, 'tcx>( fcx: &FnCtxt<'fcx, 'tcx>, - method_sig: &hir::MethodSig, + fn_sig: &hir::FnSig, method: &ty::AssocItem, self_ty: Ty<'tcx>, ) { @@ -794,7 +794,7 @@ fn check_method_receiver<'fcx, 'tcx>( return; } - let span = method_sig.decl.inputs[0].span; + let span = fn_sig.decl.inputs[0].span; let sig = fcx.tcx.fn_sig(method.def_id); let sig = fcx.normalize_associated_types_in(span, &sig); diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs index 68fd29d04e3..9c1da65c846 100644 --- a/src/librustc_typeck/collect.rs +++ b/src/librustc_typeck/collect.rs @@ -1809,7 +1809,7 @@ fn fn_sig(tcx: TyCtxt<'_>, def_id: DefId) -> ty::PolyFnSig<'_> { }, TraitItem(hir::TraitItem { - kind: TraitItemKind::Method(MethodSig { header, decl }, _), + kind: TraitItemKind::Method(FnSig { header, decl }, _), .. }) => { AstConv::ty_of_fn(&icx, header.unsafety, header.abi, decl) diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index f6cac8ca48d..6696447ceae 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -1984,7 +1984,7 @@ pub struct Method { pub ret_types: Vec, } -impl<'a> Clean for (&'a hir::MethodSig, &'a hir::Generics, hir::BodyId, +impl<'a> Clean for (&'a hir::FnSig, &'a hir::Generics, hir::BodyId, Option) { fn clean(&self, cx: &DocContext<'_>) -> Method { let (generics, decl) = enter_impl_trait(cx, || { From 2cd48e8a3b71256d7db1ac61e8994c06620238b6 Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Thu, 7 Nov 2019 13:11:59 +0100 Subject: [PATCH 14/15] ast::MethodSig -> ast::FnSig --- src/librustc/hir/lowering/item.rs | 2 +- src/librustc/hir/map/def_collector.rs | 2 +- src/librustc_interface/util.rs | 4 ++-- src/librustc_save_analysis/dump_visitor.rs | 2 +- src/librustc_save_analysis/sig.rs | 4 ++-- src/libsyntax/ast.rs | 10 +++++----- src/libsyntax/mut_visit.rs | 2 +- src/libsyntax/parse/parser/item.rs | 6 +++--- src/libsyntax/print/pprust.rs | 2 +- src/libsyntax/visit.rs | 2 +- src/libsyntax_ext/deriving/generic/mod.rs | 2 +- 11 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/librustc/hir/lowering/item.rs b/src/librustc/hir/lowering/item.rs index a01f59eea0b..861130f0c69 100644 --- a/src/librustc/hir/lowering/item.rs +++ b/src/librustc/hir/lowering/item.rs @@ -1255,7 +1255,7 @@ fn lower_maybe_async_body( fn lower_method_sig( &mut self, generics: &Generics, - sig: &MethodSig, + sig: &FnSig, fn_def_id: DefId, impl_trait_return_allow: bool, is_async: Option, diff --git a/src/librustc/hir/map/def_collector.rs b/src/librustc/hir/map/def_collector.rs index 57c1421bde6..d705737cc93 100644 --- a/src/librustc/hir/map/def_collector.rs +++ b/src/librustc/hir/map/def_collector.rs @@ -228,7 +228,7 @@ fn visit_trait_item(&mut self, ti: &'a TraitItem) { fn visit_impl_item(&mut self, ii: &'a ImplItem) { let def_data = match ii.kind { - ImplItemKind::Method(MethodSig { + ImplItemKind::Method(FnSig { ref header, ref decl, }, ref body) if header.asyncness.node.is_async() => { diff --git a/src/librustc_interface/util.rs b/src/librustc_interface/util.rs index d0c15073f16..cd7af3be9b5 100644 --- a/src/librustc_interface/util.rs +++ b/src/librustc_interface/util.rs @@ -802,7 +802,7 @@ fn visit_item_kind(&mut self, i: &mut ast::ItemKind) { fn flat_map_trait_item(&mut self, i: ast::TraitItem) -> SmallVec<[ast::TraitItem; 1]> { let is_const = match i.kind { ast::TraitItemKind::Const(..) => true, - ast::TraitItemKind::Method(ast::MethodSig { ref decl, ref header, .. }, _) => + ast::TraitItemKind::Method(ast::FnSig { ref decl, ref header, .. }, _) => header.constness.node == ast::Constness::Const || Self::should_ignore_fn(decl), _ => false, }; @@ -812,7 +812,7 @@ fn visit_item_kind(&mut self, i: &mut ast::ItemKind) { fn flat_map_impl_item(&mut self, i: ast::ImplItem) -> SmallVec<[ast::ImplItem; 1]> { let is_const = match i.kind { ast::ImplItemKind::Const(..) => true, - ast::ImplItemKind::Method(ast::MethodSig { ref decl, ref header, .. }, _) => + ast::ImplItemKind::Method(ast::FnSig { ref decl, ref header, .. }, _) => header.constness.node == ast::Constness::Const || Self::should_ignore_fn(decl), _ => false, }; diff --git a/src/librustc_save_analysis/dump_visitor.rs b/src/librustc_save_analysis/dump_visitor.rs index 5c5fbcc07de..883d8964564 100644 --- a/src/librustc_save_analysis/dump_visitor.rs +++ b/src/librustc_save_analysis/dump_visitor.rs @@ -272,7 +272,7 @@ fn process_formals(&mut self, formals: &'l [ast::Param], qualname: &str) { fn process_method( &mut self, - sig: &'l ast::MethodSig, + sig: &'l ast::FnSig, body: Option<&'l ast::Block>, id: ast::NodeId, ident: ast::Ident, diff --git a/src/librustc_save_analysis/sig.rs b/src/librustc_save_analysis/sig.rs index 019e92717b5..887aeb03b89 100644 --- a/src/librustc_save_analysis/sig.rs +++ b/src/librustc_save_analysis/sig.rs @@ -72,7 +72,7 @@ pub fn method_signature( id: NodeId, ident: ast::Ident, generics: &ast::Generics, - m: &ast::MethodSig, + m: &ast::FnSig, scx: &SaveContext<'_, '_>, ) -> Option { if !scx.config.signatures { @@ -932,7 +932,7 @@ fn make_method_signature( id: NodeId, ident: ast::Ident, generics: &ast::Generics, - m: &ast::MethodSig, + m: &ast::FnSig, scx: &SaveContext<'_, '_>, ) -> Result { // FIXME code dup with function signature diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 18151a1586c..86a353cdfd2 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -1501,10 +1501,10 @@ pub struct MutTy { pub mutbl: Mutability, } -/// Represents a method's signature in a trait declaration, -/// or in an implementation. +/// Represents a function's signature in a trait declaration, +/// trait implementation, or free function. #[derive(Clone, RustcEncodable, RustcDecodable, Debug)] -pub struct MethodSig { +pub struct FnSig { pub header: FnHeader, pub decl: P, } @@ -1528,7 +1528,7 @@ pub struct TraitItem { #[derive(Clone, RustcEncodable, RustcDecodable, Debug)] pub enum TraitItemKind { Const(P, Option>), - Method(MethodSig, Option>), + Method(FnSig, Option>), Type(GenericBounds, Option>), Macro(Mac), } @@ -1552,7 +1552,7 @@ pub struct ImplItem { #[derive(Clone, RustcEncodable, RustcDecodable, Debug)] pub enum ImplItemKind { Const(P, P), - Method(MethodSig, P), + Method(FnSig, P), TyAlias(P), OpaqueTy(GenericBounds), Macro(Mac), diff --git a/src/libsyntax/mut_visit.rs b/src/libsyntax/mut_visit.rs index 0c90652526d..f2ad7dea73b 100644 --- a/src/libsyntax/mut_visit.rs +++ b/src/libsyntax/mut_visit.rs @@ -357,7 +357,7 @@ pub fn visit_bounds(bounds: &mut GenericBounds, vis: &mut T) { } // No `noop_` prefix because there isn't a corresponding method in `MutVisitor`. -pub fn visit_method_sig(MethodSig { header, decl }: &mut MethodSig, vis: &mut T) { +pub fn visit_method_sig(FnSig { header, decl }: &mut FnSig, vis: &mut T) { vis.visit_fn_header(header); vis.visit_fn_decl(decl); } diff --git a/src/libsyntax/parse/parser/item.rs b/src/libsyntax/parse/parser/item.rs index 3c618d75d34..500e70ae8e5 100644 --- a/src/libsyntax/parse/parser/item.rs +++ b/src/libsyntax/parse/parser/item.rs @@ -8,7 +8,7 @@ use crate::ast::{PathSegment, IsAuto, Constness, IsAsync, Unsafety, Defaultness}; use crate::ast::{Visibility, VisibilityKind, Mutability, FnHeader, ForeignItem, ForeignItemKind}; use crate::ast::{Ty, TyKind, Generics, GenericBounds, TraitRef, EnumDef, VariantData, StructField}; -use crate::ast::{Mac, MacDelimiter, Block, BindingMode, FnDecl, MethodSig, SelfKind, Param}; +use crate::ast::{Mac, MacDelimiter, Block, BindingMode, FnDecl, FnSig, SelfKind, Param}; use crate::parse::token; use crate::tokenstream::{TokenTree, TokenStream}; use crate::symbol::{kw, sym}; @@ -1897,14 +1897,14 @@ fn parse_trait_method_body( fn parse_method_sig( &mut self, is_name_required: fn(&token::Token) -> bool, - ) -> PResult<'a, (Ident, MethodSig, Generics)> { + ) -> PResult<'a, (Ident, FnSig, Generics)> { let header = self.parse_fn_front_matter()?; let (ident, decl, generics) = self.parse_fn_sig(ParamCfg { is_self_allowed: true, allow_c_variadic: false, is_name_required, })?; - Ok((ident, MethodSig { header, decl }, generics)) + Ok((ident, FnSig { header, decl }, generics)) } /// Parses all the "front matter" for a `fn` declaration, up to diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index 4ca4bdeb046..e7335a00cb0 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -1541,7 +1541,7 @@ fn print_poly_trait_ref(&mut self, t: &ast::PolyTraitRef) { crate fn print_method_sig(&mut self, ident: ast::Ident, generics: &ast::Generics, - m: &ast::MethodSig, + m: &ast::FnSig, vis: &ast::Visibility) { self.print_fn(&m.decl, diff --git a/src/libsyntax/visit.rs b/src/libsyntax/visit.rs index cfd160fd577..e2983db4318 100644 --- a/src/libsyntax/visit.rs +++ b/src/libsyntax/visit.rs @@ -25,7 +25,7 @@ pub enum FnKind<'a> { ItemFn(Ident, &'a FnHeader, &'a Visibility, &'a Block), /// E.g., `fn foo(&self)`. - Method(Ident, &'a MethodSig, Option<&'a Visibility>, &'a Block), + Method(Ident, &'a FnSig, Option<&'a Visibility>, &'a Block), /// E.g., `|x, y| body`. Closure(&'a Expr), diff --git a/src/libsyntax_ext/deriving/generic/mod.rs b/src/libsyntax_ext/deriving/generic/mod.rs index b18fd50ae76..b24306def74 100644 --- a/src/libsyntax_ext/deriving/generic/mod.rs +++ b/src/libsyntax_ext/deriving/generic/mod.rs @@ -950,7 +950,7 @@ fn create_method(&self, let trait_lo_sp = trait_.span.shrink_to_lo(); - let sig = ast::MethodSig { + let sig = ast::FnSig { header: ast::FnHeader { unsafety, abi: Abi::new(abi, trait_lo_sp), From b4c6abcf9e6c1d2710e7ad6a9ce44b3ca6b10d52 Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Thu, 7 Nov 2019 13:33:37 +0100 Subject: [PATCH 15/15] ast::ItemKind::Fn: use ast::FnSig --- src/librustc/hir/lowering/item.rs | 2 +- src/librustc/hir/map/def_collector.rs | 13 ++++--------- src/librustc_interface/util.rs | 13 +++++++------ src/librustc_passes/ast_validation.rs | 8 ++++---- src/librustc_resolve/late.rs | 2 +- src/librustc_save_analysis/dump_visitor.rs | 4 ++-- src/librustc_save_analysis/lib.rs | 4 ++-- src/librustc_save_analysis/sig.rs | 2 +- src/libsyntax/ast.rs | 2 +- src/libsyntax/mut_visit.rs | 11 +++++------ src/libsyntax/parse/parser/item.rs | 2 +- src/libsyntax/print/pprust.rs | 6 +++--- src/libsyntax/visit.rs | 9 ++++----- src/libsyntax_ext/global_allocator.rs | 15 +++++---------- src/libsyntax_ext/test.rs | 14 +++++++------- src/libsyntax_ext/test_harness.rs | 7 +++---- 16 files changed, 51 insertions(+), 63 deletions(-) diff --git a/src/librustc/hir/lowering/item.rs b/src/librustc/hir/lowering/item.rs index 861130f0c69..7aa1aa8bb51 100644 --- a/src/librustc/hir/lowering/item.rs +++ b/src/librustc/hir/lowering/item.rs @@ -306,7 +306,7 @@ fn lower_item_kind( self.lower_const_body(e) ) } - ItemKind::Fn(ref decl, header, ref generics, ref body) => { + ItemKind::Fn(FnSig { ref decl, header }, ref generics, ref body) => { let fn_def_id = self.resolver.definitions().local_def_id(id); self.with_new_scopes(|this| { this.current_item = Some(ident.span); diff --git a/src/librustc/hir/map/def_collector.rs b/src/librustc/hir/map/def_collector.rs index d705737cc93..d858e00a2e9 100644 --- a/src/librustc/hir/map/def_collector.rs +++ b/src/librustc/hir/map/def_collector.rs @@ -100,7 +100,7 @@ fn visit_item(&mut self, i: &'a Item) { // Pick the def data. This need not be unique, but the more // information we encapsulate into, the better - let def_data = match i.kind { + let def_data = match &i.kind { ItemKind::Impl(..) => DefPathData::Impl, ItemKind::Mod(..) if i.ident.name == kw::Invalid => { return visit::walk_item(self, i); @@ -109,19 +109,14 @@ fn visit_item(&mut self, i: &'a Item) { ItemKind::Enum(..) | ItemKind::Struct(..) | ItemKind::Union(..) | ItemKind::OpaqueTy(..) | ItemKind::ExternCrate(..) | ItemKind::ForeignMod(..) | ItemKind::TyAlias(..) => DefPathData::TypeNs(i.ident.name), - ItemKind::Fn( - ref decl, - ref header, - ref generics, - ref body, - ) if header.asyncness.node.is_async() => { + ItemKind::Fn(sig, generics, body) if sig.header.asyncness.node.is_async() => { return self.visit_async_fn( i.id, i.ident.name, i.span, - header, + &sig.header, generics, - decl, + &sig.decl, body, ) } diff --git a/src/librustc_interface/util.rs b/src/librustc_interface/util.rs index cd7af3be9b5..a74ea4bca39 100644 --- a/src/librustc_interface/util.rs +++ b/src/librustc_interface/util.rs @@ -786,14 +786,17 @@ fn any_involves_impl_trait<'a, I: Iterator>>(mut it: I) -> false } } + + fn is_sig_const(sig: &ast::FnSig) -> bool { + sig.header.constness.node == ast::Constness::Const || Self::should_ignore_fn(&sig.decl) + } } impl<'a> MutVisitor for ReplaceBodyWithLoop<'a> { fn visit_item_kind(&mut self, i: &mut ast::ItemKind) { let is_const = match i { ast::ItemKind::Static(..) | ast::ItemKind::Const(..) => true, - ast::ItemKind::Fn(ref decl, ref header, _, _) => - header.constness.node == ast::Constness::Const || Self::should_ignore_fn(decl), + ast::ItemKind::Fn(ref sig, _, _) => Self::is_sig_const(sig), _ => false, }; self.run(is_const, |s| noop_visit_item_kind(i, s)) @@ -802,8 +805,7 @@ fn visit_item_kind(&mut self, i: &mut ast::ItemKind) { fn flat_map_trait_item(&mut self, i: ast::TraitItem) -> SmallVec<[ast::TraitItem; 1]> { let is_const = match i.kind { ast::TraitItemKind::Const(..) => true, - ast::TraitItemKind::Method(ast::FnSig { ref decl, ref header, .. }, _) => - header.constness.node == ast::Constness::Const || Self::should_ignore_fn(decl), + ast::TraitItemKind::Method(ref sig, _) => Self::is_sig_const(sig), _ => false, }; self.run(is_const, |s| noop_flat_map_trait_item(i, s)) @@ -812,8 +814,7 @@ fn visit_item_kind(&mut self, i: &mut ast::ItemKind) { fn flat_map_impl_item(&mut self, i: ast::ImplItem) -> SmallVec<[ast::ImplItem; 1]> { let is_const = match i.kind { ast::ImplItemKind::Const(..) => true, - ast::ImplItemKind::Method(ast::FnSig { ref decl, ref header, .. }, _) => - header.constness.node == ast::Constness::Const || Self::should_ignore_fn(decl), + ast::ImplItemKind::Method(ref sig, _) => Self::is_sig_const(sig), _ => false, }; self.run(is_const, |s| noop_flat_map_impl_item(i, s)) diff --git a/src/librustc_passes/ast_validation.rs b/src/librustc_passes/ast_validation.rs index d1a801b3006..6151fc58d89 100644 --- a/src/librustc_passes/ast_validation.rs +++ b/src/librustc_passes/ast_validation.rs @@ -575,12 +575,12 @@ fn visit_item(&mut self, item: &'a Item) { .note("only trait implementations may be annotated with default").emit(); } } - ItemKind::Fn(ref decl, ref header, ref generics, _) => { - self.visit_fn_header(header); - self.check_fn_decl(decl); + ItemKind::Fn(ref sig, ref generics, _) => { + self.visit_fn_header(&sig.header); + self.check_fn_decl(&sig.decl); // We currently do not permit const generics in `const fn`, as // this is tantamount to allowing compile-time dependent typing. - if header.constness.node == Constness::Const { + if sig.header.constness.node == Constness::Const { // Look for const generics and error if we find any. for param in &generics.params { match param.kind { diff --git a/src/librustc_resolve/late.rs b/src/librustc_resolve/late.rs index 58af4b817d2..a23684ea649 100644 --- a/src/librustc_resolve/late.rs +++ b/src/librustc_resolve/late.rs @@ -731,7 +731,7 @@ fn resolve_item(&mut self, item: &Item) { match item.kind { ItemKind::TyAlias(_, ref generics) | ItemKind::OpaqueTy(_, ref generics) | - ItemKind::Fn(_, _, ref generics, _) => { + ItemKind::Fn(_, ref generics, _) => { self.with_generic_param_rib(generics, ItemRibKind(HasGenericParams::Yes), |this| visit::walk_item(this, item)); } diff --git a/src/librustc_save_analysis/dump_visitor.rs b/src/librustc_save_analysis/dump_visitor.rs index 883d8964564..92c391fb4a3 100644 --- a/src/librustc_save_analysis/dump_visitor.rs +++ b/src/librustc_save_analysis/dump_visitor.rs @@ -1334,8 +1334,8 @@ fn visit_item(&mut self, item: &'l ast::Item) { ); } } - Fn(ref decl, ref header, ref ty_params, ref body) => { - self.process_fn(item, &decl, &header, ty_params, &body) + Fn(ref sig, ref ty_params, ref body) => { + self.process_fn(item, &sig.decl, &sig.header, ty_params, &body) } Static(ref typ, _, ref expr) => self.process_static_or_const_item(item, typ, expr), Const(ref typ, ref expr) => self.process_static_or_const_item(item, &typ, &expr), diff --git a/src/librustc_save_analysis/lib.rs b/src/librustc_save_analysis/lib.rs index a2f8837c581..424d57c8fe7 100644 --- a/src/librustc_save_analysis/lib.rs +++ b/src/librustc_save_analysis/lib.rs @@ -180,7 +180,7 @@ pub fn get_extern_item_data(&self, item: &ast::ForeignItem) -> Option { pub fn get_item_data(&self, item: &ast::Item) -> Option { match item.kind { - ast::ItemKind::Fn(ref decl, .., ref generics, _) => { + ast::ItemKind::Fn(ref sig, .., ref generics, _) => { let qualname = format!("::{}", self.tcx.def_path_str(self.tcx.hir().local_def_id_from_node_id(item.id))); filter!(self.span_utils, item.ident.span); @@ -190,7 +190,7 @@ pub fn get_item_data(&self, item: &ast::Item) -> Option { span: self.span_from_span(item.ident.span), name: item.ident.to_string(), qualname, - value: make_signature(decl, generics), + value: make_signature(&sig.decl, generics), parent: None, children: vec![], decl_id: None, diff --git a/src/librustc_save_analysis/sig.rs b/src/librustc_save_analysis/sig.rs index 887aeb03b89..d1b9b8ff44d 100644 --- a/src/librustc_save_analysis/sig.rs +++ b/src/librustc_save_analysis/sig.rs @@ -376,7 +376,7 @@ fn make(&self, offset: usize, _parent_id: Option, scx: &SaveContext<'_, Ok(extend_sig(ty, text, defs, vec![])) } - ast::ItemKind::Fn(ref decl, header, ref generics, _) => { + ast::ItemKind::Fn(ast::FnSig { ref decl, header }, ref generics, _) => { let mut text = String::new(); if header.constness.node == ast::Constness::Const { text.push_str("const "); diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 86a353cdfd2..b57d2238991 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -2433,7 +2433,7 @@ pub enum ItemKind { /// A function declaration (`fn`). /// /// E.g., `fn foo(bar: usize) -> usize { .. }`. - Fn(P, FnHeader, Generics, P), + Fn(FnSig, Generics, P), /// A module declaration (`mod`). /// /// E.g., `mod foo;` or `mod foo { .. }`. diff --git a/src/libsyntax/mut_visit.rs b/src/libsyntax/mut_visit.rs index f2ad7dea73b..7696ea48f93 100644 --- a/src/libsyntax/mut_visit.rs +++ b/src/libsyntax/mut_visit.rs @@ -357,7 +357,7 @@ pub fn visit_bounds(bounds: &mut GenericBounds, vis: &mut T) { } // No `noop_` prefix because there isn't a corresponding method in `MutVisitor`. -pub fn visit_method_sig(FnSig { header, decl }: &mut FnSig, vis: &mut T) { +pub fn visit_fn_sig(FnSig { header, decl }: &mut FnSig, vis: &mut T) { vis.visit_fn_header(header); vis.visit_fn_decl(decl); } @@ -878,9 +878,8 @@ pub fn noop_visit_item_kind(kind: &mut ItemKind, vis: &mut T) { vis.visit_ty(ty); vis.visit_expr(expr); } - ItemKind::Fn(decl, header, generics, body) => { - vis.visit_fn_decl(decl); - vis.visit_fn_header(header); + ItemKind::Fn(sig, generics, body) => { + visit_fn_sig(sig, vis); vis.visit_generics(generics); vis.visit_block(body); } @@ -938,7 +937,7 @@ pub fn noop_flat_map_trait_item(mut item: TraitItem, vis: &mut T) visit_opt(default, |default| vis.visit_expr(default)); } TraitItemKind::Method(sig, body) => { - visit_method_sig(sig, vis); + visit_fn_sig(sig, vis); visit_opt(body, |body| vis.visit_block(body)); } TraitItemKind::Type(bounds, default) => { @@ -970,7 +969,7 @@ pub fn noop_flat_map_impl_item(mut item: ImplItem, visitor: &mut visitor.visit_expr(expr); } ImplItemKind::Method(sig, body) => { - visit_method_sig(sig, visitor); + visit_fn_sig(sig, visitor); visitor.visit_block(body); } ImplItemKind::TyAlias(ty) => visitor.visit_ty(ty), diff --git a/src/libsyntax/parse/parser/item.rs b/src/libsyntax/parse/parser/item.rs index 500e70ae8e5..531ad532a54 100644 --- a/src/libsyntax/parse/parser/item.rs +++ b/src/libsyntax/parse/parser/item.rs @@ -1800,7 +1800,7 @@ fn parse_item_fn( is_name_required: |_| true, })?; let (inner_attrs, body) = self.parse_inner_attrs_and_block()?; - let kind = ItemKind::Fn(decl, header, generics, body); + let kind = ItemKind::Fn(FnSig { decl, header }, generics, body); self.mk_item_with_info(attrs, lo, vis, (ident, kind, Some(inner_attrs))) } diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index e7335a00cb0..2203e8d9d06 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -1199,11 +1199,11 @@ fn print_associated_type(&mut self, self.s.word(";"); self.end(); // end the outer cbox } - ast::ItemKind::Fn(ref decl, header, ref param_names, ref body) => { + ast::ItemKind::Fn(ref sig, ref param_names, ref body) => { self.head(""); self.print_fn( - decl, - header, + &sig.decl, + sig.header, Some(item.ident), param_names, &item.vis diff --git a/src/libsyntax/visit.rs b/src/libsyntax/visit.rs index e2983db4318..ea2dc357e6e 100644 --- a/src/libsyntax/visit.rs +++ b/src/libsyntax/visit.rs @@ -244,12 +244,11 @@ pub fn walk_item<'a, V: Visitor<'a>>(visitor: &mut V, item: &'a Item) { visitor.visit_ty(typ); visitor.visit_expr(expr); } - ItemKind::Fn(ref declaration, ref header, ref generics, ref body) => { + ItemKind::Fn(ref sig, ref generics, ref body) => { visitor.visit_generics(generics); - visitor.visit_fn_header(header); - visitor.visit_fn(FnKind::ItemFn(item.ident, header, - &item.vis, body), - declaration, + visitor.visit_fn_header(&sig.header); + visitor.visit_fn(FnKind::ItemFn(item.ident, &sig.header, &item.vis, body), + &sig.decl, item.span, item.id) } diff --git a/src/libsyntax_ext/global_allocator.rs b/src/libsyntax_ext/global_allocator.rs index 90d2ea38bc3..dc29e057455 100644 --- a/src/libsyntax_ext/global_allocator.rs +++ b/src/libsyntax_ext/global_allocator.rs @@ -1,7 +1,7 @@ use crate::util::check_builtin_macro_attribute; use syntax::ast::{ItemKind, Mutability, Stmt, Ty, TyKind, Unsafety}; -use syntax::ast::{self, Param, Attribute, Expr, FnHeader, Generics, Ident}; +use syntax::ast::{self, Param, Attribute, Expr, FnSig, FnHeader, Generics, Ident}; use syntax::expand::allocator::{AllocatorKind, AllocatorMethod, AllocatorTy, ALLOCATOR_METHODS}; use syntax::ptr::P; use syntax::symbol::{kw, sym, Symbol}; @@ -73,15 +73,10 @@ fn allocator_fn(&self, method: &AllocatorMethod) -> Stmt { .collect(); let result = self.call_allocator(method.name, args); let (output_ty, output_expr) = self.ret_ty(&method.output, result); - let kind = ItemKind::Fn( - self.cx.fn_decl(abi_args, ast::FunctionRetTy::Ty(output_ty)), - FnHeader { - unsafety: Unsafety::Unsafe, - ..FnHeader::default() - }, - Generics::default(), - self.cx.block_expr(output_expr), - ); + let decl = self.cx.fn_decl(abi_args, ast::FunctionRetTy::Ty(output_ty)); + let header = FnHeader { unsafety: Unsafety::Unsafe, ..FnHeader::default() }; + let sig = FnSig { decl, header }; + let kind = ItemKind::Fn(sig, Generics::default(), self.cx.block_expr(output_expr)); let item = self.cx.item( self.span, self.cx.ident_of(&self.kind.fn_name(method.name), self.span), diff --git a/src/libsyntax_ext/test.rs b/src/libsyntax_ext/test.rs index b0da413d63a..8656100c921 100644 --- a/src/libsyntax_ext/test.rs +++ b/src/libsyntax_ext/test.rs @@ -310,15 +310,15 @@ fn test_type(cx: &ExtCtxt<'_>) -> TestType { fn has_test_signature(cx: &ExtCtxt<'_>, i: &ast::Item) -> bool { let has_should_panic_attr = attr::contains_name(&i.attrs, sym::should_panic); let ref sd = cx.parse_sess.span_diagnostic; - if let ast::ItemKind::Fn(ref decl, ref header, ref generics, _) = i.kind { - if header.unsafety == ast::Unsafety::Unsafe { + if let ast::ItemKind::Fn(ref sig, ref generics, _) = i.kind { + if sig.header.unsafety == ast::Unsafety::Unsafe { sd.span_err( i.span, "unsafe functions cannot be used for tests" ); return false } - if header.asyncness.node.is_async() { + if sig.header.asyncness.node.is_async() { sd.span_err( i.span, "async functions cannot be used for tests" @@ -329,13 +329,13 @@ fn has_test_signature(cx: &ExtCtxt<'_>, i: &ast::Item) -> bool { // If the termination trait is active, the compiler will check that the output // type implements the `Termination` trait as `libtest` enforces that. - let has_output = match decl.output { + let has_output = match sig.decl.output { ast::FunctionRetTy::Default(..) => false, ast::FunctionRetTy::Ty(ref t) if t.kind.is_unit() => false, _ => true }; - if !decl.inputs.is_empty() { + if !sig.decl.inputs.is_empty() { sd.span_err(i.span, "functions used as tests can not have any arguments"); return false; } @@ -361,10 +361,10 @@ fn has_test_signature(cx: &ExtCtxt<'_>, i: &ast::Item) -> bool { } fn has_bench_signature(cx: &ExtCtxt<'_>, i: &ast::Item) -> bool { - let has_sig = if let ast::ItemKind::Fn(ref decl, _, _, _) = i.kind { + let has_sig = if let ast::ItemKind::Fn(ref sig, _, _) = i.kind { // N.B., inadequate check, but we're running // well before resolve, can't get too deep. - decl.inputs.len() == 1 + sig.decl.inputs.len() == 1 } else { false }; diff --git a/src/libsyntax_ext/test_harness.rs b/src/libsyntax_ext/test_harness.rs index 33d41a7f53e..1492f6f575f 100644 --- a/src/libsyntax_ext/test_harness.rs +++ b/src/libsyntax_ext/test_harness.rs @@ -306,10 +306,9 @@ fn mk_main(cx: &mut TestCtxt<'_>) -> P { ecx.block(sp, vec![call_test_main]) }; - let main = ast::ItemKind::Fn(ecx.fn_decl(vec![], ast::FunctionRetTy::Ty(main_ret_ty)), - ast::FnHeader::default(), - ast::Generics::default(), - main_body); + let decl = ecx.fn_decl(vec![], ast::FunctionRetTy::Ty(main_ret_ty)); + let sig = ast::FnSig { decl, header: ast::FnHeader::default() }; + let main = ast::ItemKind::Fn(sig, ast::Generics::default(), main_body); // Honor the reexport_test_harness_main attribute let main_id = match cx.reexport_test_harness_main {