/src/test/incremental/hashes/enum_defs.rs

https://gitlab.com/rust-lang/rust · Rust · 718 lines · 510 code · 154 blank · 54 comment · 0 complexity · bb52a8c48f346ca87f8b5d0475c47675 MD5 · raw file

  1. // This test case tests the incremental compilation hash (ICH) implementation
  2. // for enum definitions.
  3. // The general pattern followed here is: Change one thing between rev1 and rev2
  4. // and make sure that the hash has changed, then change nothing between rev2 and
  5. // rev3 and make sure that the hash has not changed.
  6. // We also test the ICH for enum definitions exported in metadata. Same as
  7. // above, we want to make sure that the change between rev1 and rev2 also
  8. // results in a change of the ICH for the enum's metadata, and that it stays
  9. // the same between rev2 and rev3.
  10. // build-pass (FIXME(62277): could be check-pass?)
  11. // revisions: cfail1 cfail2 cfail3 cfail4 cfail5 cfail6
  12. // compile-flags: -Z query-dep-graph -O
  13. // [cfail1]compile-flags: -Zincremental-ignore-spans
  14. // [cfail2]compile-flags: -Zincremental-ignore-spans
  15. // [cfail3]compile-flags: -Zincremental-ignore-spans
  16. // [cfail4]compile-flags: -Zincremental-relative-spans
  17. // [cfail5]compile-flags: -Zincremental-relative-spans
  18. // [cfail6]compile-flags: -Zincremental-relative-spans
  19. #![allow(warnings)]
  20. #![feature(rustc_attrs)]
  21. #![feature(stmt_expr_attributes)]
  22. #![crate_type="rlib"]
  23. // Change enum visibility -----------------------------------------------------
  24. #[cfg(any(cfail1,cfail4))]
  25. enum EnumVisibility { A }
  26. #[cfg(not(any(cfail1,cfail4)))]
  27. #[rustc_clean(cfg="cfail2")]
  28. #[rustc_clean(cfg="cfail3")]
  29. #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes")]
  30. #[rustc_clean(cfg="cfail6")]
  31. pub enum EnumVisibility { A }
  32. // Change name of a c-style variant -------------------------------------------
  33. #[cfg(any(cfail1,cfail4))]
  34. enum EnumChangeNameCStyleVariant {
  35. Variant1,
  36. Variant2,
  37. }
  38. #[cfg(not(any(cfail1,cfail4)))]
  39. #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,type_of")]
  40. #[rustc_clean(cfg="cfail3")]
  41. #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,type_of")]
  42. #[rustc_clean(cfg="cfail6")]
  43. enum EnumChangeNameCStyleVariant {
  44. Variant1,
  45. Variant2Changed,
  46. }
  47. // Change name of a tuple-style variant ---------------------------------------
  48. #[cfg(any(cfail1,cfail4))]
  49. enum EnumChangeNameTupleStyleVariant {
  50. Variant1,
  51. Variant2(u32, f32),
  52. }
  53. #[cfg(not(any(cfail1,cfail4)))]
  54. #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,type_of")]
  55. #[rustc_clean(cfg="cfail3")]
  56. #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,type_of")]
  57. #[rustc_clean(cfg="cfail6")]
  58. enum EnumChangeNameTupleStyleVariant {
  59. Variant1,
  60. Variant2Changed(u32, f32),
  61. }
  62. // Change name of a struct-style variant --------------------------------------
  63. #[cfg(any(cfail1,cfail4))]
  64. enum EnumChangeNameStructStyleVariant {
  65. Variant1,
  66. Variant2 { a: u32, b: f32 },
  67. }
  68. #[cfg(not(any(cfail1,cfail4)))]
  69. #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,type_of")]
  70. #[rustc_clean(cfg="cfail3")]
  71. #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,type_of")]
  72. #[rustc_clean(cfg="cfail6")]
  73. enum EnumChangeNameStructStyleVariant {
  74. Variant1,
  75. Variant2Changed { a: u32, b: f32 },
  76. }
  77. // Change the value of a c-style variant --------------------------------------
  78. #[cfg(any(cfail1,cfail4))]
  79. enum EnumChangeValueCStyleVariant0 {
  80. Variant1,
  81. Variant2 = 11,
  82. }
  83. #[cfg(not(any(cfail1,cfail4)))]
  84. #[rustc_clean(cfg="cfail2", except="hir_owner_nodes")]
  85. #[rustc_clean(cfg="cfail3")]
  86. #[rustc_clean(cfg="cfail5", except="hir_owner_nodes")]
  87. #[rustc_clean(cfg="cfail6")]
  88. enum EnumChangeValueCStyleVariant0 {
  89. Variant1,
  90. Variant2 = 22,
  91. }
  92. #[cfg(any(cfail1,cfail4))]
  93. enum EnumChangeValueCStyleVariant1 {
  94. Variant1,
  95. Variant2,
  96. }
  97. #[cfg(not(any(cfail1,cfail4)))]
  98. #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,type_of")]
  99. #[rustc_clean(cfg="cfail3")]
  100. #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,type_of")]
  101. #[rustc_clean(cfg="cfail6")]
  102. enum EnumChangeValueCStyleVariant1 {
  103. Variant1,
  104. Variant2 = 11,
  105. }
  106. // Add a c-style variant ------------------------------------------------------
  107. #[cfg(any(cfail1,cfail4))]
  108. enum EnumAddCStyleVariant {
  109. Variant1,
  110. }
  111. #[cfg(not(any(cfail1,cfail4)))]
  112. #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,type_of")]
  113. #[rustc_clean(cfg="cfail3")]
  114. #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,type_of")]
  115. #[rustc_clean(cfg="cfail6")]
  116. enum EnumAddCStyleVariant {
  117. Variant1,
  118. Variant2,
  119. }
  120. // Remove a c-style variant ---------------------------------------------------
  121. #[cfg(any(cfail1,cfail4))]
  122. enum EnumRemoveCStyleVariant {
  123. Variant1,
  124. Variant2,
  125. }
  126. #[cfg(not(any(cfail1,cfail4)))]
  127. #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,type_of")]
  128. #[rustc_clean(cfg="cfail3")]
  129. #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,type_of")]
  130. #[rustc_clean(cfg="cfail6")]
  131. enum EnumRemoveCStyleVariant {
  132. Variant1,
  133. }
  134. // Add a tuple-style variant --------------------------------------------------
  135. #[cfg(any(cfail1,cfail4))]
  136. enum EnumAddTupleStyleVariant {
  137. Variant1,
  138. }
  139. #[cfg(not(any(cfail1,cfail4)))]
  140. #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,type_of")]
  141. #[rustc_clean(cfg="cfail3")]
  142. #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,type_of")]
  143. #[rustc_clean(cfg="cfail6")]
  144. enum EnumAddTupleStyleVariant {
  145. Variant1,
  146. Variant2(u32, f32),
  147. }
  148. // Remove a tuple-style variant -----------------------------------------------
  149. #[cfg(any(cfail1,cfail4))]
  150. enum EnumRemoveTupleStyleVariant {
  151. Variant1,
  152. Variant2(u32, f32),
  153. }
  154. #[cfg(not(any(cfail1,cfail4)))]
  155. #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,type_of")]
  156. #[rustc_clean(cfg="cfail3")]
  157. #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,type_of")]
  158. #[rustc_clean(cfg="cfail6")]
  159. enum EnumRemoveTupleStyleVariant {
  160. Variant1,
  161. }
  162. // Add a struct-style variant -------------------------------------------------
  163. #[cfg(any(cfail1,cfail4))]
  164. enum EnumAddStructStyleVariant {
  165. Variant1,
  166. }
  167. #[cfg(not(any(cfail1,cfail4)))]
  168. #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,type_of")]
  169. #[rustc_clean(cfg="cfail3")]
  170. #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,type_of")]
  171. #[rustc_clean(cfg="cfail6")]
  172. enum EnumAddStructStyleVariant {
  173. Variant1,
  174. Variant2 { a: u32, b: f32 },
  175. }
  176. // Remove a struct-style variant ----------------------------------------------
  177. #[cfg(any(cfail1,cfail4))]
  178. enum EnumRemoveStructStyleVariant {
  179. Variant1,
  180. Variant2 { a: u32, b: f32 },
  181. }
  182. #[cfg(not(any(cfail1,cfail4)))]
  183. #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,type_of")]
  184. #[rustc_clean(cfg="cfail3")]
  185. #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,type_of")]
  186. #[rustc_clean(cfg="cfail6")]
  187. enum EnumRemoveStructStyleVariant {
  188. Variant1,
  189. }
  190. // Change the type of a field in a tuple-style variant ------------------------
  191. #[cfg(any(cfail1,cfail4))]
  192. enum EnumChangeFieldTypeTupleStyleVariant {
  193. Variant1(u32, u32),
  194. }
  195. #[cfg(not(any(cfail1,cfail4)))]
  196. #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes")]
  197. #[rustc_clean(cfg="cfail3")]
  198. #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes")]
  199. #[rustc_clean(cfg="cfail6")]
  200. enum EnumChangeFieldTypeTupleStyleVariant {
  201. Variant1(u32,
  202. u64),
  203. }
  204. // Change the type of a field in a struct-style variant -----------------------
  205. #[cfg(any(cfail1,cfail4))]
  206. enum EnumChangeFieldTypeStructStyleVariant {
  207. Variant1,
  208. Variant2 { a: u32, b: u32 },
  209. }
  210. #[cfg(not(any(cfail1,cfail4)))]
  211. #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes")]
  212. #[rustc_clean(cfg="cfail3")]
  213. #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes")]
  214. #[rustc_clean(cfg="cfail6")]
  215. enum EnumChangeFieldTypeStructStyleVariant {
  216. Variant1,
  217. Variant2 {
  218. a: u32,
  219. b: u64
  220. },
  221. }
  222. // Change the name of a field in a struct-style variant -----------------------
  223. #[cfg(any(cfail1,cfail4))]
  224. enum EnumChangeFieldNameStructStyleVariant {
  225. Variant1 { a: u32, b: u32 },
  226. }
  227. #[cfg(not(any(cfail1,cfail4)))]
  228. #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,type_of")]
  229. #[rustc_clean(cfg="cfail3")]
  230. #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,type_of")]
  231. #[rustc_clean(cfg="cfail6")]
  232. enum EnumChangeFieldNameStructStyleVariant {
  233. Variant1 { a: u32, c: u32 },
  234. }
  235. // Change order of fields in a tuple-style variant ----------------------------
  236. #[cfg(any(cfail1,cfail4))]
  237. enum EnumChangeOrderTupleStyleVariant {
  238. Variant1(u32, u64),
  239. }
  240. #[cfg(not(any(cfail1,cfail4)))]
  241. #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes")]
  242. #[rustc_clean(cfg="cfail3")]
  243. #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes")]
  244. #[rustc_clean(cfg="cfail6")]
  245. enum EnumChangeOrderTupleStyleVariant {
  246. Variant1(
  247. u64,
  248. u32),
  249. }
  250. // Change order of fields in a struct-style variant ---------------------------
  251. #[cfg(any(cfail1,cfail4))]
  252. enum EnumChangeFieldOrderStructStyleVariant {
  253. Variant1 { a: u32, b: f32 },
  254. }
  255. #[cfg(not(any(cfail1,cfail4)))]
  256. #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,type_of")]
  257. #[rustc_clean(cfg="cfail3")]
  258. #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,type_of")]
  259. #[rustc_clean(cfg="cfail6")]
  260. enum EnumChangeFieldOrderStructStyleVariant {
  261. Variant1 { b: f32, a: u32 },
  262. }
  263. // Add a field to a tuple-style variant ---------------------------------------
  264. #[cfg(any(cfail1,cfail4))]
  265. enum EnumAddFieldTupleStyleVariant {
  266. Variant1(u32, u32),
  267. }
  268. #[cfg(not(any(cfail1,cfail4)))]
  269. #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,type_of")]
  270. #[rustc_clean(cfg="cfail3")]
  271. #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,type_of")]
  272. #[rustc_clean(cfg="cfail6")]
  273. enum EnumAddFieldTupleStyleVariant {
  274. Variant1(u32, u32, u32),
  275. }
  276. // Add a field to a struct-style variant --------------------------------------
  277. #[cfg(any(cfail1,cfail4))]
  278. enum EnumAddFieldStructStyleVariant {
  279. Variant1 { a: u32, b: u32 },
  280. }
  281. #[cfg(not(any(cfail1,cfail4)))]
  282. #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,type_of")]
  283. #[rustc_clean(cfg="cfail3")]
  284. #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,type_of")]
  285. #[rustc_clean(cfg="cfail6")]
  286. enum EnumAddFieldStructStyleVariant {
  287. Variant1 { a: u32, b: u32, c: u32 },
  288. }
  289. // Add #[must_use] to the enum ------------------------------------------------
  290. #[cfg(any(cfail1,cfail4))]
  291. enum EnumAddMustUse {
  292. Variant1,
  293. Variant2,
  294. }
  295. #[cfg(not(any(cfail1,cfail4)))]
  296. #[rustc_clean(cfg="cfail2")]
  297. #[rustc_clean(cfg="cfail3")]
  298. #[rustc_clean(cfg="cfail5")]
  299. #[rustc_clean(cfg="cfail6")]
  300. #[must_use]
  301. enum EnumAddMustUse {
  302. Variant1,
  303. Variant2,
  304. }
  305. // Add #[repr(C)] to the enum -------------------------------------------------
  306. #[cfg(any(cfail1,cfail4))]
  307. enum EnumAddReprC {
  308. Variant1,
  309. Variant2,
  310. }
  311. #[cfg(not(any(cfail1,cfail4)))]
  312. #[rustc_clean(cfg="cfail2", except="type_of")]
  313. #[rustc_clean(cfg="cfail3")]
  314. #[rustc_clean(cfg="cfail5", except="type_of")]
  315. #[rustc_clean(cfg="cfail6")]
  316. #[repr(C)]
  317. enum EnumAddReprC {
  318. Variant1,
  319. Variant2,
  320. }
  321. // Change the name of a type parameter ----------------------------------------
  322. #[cfg(any(cfail1,cfail4))]
  323. enum EnumChangeNameOfTypeParameter<S> {
  324. Variant1(S),
  325. }
  326. #[cfg(not(any(cfail1,cfail4)))]
  327. #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,generics_of,predicates_of,type_of")]
  328. #[rustc_clean(cfg="cfail3")]
  329. #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,generics_of,predicates_of,type_of")]
  330. #[rustc_clean(cfg="cfail6")]
  331. enum EnumChangeNameOfTypeParameter<T> {
  332. Variant1(T),
  333. }
  334. // Add a type parameter ------------------------------------------------------
  335. #[cfg(any(cfail1,cfail4))]
  336. enum EnumAddTypeParameter<S> {
  337. Variant1(S),
  338. Variant2(S),
  339. }
  340. #[cfg(not(any(cfail1,cfail4)))]
  341. #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,generics_of,predicates_of,type_of")]
  342. #[rustc_clean(cfg="cfail3")]
  343. #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,generics_of,predicates_of,type_of")]
  344. #[rustc_clean(cfg="cfail6")]
  345. enum EnumAddTypeParameter<S, T> {
  346. Variant1(S),
  347. Variant2(T),
  348. }
  349. // Change the name of a lifetime parameter ------------------------------------
  350. #[cfg(any(cfail1,cfail4))]
  351. enum EnumChangeNameOfLifetimeParameter<'a> {
  352. Variant1(&'a u32),
  353. }
  354. #[cfg(not(any(cfail1,cfail4)))]
  355. #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,generics_of,type_of")]
  356. #[rustc_clean(cfg="cfail3")]
  357. #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,generics_of,type_of")]
  358. #[rustc_clean(cfg="cfail6")]
  359. enum EnumChangeNameOfLifetimeParameter<'b> {
  360. Variant1(&'b u32),
  361. }
  362. // Add a lifetime parameter ---------------------------------------------------
  363. #[cfg(any(cfail1,cfail4))]
  364. enum EnumAddLifetimeParameter<'a> {
  365. Variant1(&'a u32),
  366. Variant2(&'a u32),
  367. }
  368. #[cfg(not(any(cfail1,cfail4)))]
  369. #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,generics_of,type_of")]
  370. #[rustc_clean(cfg="cfail3")]
  371. #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,generics_of,type_of")]
  372. #[rustc_clean(cfg="cfail6")]
  373. enum EnumAddLifetimeParameter<'a, 'b> {
  374. Variant1(&'a u32),
  375. Variant2(&'b u32),
  376. }
  377. // Add a lifetime bound to a lifetime parameter -------------------------------
  378. #[cfg(any(cfail1,cfail4))]
  379. enum EnumAddLifetimeParameterBound<'a, 'b> {
  380. Variant1(&'a u32),
  381. Variant2(&'b u32),
  382. }
  383. #[cfg(not(any(cfail1,cfail4)))]
  384. #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,predicates_of")]
  385. #[rustc_clean(cfg="cfail3")]
  386. #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,predicates_of")]
  387. #[rustc_clean(cfg="cfail6")]
  388. enum EnumAddLifetimeParameterBound<'a, 'b: 'a> {
  389. Variant1(&'a u32),
  390. Variant2(&'b u32),
  391. }
  392. // Add a lifetime bound to a type parameter -----------------------------------
  393. #[cfg(any(cfail1,cfail4))]
  394. enum EnumAddLifetimeBoundToParameter<'a, T> {
  395. Variant1(T),
  396. Variant2(&'a u32),
  397. }
  398. #[cfg(not(any(cfail1,cfail4)))]
  399. #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,generics_of,predicates_of")]
  400. #[rustc_clean(cfg="cfail3")]
  401. #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,generics_of,predicates_of")]
  402. #[rustc_clean(cfg="cfail6")]
  403. enum EnumAddLifetimeBoundToParameter<'a, T: 'a> {
  404. Variant1(T),
  405. Variant2(&'a u32),
  406. }
  407. // Add a trait bound to a type parameter --------------------------------------
  408. #[cfg(any(cfail1,cfail4))]
  409. enum EnumAddTraitBound<S> {
  410. Variant1(S),
  411. }
  412. #[cfg(not(any(cfail1,cfail4)))]
  413. #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,generics_of,predicates_of,type_of")]
  414. #[rustc_clean(cfg="cfail3")]
  415. #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,generics_of,predicates_of,type_of")]
  416. #[rustc_clean(cfg="cfail6")]
  417. enum EnumAddTraitBound<T: Sync> {
  418. Variant1(T),
  419. }
  420. // Add a lifetime bound to a lifetime parameter in where clause ---------------
  421. #[cfg(any(cfail1,cfail4))]
  422. enum EnumAddLifetimeParameterBoundWhere<'a, 'b> {
  423. Variant1(&'a u32),
  424. Variant2(&'b u32),
  425. }
  426. #[cfg(not(any(cfail1,cfail4)))]
  427. #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,predicates_of")]
  428. #[rustc_clean(cfg="cfail3")]
  429. #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,predicates_of")]
  430. #[rustc_clean(cfg="cfail6")]
  431. enum EnumAddLifetimeParameterBoundWhere<'a, 'b> where 'b: 'a {
  432. Variant1(&'a u32),
  433. Variant2(&'b u32),
  434. }
  435. // Add a lifetime bound to a type parameter in where clause -------------------
  436. #[cfg(any(cfail1,cfail4))]
  437. enum EnumAddLifetimeBoundToParameterWhere<'a, T> {
  438. Variant1(T),
  439. Variant2(&'a u32),
  440. }
  441. #[cfg(not(any(cfail1,cfail4)))]
  442. #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,generics_of,predicates_of")]
  443. #[rustc_clean(cfg="cfail3")]
  444. #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,generics_of,predicates_of")]
  445. #[rustc_clean(cfg="cfail6")]
  446. enum EnumAddLifetimeBoundToParameterWhere<'a, T> where T: 'a {
  447. Variant1(T),
  448. Variant2(&'a u32),
  449. }
  450. // Add a trait bound to a type parameter in where clause ----------------------
  451. #[cfg(any(cfail1,cfail4))]
  452. enum EnumAddTraitBoundWhere<S> {
  453. Variant1(S),
  454. }
  455. #[cfg(not(any(cfail1,cfail4)))]
  456. #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,generics_of,predicates_of,type_of")]
  457. #[rustc_clean(cfg="cfail3")]
  458. #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,generics_of,predicates_of,type_of")]
  459. #[rustc_clean(cfg="cfail6")]
  460. enum EnumAddTraitBoundWhere<T> where T: Sync {
  461. Variant1(T),
  462. }
  463. // In an enum with two variants, swap usage of type parameters ----------------
  464. #[cfg(any(cfail1,cfail4))]
  465. enum EnumSwapUsageTypeParameters<A, B> {
  466. Variant1 { a: A },
  467. Variant2 { a: B },
  468. }
  469. #[cfg(not(any(cfail1,cfail4)))]
  470. #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes")]
  471. #[rustc_clean(cfg="cfail3")]
  472. #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes")]
  473. #[rustc_clean(cfg="cfail6")]
  474. enum EnumSwapUsageTypeParameters<A, B> {
  475. Variant1 {
  476. a: B
  477. },
  478. Variant2 {
  479. a: A
  480. },
  481. }
  482. // In an enum with two variants, swap usage of lifetime parameters ------------
  483. #[cfg(any(cfail1,cfail4))]
  484. enum EnumSwapUsageLifetimeParameters<'a, 'b> {
  485. Variant1 { a: &'a u32 },
  486. Variant2 { b: &'b u32 },
  487. }
  488. #[cfg(not(any(cfail1,cfail4)))]
  489. #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes")]
  490. #[rustc_clean(cfg="cfail3")]
  491. #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes")]
  492. #[rustc_clean(cfg="cfail6")]
  493. enum EnumSwapUsageLifetimeParameters<'a, 'b> {
  494. Variant1 {
  495. a: &'b u32
  496. },
  497. Variant2 {
  498. b: &'a u32
  499. },
  500. }
  501. struct ReferencedType1;
  502. struct ReferencedType2;
  503. // Change field type in tuple-style variant indirectly by modifying a use statement
  504. mod change_field_type_indirectly_tuple_style {
  505. #[cfg(any(cfail1,cfail4))]
  506. use super::ReferencedType1 as FieldType;
  507. #[cfg(not(any(cfail1,cfail4)))]
  508. use super::ReferencedType2 as FieldType;
  509. #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes")]
  510. #[rustc_clean(cfg="cfail3")]
  511. #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes")]
  512. #[rustc_clean(cfg="cfail6")]
  513. enum TupleStyle {
  514. Variant1(
  515. FieldType
  516. )
  517. }
  518. }
  519. // Change field type in record-style variant indirectly by modifying a use statement
  520. mod change_field_type_indirectly_struct_style {
  521. #[cfg(any(cfail1,cfail4))]
  522. use super::ReferencedType1 as FieldType;
  523. #[cfg(not(any(cfail1,cfail4)))]
  524. use super::ReferencedType2 as FieldType;
  525. #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes")]
  526. #[rustc_clean(cfg="cfail3")]
  527. #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes")]
  528. #[rustc_clean(cfg="cfail6")]
  529. enum StructStyle {
  530. Variant1 {
  531. a: FieldType
  532. }
  533. }
  534. }
  535. trait ReferencedTrait1 {}
  536. trait ReferencedTrait2 {}
  537. // Change trait bound of type parameter indirectly by modifying a use statement
  538. mod change_trait_bound_indirectly {
  539. #[cfg(any(cfail1,cfail4))]
  540. use super::ReferencedTrait1 as Trait;
  541. #[cfg(not(any(cfail1,cfail4)))]
  542. use super::ReferencedTrait2 as Trait;
  543. #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,predicates_of")]
  544. #[rustc_clean(cfg="cfail3")]
  545. #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,predicates_of")]
  546. #[rustc_clean(cfg="cfail6")]
  547. enum Enum<T: Trait> {
  548. Variant1(T)
  549. }
  550. }
  551. // Change trait bound of type parameter in where clause indirectly by modifying a use statement
  552. mod change_trait_bound_indirectly_where {
  553. #[cfg(any(cfail1,cfail4))]
  554. use super::ReferencedTrait1 as Trait;
  555. #[cfg(not(any(cfail1,cfail4)))]
  556. use super::ReferencedTrait2 as Trait;
  557. #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,predicates_of")]
  558. #[rustc_clean(cfg="cfail3")]
  559. #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,predicates_of")]
  560. #[rustc_clean(cfg="cfail6")]
  561. enum Enum<T> where T: Trait {
  562. Variant1(T)
  563. }
  564. }