]> git.lizzy.rs Git - rust.git/commitdiff
Add regression test for looking for trait defid in nocore
authorLzu Tao <taolzu@gmail.com>
Mon, 26 Aug 2019 10:11:47 +0000 (17:11 +0700)
committerflip1995 <hello@philkrones.com>
Mon, 26 Aug 2019 12:45:28 +0000 (14:45 +0200)
tests/ui/def_id_nocore.rs [new file with mode: 0644]
tests/ui/def_id_nocore.stderr [new file with mode: 0644]

diff --git a/tests/ui/def_id_nocore.rs b/tests/ui/def_id_nocore.rs
new file mode 100644 (file)
index 0000000..2a948d6
--- /dev/null
@@ -0,0 +1,29 @@
+// ignore-windows
+// ignore-macos
+
+#![feature(no_core, lang_items, start)]
+#![no_core]
+
+#[link(name = "c")]
+extern "C" {}
+
+#[lang = "sized"]
+pub trait Sized {}
+#[lang = "copy"]
+pub trait Copy {}
+#[lang = "freeze"]
+pub unsafe trait Freeze {}
+
+#[lang = "start"]
+#[start]
+fn start(_argc: isize, _argv: *const *const u8) -> isize {
+    0
+}
+
+pub struct A;
+
+impl A {
+    pub fn as_ref(self) -> &'static str {
+        "A"
+    }
+}
diff --git a/tests/ui/def_id_nocore.stderr b/tests/ui/def_id_nocore.stderr
new file mode 100644 (file)
index 0000000..ed87a50
--- /dev/null
@@ -0,0 +1,10 @@
+error: methods called `as_*` usually take self by reference or self by mutable reference; consider choosing a less ambiguous name
+  --> $DIR/def_id_nocore.rs:26:19
+   |
+LL |     pub fn as_ref(self) -> &'static str {
+   |                   ^^^^
+   |
+   = note: `-D clippy::wrong-self-convention` implied by `-D warnings`
+
+error: aborting due to previous error
+