]> git.proxmox.com Git - rustc.git/blame - src/test/compile-fail/defaulted-unit-warning.rs
New upstream version 1.20.0+dfsg1
[rustc.git] / src / test / compile-fail / defaulted-unit-warning.rs
CommitLineData
8bb4bdeb
XL
1// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
2// file at the top-level directory of this distribution and at
3// http://rust-lang.org/COPYRIGHT.
4//
5// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8// option. This file may not be copied, modified, or distributed
9// except according to those terms.
10
041b39d2 11#![allow(unused)]
8bb4bdeb
XL
12
13trait Deserialize: Sized {
14 fn deserialize() -> Result<Self, String>;
15}
16
17impl Deserialize for () {
18 fn deserialize() -> Result<(), String> {
19 Ok(())
20 }
21}
22
8bb4bdeb
XL
23trait ImplementedForUnitButNotNever {}
24
25impl ImplementedForUnitButNotNever for () {}
26
27fn foo<T: ImplementedForUnitButNotNever>(_t: T) {}
28
29fn smeg() {
30 let _x = return;
31 foo(_x);
32 //~^ ERROR code relies on type
33 //~| WARNING previously accepted
34}
35
36fn main() {
cc61c64b 37 smeg();
8bb4bdeb 38}