PageRenderTime 61ms CodeModel.GetById 25ms RepoModel.GetById 0ms app.codeStats 0ms

/src/test/compile-fail/lint-stability-fields.rs

http://github.com/eholk/rust
Rust | 286 lines | 207 code | 57 blank | 22 comment | 0 complexity | 7be3441dcd126335191c364bbf0606b1 MD5 | raw file
Possible License(s): AGPL-1.0, BSD-2-Clause, 0BSD, Apache-2.0, MIT, LGPL-2.0
  1. // Copyright 2015 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. // aux-build:lint_stability_fields.rs
  11. #![allow(deprecated)]
  12. #![allow(dead_code)]
  13. #![feature(staged_api)]
  14. #![stable(feature = "rust1", since = "1.0.0")]
  15. mod cross_crate {
  16. extern crate lint_stability_fields;
  17. use self::lint_stability_fields::*;
  18. pub fn foo() {
  19. let x = Stable {
  20. inherit: 1,
  21. override1: 2, //~ ERROR use of unstable
  22. override2: 3, //~ ERROR use of unstable
  23. };
  24. let _ = x.inherit;
  25. let _ = x.override1; //~ ERROR use of unstable
  26. let _ = x.override2; //~ ERROR use of unstable
  27. let Stable {
  28. inherit: _,
  29. override1: _, //~ ERROR use of unstable
  30. override2: _ //~ ERROR use of unstable
  31. } = x;
  32. // all fine
  33. let Stable { .. } = x;
  34. let x = Stable2(1, 2, 3);
  35. let _ = x.0;
  36. let _ = x.1; //~ ERROR use of unstable
  37. let _ = x.2; //~ ERROR use of unstable
  38. let Stable2(_,
  39. _, //~ ERROR use of unstable
  40. _) //~ ERROR use of unstable
  41. = x;
  42. // all fine
  43. let Stable2(..) = x;
  44. let x = Unstable { //~ ERROR use of unstable
  45. inherit: 1, //~ ERROR use of unstable
  46. override1: 2,
  47. override2: 3, //~ ERROR use of unstable
  48. };
  49. let _ = x.inherit; //~ ERROR use of unstable
  50. let _ = x.override1;
  51. let _ = x.override2; //~ ERROR use of unstable
  52. let Unstable { //~ ERROR use of unstable
  53. inherit: _, //~ ERROR use of unstable
  54. override1: _,
  55. override2: _ //~ ERROR use of unstable
  56. } = x;
  57. let Unstable //~ ERROR use of unstable
  58. // the patterns are all fine:
  59. { .. } = x;
  60. let x = Unstable2(1, 2, 3); //~ ERROR use of unstable
  61. let _ = x.0; //~ ERROR use of unstable
  62. let _ = x.1;
  63. let _ = x.2; //~ ERROR use of unstable
  64. let Unstable2 //~ ERROR use of unstable
  65. (_, //~ ERROR use of unstable
  66. _,
  67. _) //~ ERROR use of unstable
  68. = x;
  69. let Unstable2 //~ ERROR use of unstable
  70. // the patterns are all fine:
  71. (..) = x;
  72. let x = Deprecated { //~ ERROR use of unstable
  73. inherit: 1, //~ ERROR use of unstable
  74. override1: 2,
  75. override2: 3, //~ ERROR use of unstable
  76. };
  77. let _ = x.inherit; //~ ERROR use of unstable
  78. let _ = x.override1;
  79. let _ = x.override2; //~ ERROR use of unstable
  80. let Deprecated { //~ ERROR use of unstable
  81. inherit: _, //~ ERROR use of unstable
  82. override1: _,
  83. override2: _ //~ ERROR use of unstable
  84. } = x;
  85. let Deprecated //~ ERROR use of unstable
  86. // the patterns are all fine:
  87. { .. } = x;
  88. let x = Deprecated2(1, 2, 3); //~ ERROR use of unstable
  89. let _ = x.0; //~ ERROR use of unstable
  90. let _ = x.1;
  91. let _ = x.2; //~ ERROR use of unstable
  92. let Deprecated2 //~ ERROR use of unstable
  93. (_, //~ ERROR use of unstable
  94. _,
  95. _) //~ ERROR use of unstable
  96. = x;
  97. let Deprecated2 //~ ERROR use of unstable
  98. // the patterns are all fine:
  99. (..) = x;
  100. }
  101. }
  102. mod this_crate {
  103. #[stable(feature = "rust1", since = "1.0.0")]
  104. struct Stable {
  105. inherit: u8,
  106. #[unstable(feature = "test_feature", issue = "0")]
  107. override1: u8,
  108. #[rustc_deprecated(since = "1.0.0", reason = "text")]
  109. #[unstable(feature = "test_feature", issue = "0")]
  110. override2: u8,
  111. }
  112. #[stable(feature = "rust1", since = "1.0.0")]
  113. struct Stable2(u8,
  114. #[stable(feature = "rust1", since = "1.0.0")] u8,
  115. #[unstable(feature = "test_feature", issue = "0")]
  116. #[rustc_deprecated(since = "1.0.0", reason = "text")] u8);
  117. #[unstable(feature = "test_feature", issue = "0")]
  118. struct Unstable {
  119. inherit: u8,
  120. #[stable(feature = "rust1", since = "1.0.0")]
  121. override1: u8,
  122. #[rustc_deprecated(since = "1.0.0", reason = "text")]
  123. #[unstable(feature = "test_feature", issue = "0")]
  124. override2: u8,
  125. }
  126. #[unstable(feature = "test_feature", issue = "0")]
  127. struct Unstable2(u8,
  128. #[stable(feature = "rust1", since = "1.0.0")] u8,
  129. #[unstable(feature = "test_feature", issue = "0")]
  130. #[rustc_deprecated(since = "1.0.0", reason = "text")] u8);
  131. #[unstable(feature = "test_feature", issue = "0")]
  132. #[rustc_deprecated(since = "1.0.0", reason = "text")]
  133. struct Deprecated {
  134. inherit: u8,
  135. #[stable(feature = "rust1", since = "1.0.0")]
  136. override1: u8,
  137. #[unstable(feature = "test_feature", issue = "0")]
  138. override2: u8,
  139. }
  140. #[unstable(feature = "test_feature", issue = "0")]
  141. #[rustc_deprecated(since = "1.0.0", reason = "text")]
  142. struct Deprecated2(u8,
  143. #[stable(feature = "rust1", since = "1.0.0")] u8,
  144. #[unstable(feature = "test_feature", issue = "0")] u8);
  145. pub fn foo() {
  146. let x = Stable {
  147. inherit: 1,
  148. override1: 2,
  149. override2: 3,
  150. };
  151. let _ = x.inherit;
  152. let _ = x.override1;
  153. let _ = x.override2;
  154. let Stable {
  155. inherit: _,
  156. override1: _,
  157. override2: _
  158. } = x;
  159. // all fine
  160. let Stable { .. } = x;
  161. let x = Stable2(1, 2, 3);
  162. let _ = x.0;
  163. let _ = x.1;
  164. let _ = x.2;
  165. let Stable2(_,
  166. _,
  167. _)
  168. = x;
  169. // all fine
  170. let Stable2(..) = x;
  171. let x = Unstable {
  172. inherit: 1,
  173. override1: 2,
  174. override2: 3,
  175. };
  176. let _ = x.inherit;
  177. let _ = x.override1;
  178. let _ = x.override2;
  179. let Unstable {
  180. inherit: _,
  181. override1: _,
  182. override2: _
  183. } = x;
  184. let Unstable
  185. // the patterns are all fine:
  186. { .. } = x;
  187. let x = Unstable2(1, 2, 3);
  188. let _ = x.0;
  189. let _ = x.1;
  190. let _ = x.2;
  191. let Unstable2
  192. (_,
  193. _,
  194. _)
  195. = x;
  196. let Unstable2
  197. // the patterns are all fine:
  198. (..) = x;
  199. let x = Deprecated {
  200. inherit: 1,
  201. override1: 2,
  202. override2: 3,
  203. };
  204. let _ = x.inherit;
  205. let _ = x.override1;
  206. let _ = x.override2;
  207. let Deprecated {
  208. inherit: _,
  209. override1: _,
  210. override2: _
  211. } = x;
  212. let Deprecated
  213. // the patterns are all fine:
  214. { .. } = x;
  215. let x = Deprecated2(1, 2, 3);
  216. let _ = x.0;
  217. let _ = x.1;
  218. let _ = x.2;
  219. let Deprecated2
  220. (_,
  221. _,
  222. _)
  223. = x;
  224. let Deprecated2
  225. // the patterns are all fine:
  226. (..) = x;
  227. }
  228. }
  229. fn main() {}