summaryrefslogtreecommitdiffstats
path: root/src/test/ui/missing
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:02:58 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:02:58 +0000
commit698f8c2f01ea549d77d7dc3338a12e04c11057b9 (patch)
tree173a775858bd501c378080a10dca74132f05bc50 /src/test/ui/missing
parentInitial commit. (diff)
downloadrustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.tar.xz
rustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.zip
Adding upstream version 1.64.0+dfsg1.upstream/1.64.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/test/ui/missing')
-rw-r--r--src/test/ui/missing/auxiliary/two_macros.rs5
-rw-r--r--src/test/ui/missing/missing-alloc_error_handler.rs23
-rw-r--r--src/test/ui/missing/missing-alloc_error_handler.stderr6
-rw-r--r--src/test/ui/missing/missing-allocator.rs18
-rw-r--r--src/test/ui/missing/missing-allocator.stderr4
-rw-r--r--src/test/ui/missing/missing-block-hint.rs9
-rw-r--r--src/test/ui/missing/missing-block-hint.stderr30
-rw-r--r--src/test/ui/missing/missing-comma-in-match.fixed11
-rw-r--r--src/test/ui/missing/missing-comma-in-match.rs11
-rw-r--r--src/test/ui/missing/missing-comma-in-match.stderr10
-rw-r--r--src/test/ui/missing/missing-derivable-attr.rs16
-rw-r--r--src/test/ui/missing/missing-derivable-attr.stderr12
-rw-r--r--src/test/ui/missing/missing-fields-in-struct-pattern.rs8
-rw-r--r--src/test/ui/missing/missing-fields-in-struct-pattern.stderr14
-rw-r--r--src/test/ui/missing/missing-items/auxiliary/m1.rs9
-rw-r--r--src/test/ui/missing/missing-items/m2.rs12
-rw-r--r--src/test/ui/missing/missing-items/m2.stderr17
-rw-r--r--src/test/ui/missing/missing-items/missing-type-parameter.rs5
-rw-r--r--src/test/ui/missing/missing-items/missing-type-parameter.stderr14
-rw-r--r--src/test/ui/missing/missing-items/missing-type-parameter2.rs19
-rw-r--r--src/test/ui/missing/missing-items/missing-type-parameter2.stderr121
-rw-r--r--src/test/ui/missing/missing-macro-use.rs8
-rw-r--r--src/test/ui/missing/missing-macro-use.stderr11
-rw-r--r--src/test/ui/missing/missing-main.rs2
-rw-r--r--src/test/ui/missing/missing-main.stderr9
-rw-r--r--src/test/ui/missing/missing-return.rs5
-rw-r--r--src/test/ui/missing/missing-return.stderr11
-rw-r--r--src/test/ui/missing/missing-stability.rs24
-rw-r--r--src/test/ui/missing/missing-stability.stderr17
29 files changed, 461 insertions, 0 deletions
diff --git a/src/test/ui/missing/auxiliary/two_macros.rs b/src/test/ui/missing/auxiliary/two_macros.rs
new file mode 100644
index 000000000..2330c75c8
--- /dev/null
+++ b/src/test/ui/missing/auxiliary/two_macros.rs
@@ -0,0 +1,5 @@
+#[macro_export]
+macro_rules! macro_one { () => ("one") }
+
+#[macro_export]
+macro_rules! macro_two { () => ("two") }
diff --git a/src/test/ui/missing/missing-alloc_error_handler.rs b/src/test/ui/missing/missing-alloc_error_handler.rs
new file mode 100644
index 000000000..4d378f010
--- /dev/null
+++ b/src/test/ui/missing/missing-alloc_error_handler.rs
@@ -0,0 +1,23 @@
+// compile-flags: -C panic=abort
+// no-prefer-dynamic
+
+#![no_std]
+#![crate_type = "staticlib"]
+#![feature(alloc_error_handler)]
+
+#[panic_handler]
+fn panic(_: &core::panic::PanicInfo) -> ! {
+ loop {}
+}
+
+extern crate alloc;
+
+#[global_allocator]
+static A: MyAlloc = MyAlloc;
+
+struct MyAlloc;
+
+unsafe impl core::alloc::GlobalAlloc for MyAlloc {
+ unsafe fn alloc(&self, _: core::alloc::Layout) -> *mut u8 { 0 as _ }
+ unsafe fn dealloc(&self, _: *mut u8, _: core::alloc::Layout) {}
+}
diff --git a/src/test/ui/missing/missing-alloc_error_handler.stderr b/src/test/ui/missing/missing-alloc_error_handler.stderr
new file mode 100644
index 000000000..995fa7cf8
--- /dev/null
+++ b/src/test/ui/missing/missing-alloc_error_handler.stderr
@@ -0,0 +1,6 @@
+error: `#[alloc_error_handler]` function required, but not found
+
+note: use `#![feature(default_alloc_error_handler)]` for a default error handler
+
+error: aborting due to previous error
+
diff --git a/src/test/ui/missing/missing-allocator.rs b/src/test/ui/missing/missing-allocator.rs
new file mode 100644
index 000000000..2dc509f2c
--- /dev/null
+++ b/src/test/ui/missing/missing-allocator.rs
@@ -0,0 +1,18 @@
+// compile-flags: -C panic=abort
+// no-prefer-dynamic
+
+#![no_std]
+#![crate_type = "staticlib"]
+#![feature(alloc_error_handler)]
+
+#[panic_handler]
+fn panic(_: &core::panic::PanicInfo) -> ! {
+ loop {}
+}
+
+#[alloc_error_handler]
+fn oom(_: core::alloc::Layout) -> ! {
+ loop {}
+}
+
+extern crate alloc;
diff --git a/src/test/ui/missing/missing-allocator.stderr b/src/test/ui/missing/missing-allocator.stderr
new file mode 100644
index 000000000..0da5651c1
--- /dev/null
+++ b/src/test/ui/missing/missing-allocator.stderr
@@ -0,0 +1,4 @@
+error: no global memory allocator found but one is required; link to std or add `#[global_allocator]` to a static item that implements the GlobalAlloc trait
+
+error: aborting due to previous error
+
diff --git a/src/test/ui/missing/missing-block-hint.rs b/src/test/ui/missing/missing-block-hint.rs
new file mode 100644
index 000000000..89db02a9c
--- /dev/null
+++ b/src/test/ui/missing/missing-block-hint.rs
@@ -0,0 +1,9 @@
+fn main() {
+ {
+ if (foo) => {} //~ ERROR expected `{`, found `=>`
+ }
+ {
+ if (foo)
+ bar; //~ ERROR expected `{`, found `bar`
+ }
+}
diff --git a/src/test/ui/missing/missing-block-hint.stderr b/src/test/ui/missing/missing-block-hint.stderr
new file mode 100644
index 000000000..16954223a
--- /dev/null
+++ b/src/test/ui/missing/missing-block-hint.stderr
@@ -0,0 +1,30 @@
+error: expected `{`, found `=>`
+ --> $DIR/missing-block-hint.rs:3:18
+ |
+LL | if (foo) => {}
+ | ^^ expected `{`
+ |
+note: the `if` expression is missing a block after this condition
+ --> $DIR/missing-block-hint.rs:3:12
+ |
+LL | if (foo) => {}
+ | ^^^^^
+
+error: expected `{`, found `bar`
+ --> $DIR/missing-block-hint.rs:7:13
+ |
+LL | bar;
+ | ^^^ expected `{`
+ |
+note: the `if` expression is missing a block after this condition
+ --> $DIR/missing-block-hint.rs:6:12
+ |
+LL | if (foo)
+ | ^^^^^
+help: try placing this code inside a block
+ |
+LL | { bar; }
+ | + +
+
+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
new file mode 100644
index 000000000..f091082f3
--- /dev/null
+++ b/src/test/ui/missing/missing-comma-in-match.fixed
@@ -0,0 +1,11 @@
+// run-rustfix
+
+fn main() {
+ match &Some(3) {
+ &None => 1,
+ &Some(2) => { 3 }
+ //~^ ERROR expected one of `,`, `.`, `?`, `}`, or an operator, found `=>`
+ //~| 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
new file mode 100644
index 000000000..54dab4e97
--- /dev/null
+++ b/src/test/ui/missing/missing-comma-in-match.rs
@@ -0,0 +1,11 @@
+// run-rustfix
+
+fn main() {
+ match &Some(3) {
+ &None => 1
+ &Some(2) => { 3 }
+ //~^ ERROR expected one of `,`, `.`, `?`, `}`, or an operator, found `=>`
+ //~| 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
new file mode 100644
index 000000000..fe210f697
--- /dev/null
+++ b/src/test/ui/missing/missing-comma-in-match.stderr
@@ -0,0 +1,10 @@
+error: expected one of `,`, `.`, `?`, `}`, or an operator, found `=>`
+ --> $DIR/missing-comma-in-match.rs:6:18
+ |
+LL | &None => 1
+ | - help: missing a comma here to end this `match` arm
+LL | &Some(2) => { 3 }
+ | ^^ expected one of `,`, `.`, `?`, `}`, or an operator
+
+error: aborting due to previous error
+
diff --git a/src/test/ui/missing/missing-derivable-attr.rs b/src/test/ui/missing/missing-derivable-attr.rs
new file mode 100644
index 000000000..58c94de50
--- /dev/null
+++ b/src/test/ui/missing/missing-derivable-attr.rs
@@ -0,0 +1,16 @@
+trait MyEq {
+ fn eq(&self, other: &Self) -> bool;
+}
+
+struct A {
+ x: isize
+}
+
+impl MyEq for isize {
+ fn eq(&self, other: &isize) -> bool { *self == *other }
+}
+
+impl MyEq for A {} //~ ERROR not all trait items implemented, missing: `eq`
+
+fn main() {
+}
diff --git a/src/test/ui/missing/missing-derivable-attr.stderr b/src/test/ui/missing/missing-derivable-attr.stderr
new file mode 100644
index 000000000..9b8c0c583
--- /dev/null
+++ b/src/test/ui/missing/missing-derivable-attr.stderr
@@ -0,0 +1,12 @@
+error[E0046]: not all trait items implemented, missing: `eq`
+ --> $DIR/missing-derivable-attr.rs:13:1
+ |
+LL | fn eq(&self, other: &Self) -> bool;
+ | ----------------------------------- `eq` from trait
+...
+LL | impl MyEq for A {}
+ | ^^^^^^^^^^^^^^^ missing `eq` in implementation
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0046`.
diff --git a/src/test/ui/missing/missing-fields-in-struct-pattern.rs b/src/test/ui/missing/missing-fields-in-struct-pattern.rs
new file mode 100644
index 000000000..40304a674
--- /dev/null
+++ b/src/test/ui/missing/missing-fields-in-struct-pattern.rs
@@ -0,0 +1,8 @@
+struct S(usize, usize, usize, usize);
+
+fn main() {
+ if let S { a, b, c, d } = S(1, 2, 3, 4) {
+ //~^ ERROR tuple variant `S` written as struct variant
+ println!("hi");
+ }
+}
diff --git a/src/test/ui/missing/missing-fields-in-struct-pattern.stderr b/src/test/ui/missing/missing-fields-in-struct-pattern.stderr
new file mode 100644
index 000000000..1fe9f5299
--- /dev/null
+++ b/src/test/ui/missing/missing-fields-in-struct-pattern.stderr
@@ -0,0 +1,14 @@
+error[E0769]: tuple variant `S` written as struct variant
+ --> $DIR/missing-fields-in-struct-pattern.rs:4:12
+ |
+LL | if let S { a, b, c, d } = S(1, 2, 3, 4) {
+ | ^^^^^^^^^^^^^^^^
+ |
+help: use the tuple variant pattern syntax instead
+ |
+LL | if let S(a, b, c, d) = S(1, 2, 3, 4) {
+ | ~~~~~~~~~~~~
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0769`.
diff --git a/src/test/ui/missing/missing-items/auxiliary/m1.rs b/src/test/ui/missing/missing-items/auxiliary/m1.rs
new file mode 100644
index 000000000..fcf52c9e8
--- /dev/null
+++ b/src/test/ui/missing/missing-items/auxiliary/m1.rs
@@ -0,0 +1,9 @@
+pub trait X {
+ const CONSTANT: u32;
+ type Type;
+ fn method(&self, s: String) -> Self::Type;
+ fn method2(self: Box<Self>, s: String) -> Self::Type;
+ fn method3(other: &Self, s: String) -> Self::Type;
+ fn method4(&self, other: &Self) -> Self::Type;
+ fn method5(self: &Box<Self>) -> Self::Type;
+}
diff --git a/src/test/ui/missing/missing-items/m2.rs b/src/test/ui/missing/missing-items/m2.rs
new file mode 100644
index 000000000..c2a6914ab
--- /dev/null
+++ b/src/test/ui/missing/missing-items/m2.rs
@@ -0,0 +1,12 @@
+// aux-build:m1.rs
+
+
+extern crate m1;
+
+struct X {
+}
+
+impl m1::X for X { //~ ERROR not all trait items implemented
+}
+
+fn main() {}
diff --git a/src/test/ui/missing/missing-items/m2.stderr b/src/test/ui/missing/missing-items/m2.stderr
new file mode 100644
index 000000000..d18fb443a
--- /dev/null
+++ b/src/test/ui/missing/missing-items/m2.stderr
@@ -0,0 +1,17 @@
+error[E0046]: not all trait items implemented, missing: `CONSTANT`, `Type`, `method`, `method2`, `method3`, `method4`, `method5`
+ --> $DIR/m2.rs:9:1
+ |
+LL | impl m1::X for X {
+ | ^^^^^^^^^^^^^^^^ missing `CONSTANT`, `Type`, `method`, `method2`, `method3`, `method4`, `method5` in implementation
+ |
+ = help: implement the missing item: `const CONSTANT: u32 = 42;`
+ = help: implement the missing item: `type Type = Type;`
+ = help: implement the missing item: `fn method(&self, _: String) -> <Self as m1::X>::Type { todo!() }`
+ = help: implement the missing item: `fn method2(self: Box<Self>, _: String) -> <Self as m1::X>::Type { todo!() }`
+ = help: implement the missing item: `fn method3(_: &Self, _: String) -> <Self as m1::X>::Type { todo!() }`
+ = help: implement the missing item: `fn method4(&self, _: &Self) -> <Self as m1::X>::Type { todo!() }`
+ = help: implement the missing item: `fn method5(self: &Box<Self>) -> <Self as m1::X>::Type { todo!() }`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0046`.
diff --git a/src/test/ui/missing/missing-items/missing-type-parameter.rs b/src/test/ui/missing/missing-items/missing-type-parameter.rs
new file mode 100644
index 000000000..8a64053a4
--- /dev/null
+++ b/src/test/ui/missing/missing-items/missing-type-parameter.rs
@@ -0,0 +1,5 @@
+fn foo<X>() { }
+
+fn main() {
+ foo(); //~ ERROR type annotations needed
+}
diff --git a/src/test/ui/missing/missing-items/missing-type-parameter.stderr b/src/test/ui/missing/missing-items/missing-type-parameter.stderr
new file mode 100644
index 000000000..722539fca
--- /dev/null
+++ b/src/test/ui/missing/missing-items/missing-type-parameter.stderr
@@ -0,0 +1,14 @@
+error[E0282]: type annotations needed
+ --> $DIR/missing-type-parameter.rs:4:5
+ |
+LL | foo();
+ | ^^^ cannot infer type of the type parameter `X` declared on the function `foo`
+ |
+help: consider specifying the generic argument
+ |
+LL | foo::<X>();
+ | +++++
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0282`.
diff --git a/src/test/ui/missing/missing-items/missing-type-parameter2.rs b/src/test/ui/missing/missing-items/missing-type-parameter2.rs
new file mode 100644
index 000000000..e9b32fb71
--- /dev/null
+++ b/src/test/ui/missing/missing-items/missing-type-parameter2.rs
@@ -0,0 +1,19 @@
+struct X<const N: u8>();
+
+impl X<N> {}
+//~^ ERROR cannot find type `N` in this scope
+//~| ERROR unresolved item provided when a constant was expected
+impl<T, const A: u8 = 2> X<N> {}
+//~^ ERROR cannot find type `N` in this scope
+//~| ERROR defaults for const parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions
+//~| ERROR unresolved item provided when a constant was expected
+
+fn foo(_: T) where T: Send {}
+//~^ ERROR cannot find type `T` in this scope
+//~| ERROR cannot find type `T` in this scope
+
+fn bar<const N: u8>(_: A) {}
+//~^ ERROR cannot find type `A` in this scope
+
+fn main() {
+}
diff --git a/src/test/ui/missing/missing-items/missing-type-parameter2.stderr b/src/test/ui/missing/missing-items/missing-type-parameter2.stderr
new file mode 100644
index 000000000..f33951c98
--- /dev/null
+++ b/src/test/ui/missing/missing-items/missing-type-parameter2.stderr
@@ -0,0 +1,121 @@
+error[E0412]: cannot find type `N` in this scope
+ --> $DIR/missing-type-parameter2.rs:3:8
+ |
+LL | struct X<const N: u8>();
+ | ------------------------ similarly named struct `X` defined here
+LL |
+LL | impl X<N> {}
+ | ^
+ |
+help: a struct with a similar name exists
+ |
+LL | impl X<X> {}
+ | ~
+help: you might be missing a type parameter
+ |
+LL | impl<N> X<N> {}
+ | +++
+
+error[E0412]: cannot find type `N` in this scope
+ --> $DIR/missing-type-parameter2.rs:6:28
+ |
+LL | impl<T, const A: u8 = 2> X<N> {}
+ | - ^
+ | |
+ | similarly named type parameter `T` defined here
+ |
+help: a type parameter with a similar name exists
+ |
+LL | impl<T, const A: u8 = 2> X<T> {}
+ | ~
+help: you might be missing a type parameter
+ |
+LL | impl<T, const A: u8 = 2, N> X<N> {}
+ | +++
+
+error[E0412]: cannot find type `T` in this scope
+ --> $DIR/missing-type-parameter2.rs:11:20
+ |
+LL | struct X<const N: u8>();
+ | ------------------------ similarly named struct `X` defined here
+...
+LL | fn foo(_: T) where T: Send {}
+ | ^
+ |
+help: a struct with a similar name exists
+ |
+LL | fn foo(_: T) where X: Send {}
+ | ~
+help: you might be missing a type parameter
+ |
+LL | fn foo<T>(_: T) where T: Send {}
+ | +++
+
+error[E0412]: cannot find type `T` in this scope
+ --> $DIR/missing-type-parameter2.rs:11:11
+ |
+LL | struct X<const N: u8>();
+ | ------------------------ similarly named struct `X` defined here
+...
+LL | fn foo(_: T) where T: Send {}
+ | ^
+ |
+help: a struct with a similar name exists
+ |
+LL | fn foo(_: X) where T: Send {}
+ | ~
+help: you might be missing a type parameter
+ |
+LL | fn foo<T>(_: T) where T: Send {}
+ | +++
+
+error[E0412]: cannot find type `A` in this scope
+ --> $DIR/missing-type-parameter2.rs:15:24
+ |
+LL | struct X<const N: u8>();
+ | ------------------------ similarly named struct `X` defined here
+...
+LL | fn bar<const N: u8>(_: A) {}
+ | ^
+ |
+help: a struct with a similar name exists
+ |
+LL | fn bar<const N: u8>(_: X) {}
+ | ~
+help: you might be missing a type parameter
+ |
+LL | fn bar<const N: u8, A>(_: A) {}
+ | +++
+
+error[E0747]: unresolved item provided when a constant was expected
+ --> $DIR/missing-type-parameter2.rs:3:8
+ |
+LL | impl X<N> {}
+ | ^
+ |
+help: if this generic argument was intended as a const parameter, surround it with braces
+ |
+LL | impl X<{ N }> {}
+ | + +
+
+error: defaults for const parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions
+ --> $DIR/missing-type-parameter2.rs:6:9
+ |
+LL | impl<T, const A: u8 = 2> X<N> {}
+ | ^^^^^^^^^^^^^^^
+
+error[E0747]: unresolved item provided when a constant was expected
+ --> $DIR/missing-type-parameter2.rs:6:28
+ |
+LL | impl<T, const A: u8 = 2> X<N> {}
+ | ^
+ |
+help: if this generic argument was intended as a const parameter, surround it with braces
+ |
+LL | impl<T, const A: u8 = 2> X<{ N }> {}
+ | + +
+
+error: aborting due to 8 previous errors
+
+Some errors have detailed explanations: E0412, E0747.
+For more information about an error, try `rustc --explain E0412`.
diff --git a/src/test/ui/missing/missing-macro-use.rs b/src/test/ui/missing/missing-macro-use.rs
new file mode 100644
index 000000000..d494c4471
--- /dev/null
+++ b/src/test/ui/missing/missing-macro-use.rs
@@ -0,0 +1,8 @@
+// aux-build:two_macros.rs
+
+extern crate two_macros;
+
+pub fn main() {
+ macro_two!();
+ //~^ ERROR cannot find macro `macro_two` in this scope
+}
diff --git a/src/test/ui/missing/missing-macro-use.stderr b/src/test/ui/missing/missing-macro-use.stderr
new file mode 100644
index 000000000..ced062269
--- /dev/null
+++ b/src/test/ui/missing/missing-macro-use.stderr
@@ -0,0 +1,11 @@
+error: cannot find macro `macro_two` in this scope
+ --> $DIR/missing-macro-use.rs:6:5
+ |
+LL | macro_two!();
+ | ^^^^^^^^^
+ |
+ = note: consider importing this macro:
+ two_macros::macro_two
+
+error: aborting due to previous error
+
diff --git a/src/test/ui/missing/missing-main.rs b/src/test/ui/missing/missing-main.rs
new file mode 100644
index 000000000..6ad544533
--- /dev/null
+++ b/src/test/ui/missing/missing-main.rs
@@ -0,0 +1,2 @@
+// error-pattern: `main` function not found
+fn mian() { }
diff --git a/src/test/ui/missing/missing-main.stderr b/src/test/ui/missing/missing-main.stderr
new file mode 100644
index 000000000..5113dc6ec
--- /dev/null
+++ b/src/test/ui/missing/missing-main.stderr
@@ -0,0 +1,9 @@
+error[E0601]: `main` function not found in crate `missing_main`
+ --> $DIR/missing-main.rs:2:14
+ |
+LL | fn mian() { }
+ | ^ consider adding a `main` function to `$DIR/missing-main.rs`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0601`.
diff --git a/src/test/ui/missing/missing-return.rs b/src/test/ui/missing/missing-return.rs
new file mode 100644
index 000000000..6a171753d
--- /dev/null
+++ b/src/test/ui/missing/missing-return.rs
@@ -0,0 +1,5 @@
+// error-pattern: return
+
+fn f() -> isize { }
+
+fn main() { f(); }
diff --git a/src/test/ui/missing/missing-return.stderr b/src/test/ui/missing/missing-return.stderr
new file mode 100644
index 000000000..ff7f261e0
--- /dev/null
+++ b/src/test/ui/missing/missing-return.stderr
@@ -0,0 +1,11 @@
+error[E0308]: mismatched types
+ --> $DIR/missing-return.rs:3:11
+ |
+LL | fn f() -> isize { }
+ | - ^^^^^ expected `isize`, found `()`
+ | |
+ | implicitly returns `()` as its body has no tail or `return` expression
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0308`.
diff --git a/src/test/ui/missing/missing-stability.rs b/src/test/ui/missing/missing-stability.rs
new file mode 100644
index 000000000..0da5808b4
--- /dev/null
+++ b/src/test/ui/missing/missing-stability.rs
@@ -0,0 +1,24 @@
+// Checks that exported items without stability attributes cause an error
+
+#![crate_type="lib"]
+#![feature(staged_api)]
+
+#![stable(feature = "stable_test_feature", since = "1.0.0")]
+
+pub fn unmarked() {
+ //~^ ERROR function has missing stability attribute
+ ()
+}
+
+#[unstable(feature = "unstable_test_feature", issue = "none")]
+pub mod foo {
+ // #[unstable] is inherited
+ pub fn unmarked() {}
+}
+
+#[stable(feature = "stable_test_feature", since="1.0.0")]
+pub mod bar {
+ // #[stable] is not inherited
+ pub fn unmarked() {}
+ //~^ ERROR function has missing stability attribute
+}
diff --git a/src/test/ui/missing/missing-stability.stderr b/src/test/ui/missing/missing-stability.stderr
new file mode 100644
index 000000000..659f8c78c
--- /dev/null
+++ b/src/test/ui/missing/missing-stability.stderr
@@ -0,0 +1,17 @@
+error: function has missing stability attribute
+ --> $DIR/missing-stability.rs:8:1
+ |
+LL | / pub fn unmarked() {
+LL | |
+LL | | ()
+LL | | }
+ | |_^
+
+error: function has missing stability attribute
+ --> $DIR/missing-stability.rs:22:5
+ |
+LL | pub fn unmarked() {}
+ | ^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to 2 previous errors
+