From 6a90f1414fbe5109c0954f7927726c1f3e866067 Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Wed, 9 Jan 2019 20:53:33 +0900 Subject: [PATCH 01/10] Add check_attribute --- src/librustc_lint/builtin.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/librustc_lint/builtin.rs b/src/librustc_lint/builtin.rs index a555b7790971f..f41954f56500e 100644 --- a/src/librustc_lint/builtin.rs +++ b/src/librustc_lint/builtin.rs @@ -227,6 +227,12 @@ impl UnsafeCode { } impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnsafeCode { + fn check_attribute(&mut self, cx: &LateContext, attr: &ast::Attribute) { + if attr.check_name("allow_internal_unsafe") { + self.report_unsafe(cx, attr.span, "`allow_internal_unsafe` allows defining macros using unsafe without triggering the `unsafe_code` lint at their call site"); + } + } + fn check_expr(&mut self, cx: &LateContext, e: &hir::Expr) { if let hir::ExprKind::Block(ref blk, _) = e.node { // Don't warn about generated blocks, that'll just pollute the output. From 3cf3ed787740a82b4f3ab76db454218177a7a08a Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Wed, 9 Jan 2019 21:13:42 +0900 Subject: [PATCH 02/10] Separate the description on different lines --- src/librustc_lint/builtin.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/librustc_lint/builtin.rs b/src/librustc_lint/builtin.rs index f41954f56500e..18b83fa1eaef1 100644 --- a/src/librustc_lint/builtin.rs +++ b/src/librustc_lint/builtin.rs @@ -229,7 +229,9 @@ impl UnsafeCode { impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnsafeCode { fn check_attribute(&mut self, cx: &LateContext, attr: &ast::Attribute) { if attr.check_name("allow_internal_unsafe") { - self.report_unsafe(cx, attr.span, "`allow_internal_unsafe` allows defining macros using unsafe without triggering the `unsafe_code` lint at their call site"); + self.report_unsafe(cx, attr.span, "`allow_internal_unsafe` allows defining \ + macros using unsafe without triggering \ + the `unsafe_code` lint at their call site"); } } From ea5197c664bbd1f1f7e8210544a32f1cb1cdfaec Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Tue, 15 Jan 2019 05:36:46 +0900 Subject: [PATCH 03/10] Add PartialEq --- src/libsyntax/ast.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index e3a8980a975c1..99ab9fbcf5fa0 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -853,13 +853,13 @@ pub struct Field { pub type SpannedIdent = Spanned; -#[derive(Clone, RustcEncodable, RustcDecodable, Debug, Copy)] +#[derive(Clone, PartialEq, RustcEncodable, RustcDecodable, Debug, Copy)] pub enum BlockCheckMode { Default, Unsafe(UnsafeSource), } -#[derive(Clone, RustcEncodable, RustcDecodable, Debug, Copy)] +#[derive(Clone, PartialEq, RustcEncodable, RustcDecodable, Debug, Copy)] pub enum UnsafeSource { CompilerGenerated, UserProvided, From f18ae26840399371ea969e70e9d1a79823f800b8 Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Tue, 15 Jan 2019 05:42:09 +0900 Subject: [PATCH 04/10] Run lint for unsafe on the ast --- src/librustc_lint/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustc_lint/lib.rs b/src/librustc_lint/lib.rs index 4dfb664451b91..0d05cc1b2be9e 100644 --- a/src/librustc_lint/lib.rs +++ b/src/librustc_lint/lib.rs @@ -111,6 +111,7 @@ pub fn register_builtins(store: &mut lint::LintStore, sess: Option<&Session>) { add_early_builtin!(sess, UnusedParens, UnusedImportBraces, + UnsafeCode, AnonymousParameters, UnusedDocComment, BadRepr, @@ -134,7 +135,6 @@ pub fn register_builtins(store: &mut lint::LintStore, sess: Option<&Session>) { NonSnakeCase: NonSnakeCase, NonUpperCaseGlobals: NonUpperCaseGlobals, NonShorthandFieldPatterns: NonShorthandFieldPatterns, - UnsafeCode: UnsafeCode, UnusedAllocation: UnusedAllocation, MissingCopyImplementations: MissingCopyImplementations, UnstableFeatures: UnstableFeatures, From 60a68bed7b1da4cd9052c2610525c3c50dd344d2 Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Tue, 15 Jan 2019 06:54:28 +0900 Subject: [PATCH 05/10] Make UnsafeCode EarlyLintPass --- src/librustc_lint/builtin.rs | 42 +++++++++++++++++------------------- 1 file changed, 20 insertions(+), 22 deletions(-) diff --git a/src/librustc_lint/builtin.rs b/src/librustc_lint/builtin.rs index 18b83fa1eaef1..6cd632321cc1a 100644 --- a/src/librustc_lint/builtin.rs +++ b/src/librustc_lint/builtin.rs @@ -40,9 +40,9 @@ use syntax_pos::{BytePos, Span, SyntaxContext}; use syntax::symbol::keywords; use syntax::errors::{Applicability, DiagnosticBuilder}; use syntax::print::pprust::expr_to_string; +use syntax::visit::FnKind; use rustc::hir::{self, GenericParamKind, PatKind}; -use rustc::hir::intravisit::FnKind; use nonstandard_style::{MethodLateContext, method_context}; @@ -216,7 +216,7 @@ impl LintPass for UnsafeCode { } impl UnsafeCode { - fn report_unsafe(&self, cx: &LateContext, span: Span, desc: &'static str) { + fn report_unsafe(&self, cx: &EarlyContext, span: Span, desc: &'static str) { // This comes from a macro that has #[allow_internal_unsafe]. if span.allows_unsafe() { return; @@ -226,31 +226,30 @@ impl UnsafeCode { } } -impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnsafeCode { - fn check_attribute(&mut self, cx: &LateContext, attr: &ast::Attribute) { +impl EarlyLintPass for UnsafeCode { + fn check_attribute(&mut self, cx: &EarlyContext, attr: &ast::Attribute) { if attr.check_name("allow_internal_unsafe") { - self.report_unsafe(cx, attr.span, "`allow_internal_unsafe` allows defining \ - macros using unsafe without triggering \ - the `unsafe_code` lint at their call site"); + self.report_unsafe(cx, attr.span, "cannot use `allow_internal_unsafe` \ + with `forbid(unsafe_code)`"); } } - fn check_expr(&mut self, cx: &LateContext, e: &hir::Expr) { - if let hir::ExprKind::Block(ref blk, _) = e.node { + fn check_expr(&mut self, cx: &EarlyContext, e: &ast::Expr) { + if let ast::ExprKind::Block(ref blk, _) = e.node { // Don't warn about generated blocks, that'll just pollute the output. - if blk.rules == hir::UnsafeBlock(hir::UserProvided) { + if blk.rules == ast::BlockCheckMode::Unsafe(ast::UserProvided) { self.report_unsafe(cx, blk.span, "usage of an `unsafe` block"); } } } - fn check_item(&mut self, cx: &LateContext, it: &hir::Item) { + fn check_item(&mut self, cx: &EarlyContext, it: &ast::Item) { match it.node { - hir::ItemKind::Trait(_, hir::Unsafety::Unsafe, ..) => { + ast::ItemKind::Trait(_, ast::Unsafety::Unsafe, ..) => { self.report_unsafe(cx, it.span, "declaration of an `unsafe` trait") } - hir::ItemKind::Impl(hir::Unsafety::Unsafe, ..) => { + ast::ItemKind::Impl(ast::Unsafety::Unsafe, ..) => { self.report_unsafe(cx, it.span, "implementation of an `unsafe` trait") } @@ -259,19 +258,18 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnsafeCode { } fn check_fn(&mut self, - cx: &LateContext, - fk: FnKind<'tcx>, - _: &hir::FnDecl, - _: &hir::Body, + cx: &EarlyContext, + fk: FnKind, + _: &ast::FnDecl, span: Span, _: ast::NodeId) { match fk { - FnKind::ItemFn(_, _, hir::FnHeader { unsafety: hir::Unsafety::Unsafe, .. }, ..) => { + FnKind::ItemFn(_, ast::FnHeader { unsafety: ast::Unsafety::Unsafe, .. }, ..) => { self.report_unsafe(cx, span, "declaration of an `unsafe` function") } FnKind::Method(_, sig, ..) => { - if sig.header.unsafety == hir::Unsafety::Unsafe { + if sig.header.unsafety == ast::Unsafety::Unsafe { self.report_unsafe(cx, span, "implementation of an `unsafe` method") } } @@ -280,9 +278,9 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnsafeCode { } } - fn check_trait_item(&mut self, cx: &LateContext, item: &hir::TraitItem) { - if let hir::TraitItemKind::Method(ref sig, hir::TraitMethod::Required(_)) = item.node { - if sig.header.unsafety == hir::Unsafety::Unsafe { + fn check_trait_item(&mut self, cx: &EarlyContext, item: &ast::TraitItem) { + if let ast::TraitItemKind::Method(ref sig, _) = item.node { + if sig.header.unsafety == ast::Unsafety::Unsafe { self.report_unsafe(cx, item.span, "declaration of an `unsafe` method") } } From efd111e5026ccc78f78c3534267e5ba74899f268 Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Tue, 15 Jan 2019 06:55:17 +0900 Subject: [PATCH 06/10] Add test --- src/test/ui/lint/lint-forbid-internal-unsafe.rs | 16 ++++++++++++++++ .../ui/lint/lint-forbid-internal-unsafe.stderr | 14 ++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 src/test/ui/lint/lint-forbid-internal-unsafe.rs create mode 100644 src/test/ui/lint/lint-forbid-internal-unsafe.stderr diff --git a/src/test/ui/lint/lint-forbid-internal-unsafe.rs b/src/test/ui/lint/lint-forbid-internal-unsafe.rs new file mode 100644 index 0000000000000..7f58b7280f359 --- /dev/null +++ b/src/test/ui/lint/lint-forbid-internal-unsafe.rs @@ -0,0 +1,16 @@ +#![forbid(unsafe_code)] +#![feature(allow_internal_unsafe)] + +#[allow_internal_unsafe] +//~^ ERROR: cannot use `allow_internal_unsafe` with `forbid(unsafe_code)` +macro_rules! evil { + ($e:expr) => { + unsafe { + $e + } + } +} + +fn main() { + println!("{}", evil!(*(0 as *const u8))); +} diff --git a/src/test/ui/lint/lint-forbid-internal-unsafe.stderr b/src/test/ui/lint/lint-forbid-internal-unsafe.stderr new file mode 100644 index 0000000000000..b65ba6118b951 --- /dev/null +++ b/src/test/ui/lint/lint-forbid-internal-unsafe.stderr @@ -0,0 +1,14 @@ +error: cannot use `allow_internal_unsafe` with `forbid(unsafe_code)` + --> $DIR/lint-forbid-internal-unsafe.rs:4:1 + | +LL | #[allow_internal_unsafe] + | ^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: lint level defined here + --> $DIR/lint-forbid-internal-unsafe.rs:1:11 + | +LL | #![forbid(unsafe_code)] + | ^^^^^^^^^^^ + +error: aborting due to previous error + From a7623e70d5d3f27293483b0d609d7c446f3499f7 Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Tue, 15 Jan 2019 06:56:21 +0900 Subject: [PATCH 07/10] Add error check --- src/test/ui/lint/lint-unsafe-code.rs | 3 ++ src/test/ui/lint/lint-unsafe-code.stderr | 36 ++++++++++++++++++------ 2 files changed, 30 insertions(+), 9 deletions(-) diff --git a/src/test/ui/lint/lint-unsafe-code.rs b/src/test/ui/lint/lint-unsafe-code.rs index 735f33f601f9d..b6d2da12db30c 100644 --- a/src/test/ui/lint/lint-unsafe-code.rs +++ b/src/test/ui/lint/lint-unsafe-code.rs @@ -27,7 +27,9 @@ unsafe impl Foo for Bar {} //~ ERROR: implementation of an `unsafe` trait trait Baz { unsafe fn baz(&self); //~ ERROR: declaration of an `unsafe` method unsafe fn provided(&self) {} //~ ERROR: implementation of an `unsafe` method + //~^ ERROR: declaration of an `unsafe` method unsafe fn provided_override(&self) {} //~ ERROR: implementation of an `unsafe` method + //~^ ERROR: declaration of an `unsafe` method } impl Baz for Bar { @@ -63,6 +65,7 @@ trait C { #[allow(unsafe_code)] unsafe fn baz(&self); unsafe fn provided(&self) {} //~ ERROR: implementation of an `unsafe` method + //~^ ERROR: declaration of an `unsafe` method } impl C for Bar { diff --git a/src/test/ui/lint/lint-unsafe-code.stderr b/src/test/ui/lint/lint-unsafe-code.stderr index e2dd45e2c8a31..2d08902dc698f 100644 --- a/src/test/ui/lint/lint-unsafe-code.stderr +++ b/src/test/ui/lint/lint-unsafe-code.stderr @@ -28,56 +28,74 @@ error: declaration of an `unsafe` method LL | unsafe fn baz(&self); //~ ERROR: declaration of an `unsafe` method | ^^^^^^^^^^^^^^^^^^^^^ +error: declaration of an `unsafe` method + --> $DIR/lint-unsafe-code.rs:29:5 + | +LL | unsafe fn provided(&self) {} //~ ERROR: implementation of an `unsafe` method + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + error: implementation of an `unsafe` method --> $DIR/lint-unsafe-code.rs:29:5 | LL | unsafe fn provided(&self) {} //~ ERROR: implementation of an `unsafe` method | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +error: declaration of an `unsafe` method + --> $DIR/lint-unsafe-code.rs:31:5 + | +LL | unsafe fn provided_override(&self) {} //~ ERROR: implementation of an `unsafe` method + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + error: implementation of an `unsafe` method - --> $DIR/lint-unsafe-code.rs:30:5 + --> $DIR/lint-unsafe-code.rs:31:5 | LL | unsafe fn provided_override(&self) {} //~ ERROR: implementation of an `unsafe` method | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: implementation of an `unsafe` method - --> $DIR/lint-unsafe-code.rs:34:5 + --> $DIR/lint-unsafe-code.rs:36:5 | LL | unsafe fn baz(&self) {} //~ ERROR: implementation of an `unsafe` method | ^^^^^^^^^^^^^^^^^^^^^^^ error: implementation of an `unsafe` method - --> $DIR/lint-unsafe-code.rs:35:5 + --> $DIR/lint-unsafe-code.rs:37:5 | LL | unsafe fn provided_override(&self) {} //~ ERROR: implementation of an `unsafe` method | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: implementation of an `unsafe` method - --> $DIR/lint-unsafe-code.rs:54:5 + --> $DIR/lint-unsafe-code.rs:56:5 | LL | unsafe fn provided_override(&self) {} //~ ERROR: implementation of an `unsafe` method | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +error: declaration of an `unsafe` method + --> $DIR/lint-unsafe-code.rs:67:5 + | +LL | unsafe fn provided(&self) {} //~ ERROR: implementation of an `unsafe` method + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + error: implementation of an `unsafe` method - --> $DIR/lint-unsafe-code.rs:65:5 + --> $DIR/lint-unsafe-code.rs:67:5 | LL | unsafe fn provided(&self) {} //~ ERROR: implementation of an `unsafe` method | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: implementation of an `unsafe` method - --> $DIR/lint-unsafe-code.rs:71:5 + --> $DIR/lint-unsafe-code.rs:74:5 | LL | unsafe fn provided(&self) {} //~ ERROR: implementation of an `unsafe` method | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: implementation of an `unsafe` method - --> $DIR/lint-unsafe-code.rs:75:5 + --> $DIR/lint-unsafe-code.rs:78:5 | LL | unsafe fn baz(&self) {} //~ ERROR: implementation of an `unsafe` method | ^^^^^^^^^^^^^^^^^^^^^^^ error: usage of an `unsafe` block - --> $DIR/lint-unsafe-code.rs:86:5 + --> $DIR/lint-unsafe-code.rs:89:5 | LL | unsafe {} //~ ERROR: usage of an `unsafe` block | ^^^^^^^^^ @@ -91,5 +109,5 @@ LL | unsafe {} //~ ERROR: usage of an `unsafe` block LL | unsafe_in_macro!() | ------------------ in this macro invocation -error: aborting due to 14 previous errors +error: aborting due to 17 previous errors From d04f7560275ab61ff4b5049ea64599d79a052509 Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Tue, 15 Jan 2019 18:01:38 +0900 Subject: [PATCH 08/10] Restore error message --- src/librustc_lint/builtin.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/librustc_lint/builtin.rs b/src/librustc_lint/builtin.rs index 6cd632321cc1a..50631a74fe617 100644 --- a/src/librustc_lint/builtin.rs +++ b/src/librustc_lint/builtin.rs @@ -229,8 +229,9 @@ impl UnsafeCode { impl EarlyLintPass for UnsafeCode { fn check_attribute(&mut self, cx: &EarlyContext, attr: &ast::Attribute) { if attr.check_name("allow_internal_unsafe") { - self.report_unsafe(cx, attr.span, "cannot use `allow_internal_unsafe` \ - with `forbid(unsafe_code)`"); + self.report_unsafe(cx, attr.span, "`allow_internal_unsafe` allows defining \ + macros using unsafe without triggering \ + the `unsafe_code` lint at their call site"); } } From b39e9e2d07a79998f7e6a87f1c0855f5a939b92e Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Tue, 15 Jan 2019 18:02:22 +0900 Subject: [PATCH 09/10] Change from _ to None --- src/librustc_lint/builtin.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustc_lint/builtin.rs b/src/librustc_lint/builtin.rs index 50631a74fe617..52eab9b12f399 100644 --- a/src/librustc_lint/builtin.rs +++ b/src/librustc_lint/builtin.rs @@ -280,7 +280,7 @@ impl EarlyLintPass for UnsafeCode { } fn check_trait_item(&mut self, cx: &EarlyContext, item: &ast::TraitItem) { - if let ast::TraitItemKind::Method(ref sig, _) = item.node { + if let ast::TraitItemKind::Method(ref sig, None) = item.node { if sig.header.unsafety == ast::Unsafety::Unsafe { self.report_unsafe(cx, item.span, "declaration of an `unsafe` method") } From bd1551e46e4a788dc974f4aac8ba821133625663 Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Tue, 15 Jan 2019 18:02:46 +0900 Subject: [PATCH 10/10] Fix tests --- .../ui/lint/lint-forbid-internal-unsafe.rs | 2 +- .../lint/lint-forbid-internal-unsafe.stderr | 2 +- src/test/ui/lint/lint-unsafe-code.rs | 3 -- src/test/ui/lint/lint-unsafe-code.stderr | 36 +++++-------------- 4 files changed, 11 insertions(+), 32 deletions(-) diff --git a/src/test/ui/lint/lint-forbid-internal-unsafe.rs b/src/test/ui/lint/lint-forbid-internal-unsafe.rs index 7f58b7280f359..b08fbf6f845f8 100644 --- a/src/test/ui/lint/lint-forbid-internal-unsafe.rs +++ b/src/test/ui/lint/lint-forbid-internal-unsafe.rs @@ -2,7 +2,7 @@ #![feature(allow_internal_unsafe)] #[allow_internal_unsafe] -//~^ ERROR: cannot use `allow_internal_unsafe` with `forbid(unsafe_code)` +//~^ ERROR: `allow_internal_unsafe` allows defining macro_rules! evil { ($e:expr) => { unsafe { diff --git a/src/test/ui/lint/lint-forbid-internal-unsafe.stderr b/src/test/ui/lint/lint-forbid-internal-unsafe.stderr index b65ba6118b951..59dab119682c1 100644 --- a/src/test/ui/lint/lint-forbid-internal-unsafe.stderr +++ b/src/test/ui/lint/lint-forbid-internal-unsafe.stderr @@ -1,4 +1,4 @@ -error: cannot use `allow_internal_unsafe` with `forbid(unsafe_code)` +error: `allow_internal_unsafe` allows defining macros using unsafe without triggering the `unsafe_code` lint at their call site --> $DIR/lint-forbid-internal-unsafe.rs:4:1 | LL | #[allow_internal_unsafe] diff --git a/src/test/ui/lint/lint-unsafe-code.rs b/src/test/ui/lint/lint-unsafe-code.rs index b6d2da12db30c..735f33f601f9d 100644 --- a/src/test/ui/lint/lint-unsafe-code.rs +++ b/src/test/ui/lint/lint-unsafe-code.rs @@ -27,9 +27,7 @@ unsafe impl Foo for Bar {} //~ ERROR: implementation of an `unsafe` trait trait Baz { unsafe fn baz(&self); //~ ERROR: declaration of an `unsafe` method unsafe fn provided(&self) {} //~ ERROR: implementation of an `unsafe` method - //~^ ERROR: declaration of an `unsafe` method unsafe fn provided_override(&self) {} //~ ERROR: implementation of an `unsafe` method - //~^ ERROR: declaration of an `unsafe` method } impl Baz for Bar { @@ -65,7 +63,6 @@ trait C { #[allow(unsafe_code)] unsafe fn baz(&self); unsafe fn provided(&self) {} //~ ERROR: implementation of an `unsafe` method - //~^ ERROR: declaration of an `unsafe` method } impl C for Bar { diff --git a/src/test/ui/lint/lint-unsafe-code.stderr b/src/test/ui/lint/lint-unsafe-code.stderr index 2d08902dc698f..e2dd45e2c8a31 100644 --- a/src/test/ui/lint/lint-unsafe-code.stderr +++ b/src/test/ui/lint/lint-unsafe-code.stderr @@ -28,74 +28,56 @@ error: declaration of an `unsafe` method LL | unsafe fn baz(&self); //~ ERROR: declaration of an `unsafe` method | ^^^^^^^^^^^^^^^^^^^^^ -error: declaration of an `unsafe` method - --> $DIR/lint-unsafe-code.rs:29:5 - | -LL | unsafe fn provided(&self) {} //~ ERROR: implementation of an `unsafe` method - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - error: implementation of an `unsafe` method --> $DIR/lint-unsafe-code.rs:29:5 | LL | unsafe fn provided(&self) {} //~ ERROR: implementation of an `unsafe` method | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: declaration of an `unsafe` method - --> $DIR/lint-unsafe-code.rs:31:5 - | -LL | unsafe fn provided_override(&self) {} //~ ERROR: implementation of an `unsafe` method - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - error: implementation of an `unsafe` method - --> $DIR/lint-unsafe-code.rs:31:5 + --> $DIR/lint-unsafe-code.rs:30:5 | LL | unsafe fn provided_override(&self) {} //~ ERROR: implementation of an `unsafe` method | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: implementation of an `unsafe` method - --> $DIR/lint-unsafe-code.rs:36:5 + --> $DIR/lint-unsafe-code.rs:34:5 | LL | unsafe fn baz(&self) {} //~ ERROR: implementation of an `unsafe` method | ^^^^^^^^^^^^^^^^^^^^^^^ error: implementation of an `unsafe` method - --> $DIR/lint-unsafe-code.rs:37:5 + --> $DIR/lint-unsafe-code.rs:35:5 | LL | unsafe fn provided_override(&self) {} //~ ERROR: implementation of an `unsafe` method | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: implementation of an `unsafe` method - --> $DIR/lint-unsafe-code.rs:56:5 + --> $DIR/lint-unsafe-code.rs:54:5 | LL | unsafe fn provided_override(&self) {} //~ ERROR: implementation of an `unsafe` method | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: declaration of an `unsafe` method - --> $DIR/lint-unsafe-code.rs:67:5 - | -LL | unsafe fn provided(&self) {} //~ ERROR: implementation of an `unsafe` method - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - error: implementation of an `unsafe` method - --> $DIR/lint-unsafe-code.rs:67:5 + --> $DIR/lint-unsafe-code.rs:65:5 | LL | unsafe fn provided(&self) {} //~ ERROR: implementation of an `unsafe` method | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: implementation of an `unsafe` method - --> $DIR/lint-unsafe-code.rs:74:5 + --> $DIR/lint-unsafe-code.rs:71:5 | LL | unsafe fn provided(&self) {} //~ ERROR: implementation of an `unsafe` method | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: implementation of an `unsafe` method - --> $DIR/lint-unsafe-code.rs:78:5 + --> $DIR/lint-unsafe-code.rs:75:5 | LL | unsafe fn baz(&self) {} //~ ERROR: implementation of an `unsafe` method | ^^^^^^^^^^^^^^^^^^^^^^^ error: usage of an `unsafe` block - --> $DIR/lint-unsafe-code.rs:89:5 + --> $DIR/lint-unsafe-code.rs:86:5 | LL | unsafe {} //~ ERROR: usage of an `unsafe` block | ^^^^^^^^^ @@ -109,5 +91,5 @@ LL | unsafe {} //~ ERROR: usage of an `unsafe` block LL | unsafe_in_macro!() | ------------------ in this macro invocation -error: aborting due to 17 previous errors +error: aborting due to 14 previous errors