// Attributes are checked where they are written (E0114), and a function // has a body unless it is `@extern` or a trait method (E0115). // Accepted. @extern c "ok_plain" fn plain :: x: Int -> Int @extern c "ok_options" blocking owned fn options :: x: Int -> Int / @test @should_panic "boom" fn panics :: { panic "boom" } @thread_safe @derive Eq @derive Show type Kind { Kind } @derivable size_of_constructor trait Size { fn size :: x: a -> Int } fn size_of_constructor :: c: Constructor -> Int { 1 } // Unknown attributes, ABIs and options. @extrn c "typo" //~ ERROR E0114 unknown attribute `@extrn` fn typo :: //~ ERROR E0115 function `typo` has no body x: Int -> Int @extern rust "rusty" //~ ERROR E0114 unknown ABI `rust` fn rusty :: x: Int -> Int @extern c "slow" blockng //~ ERROR E0114 unknown `@extern` option `blockng` fn slow :: x: Int -> Int // Blocking pools (ADR 0005, Revision 2): `cpu` and `io` only. @extern c "on_cpu" (blocking cpu) fn on_cpu :: x: Int -> Int @extern c "on_io" (blocking io) fn on_io :: x: Int -> Int @extern c "on_gpu" (blocking gpu) //~ ERROR E0114 unknown blocking pool `gpu` fn on_gpu :: x: Int -> Int @extern c "owned_io" (owned io) //~^ ERROR E0114 the `@extern` option `owned` takes no argument fn owned_io :: x: Int -> Int // Malformed arguments. @extern c //~ ERROR E0114 `@extern` needs a symbol fn no_symbol :: x: Int -> Int @extern //~ ERROR E0114 `@extern` needs an ABI and a symbol fn nothing :: x: Int -> Int @extern c bare //~ ERROR E0114 the symbol of `@extern` is a non-empty string fn bare_symbol :: x: Int -> Int @test 1 //~ ERROR E0114 `@test` takes no arguments fn test_with_argument :: {} @test @should_panic fragment //~ ERROR E0114 `@should_panic` takes at most one string fn bare_fragment :: {} @derive //~ ERROR E0114 `@derive` needs the traits to derive type Underived { Underived } @derivable f g //~^ ERROR E0114 `@derivable` takes the name of one derive function trait Twice //~ ERROR E0412 no function `f` is in scope { fn twice :: x: a -> Int } // Repeated, or on the wrong item. @test @test //~ ERROR E0114 `@test` is given twice fn twice_a_test :: {} @should_panic //~ ERROR E0114 `@should_panic` applies only to a `@test` function fn not_a_test :: {} @derive Eq //~ ERROR E0114 `@derive` does not apply to a function fn derived :: {} @extern c "on_a_type" //~ ERROR E0114 `@extern` does not apply to a type type Foreign @builtin //~^ ERROR E0114 `@builtin` applies only to a type without constructors in the standard library type Mine @intrinsic //~^ ERROR E0114 `@intrinsic` applies only to a function in the standard library fn compiled :: -> Int { 1 } trait Methods { @test //~ ERROR E0114 `@test` does not apply to a method fn method :: x: a -> Int } // Bodies. fn forgotten :: x: Int -> Int //~ ERROR E0115 function `forgotten` has no body impl Size { fn size :: x: Kind -> Int //~ ERROR E0115 method `size` has no body } @extern c "both" fn both :: x: Int -> Int { //~ ERROR E0115 `@extern` function `both` has a body x }