/src/test/incremental/hashes/trait_defs.rs

https://gitlab.com/jianglu/rust · Rust · 1056 lines · 671 code · 293 blank · 92 comment · 0 complexity · 4d08f4db282316f43c5ac7fdc0e40252 MD5 · raw file

  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. // This test case tests the incremental compilation hash (ICH) implementation
  11. // for trait definitions.
  12. // The general pattern followed here is: Change one thing between rev1 and rev2
  13. // and make sure that the hash has changed, then change nothing between rev2 and
  14. // rev3 and make sure that the hash has not changed.
  15. // We also test the ICH for trait definitions exported in metadata. Same as
  16. // above, we want to make sure that the change between rev1 and rev2 also
  17. // results in a change of the ICH for the trait's metadata, and that it stays
  18. // the same between rev2 and rev3.
  19. // compile-pass
  20. // revisions: cfail1 cfail2 cfail3
  21. // compile-flags: -Z query-dep-graph -Zincremental-ignore-spans
  22. #![allow(warnings)]
  23. #![feature(rustc_attrs)]
  24. #![crate_type="rlib"]
  25. #![feature(associated_type_defaults)]
  26. #![feature(intrinsics)]
  27. // Change trait visibility --------------------------------------------------------
  28. #[cfg(cfail1)]
  29. trait TraitVisibility { }
  30. #[cfg(not(cfail1))]
  31. #[rustc_dirty(label="Hir", cfg="cfail2")]
  32. #[rustc_clean(label="Hir", cfg="cfail3")]
  33. pub trait TraitVisibility { }
  34. // Change trait unsafety ----------------------------------------------------------
  35. #[cfg(cfail1)]
  36. trait TraitUnsafety { }
  37. #[cfg(not(cfail1))]
  38. #[rustc_dirty(label="Hir", cfg="cfail2")]
  39. #[rustc_clean(label="Hir", cfg="cfail3")]
  40. unsafe trait TraitUnsafety { }
  41. // Add method ---------------------------------------------------------------------
  42. #[cfg(cfail1)]
  43. trait TraitAddMethod {
  44. }
  45. #[cfg(not(cfail1))]
  46. #[rustc_dirty(label="Hir", cfg="cfail2")]
  47. #[rustc_clean(label="Hir", cfg="cfail3")]
  48. pub trait TraitAddMethod {
  49. fn method();
  50. }
  51. // Change name of method ----------------------------------------------------------
  52. #[cfg(cfail1)]
  53. trait TraitChangeMethodName {
  54. fn method();
  55. }
  56. #[cfg(not(cfail1))]
  57. #[rustc_dirty(label="Hir", cfg="cfail2")]
  58. #[rustc_clean(label="Hir", cfg="cfail3")]
  59. trait TraitChangeMethodName {
  60. fn methodChanged();
  61. }
  62. // Add return type to method ------------------------------------------------------
  63. #[cfg(cfail1)]
  64. trait TraitAddReturnType {
  65. fn method();
  66. }
  67. #[cfg(not(cfail1))]
  68. #[rustc_clean(label="Hir", cfg="cfail2")]
  69. #[rustc_clean(label="Hir", cfg="cfail3")]
  70. trait TraitAddReturnType {
  71. #[rustc_dirty(label="Hir", cfg="cfail2")]
  72. #[rustc_clean(label="Hir", cfg="cfail3")]
  73. fn method() -> u32;
  74. }
  75. // Change return type of method ---------------------------------------------------
  76. #[cfg(cfail1)]
  77. trait TraitChangeReturnType {
  78. fn method() -> u32;
  79. }
  80. #[cfg(not(cfail1))]
  81. #[rustc_clean(label="Hir", cfg="cfail2")]
  82. #[rustc_clean(label="Hir", cfg="cfail3")]
  83. trait TraitChangeReturnType {
  84. #[rustc_dirty(label="Hir", cfg="cfail2")]
  85. #[rustc_clean(label="Hir", cfg="cfail3")]
  86. fn method() -> u64;
  87. }
  88. // Add parameter to method --------------------------------------------------------
  89. #[cfg(cfail1)]
  90. trait TraitAddParameterToMethod {
  91. fn method();
  92. }
  93. #[cfg(not(cfail1))]
  94. #[rustc_clean(label="Hir", cfg="cfail2")]
  95. #[rustc_clean(label="Hir", cfg="cfail3")]
  96. trait TraitAddParameterToMethod {
  97. #[rustc_dirty(label="Hir", cfg="cfail2")]
  98. #[rustc_clean(label="Hir", cfg="cfail3")]
  99. fn method(a: u32);
  100. }
  101. // Change name of method parameter ------------------------------------------------
  102. #[cfg(cfail1)]
  103. trait TraitChangeMethodParameterName {
  104. fn method(a: u32);
  105. fn with_default(x: i32) {}
  106. }
  107. #[cfg(not(cfail1))]
  108. #[rustc_clean(label="Hir", cfg="cfail2")]
  109. #[rustc_clean(label="Hir", cfg="cfail3")]
  110. trait TraitChangeMethodParameterName {
  111. // FIXME(#38501) This should preferably always be clean.
  112. #[rustc_dirty(label="Hir", cfg="cfail2")]
  113. #[rustc_clean(label="Hir", cfg="cfail3")]
  114. fn method(b: u32);
  115. #[rustc_clean(label="Hir", cfg="cfail2")]
  116. #[rustc_clean(label="Hir", cfg="cfail3")]
  117. #[rustc_dirty(label="HirBody", cfg="cfail2")]
  118. #[rustc_clean(label="HirBody", cfg="cfail3")]
  119. fn with_default(y: i32) {}
  120. }
  121. // Change type of method parameter (i32 => i64) -----------------------------------
  122. #[cfg(cfail1)]
  123. trait TraitChangeMethodParameterType {
  124. fn method(a: i32);
  125. }
  126. #[cfg(not(cfail1))]
  127. #[rustc_clean(label="Hir", cfg="cfail2")]
  128. #[rustc_clean(label="Hir", cfg="cfail3")]
  129. trait TraitChangeMethodParameterType {
  130. #[rustc_dirty(label="Hir", cfg="cfail2")]
  131. #[rustc_clean(label="Hir", cfg="cfail3")]
  132. fn method(a: i64);
  133. }
  134. // Change type of method parameter (&i32 => &mut i32) -----------------------------
  135. #[cfg(cfail1)]
  136. trait TraitChangeMethodParameterTypeRef {
  137. fn method(a: &i32);
  138. }
  139. #[cfg(not(cfail1))]
  140. #[rustc_clean(label="Hir", cfg="cfail2")]
  141. #[rustc_clean(label="Hir", cfg="cfail3")]
  142. trait TraitChangeMethodParameterTypeRef {
  143. #[rustc_dirty(label="Hir", cfg="cfail2")]
  144. #[rustc_clean(label="Hir", cfg="cfail3")]
  145. fn method(a: &mut i32);
  146. }
  147. // Change order of method parameters ----------------------------------------------
  148. #[cfg(cfail1)]
  149. trait TraitChangeMethodParametersOrder {
  150. fn method(a: i32, b: i64);
  151. }
  152. #[cfg(not(cfail1))]
  153. #[rustc_clean(label="Hir", cfg="cfail2")]
  154. #[rustc_clean(label="Hir", cfg="cfail3")]
  155. trait TraitChangeMethodParametersOrder {
  156. #[rustc_dirty(label="Hir", cfg="cfail2")]
  157. #[rustc_clean(label="Hir", cfg="cfail3")]
  158. fn method(b: i64, a: i32);
  159. }
  160. // Add default implementation to method -------------------------------------------
  161. #[cfg(cfail1)]
  162. trait TraitAddMethodAutoImplementation {
  163. fn method();
  164. }
  165. #[cfg(not(cfail1))]
  166. #[rustc_dirty(label="Hir", cfg="cfail2")]
  167. #[rustc_clean(label="Hir", cfg="cfail3")]
  168. trait TraitAddMethodAutoImplementation {
  169. #[rustc_dirty(label="Hir", cfg="cfail2")]
  170. #[rustc_clean(label="Hir", cfg="cfail3")]
  171. fn method() { }
  172. }
  173. // Change order of methods --------------------------------------------------------
  174. #[cfg(cfail1)]
  175. trait TraitChangeOrderOfMethods {
  176. fn method0();
  177. fn method1();
  178. }
  179. #[cfg(not(cfail1))]
  180. #[rustc_dirty(label="Hir", cfg="cfail2")]
  181. #[rustc_clean(label="Hir", cfg="cfail3")]
  182. trait TraitChangeOrderOfMethods {
  183. fn method1();
  184. fn method0();
  185. }
  186. // Change mode of self parameter --------------------------------------------------
  187. #[cfg(cfail1)]
  188. trait TraitChangeModeSelfRefToMut {
  189. fn method(&self);
  190. }
  191. #[cfg(not(cfail1))]
  192. #[rustc_clean(label="Hir", cfg="cfail2")]
  193. #[rustc_clean(label="Hir", cfg="cfail3")]
  194. trait TraitChangeModeSelfRefToMut {
  195. #[rustc_dirty(label="Hir", cfg="cfail2")]
  196. #[rustc_clean(label="Hir", cfg="cfail3")]
  197. fn method(&mut self);
  198. }
  199. #[cfg(cfail1)]
  200. trait TraitChangeModeSelfOwnToMut: Sized {
  201. fn method(self) {}
  202. }
  203. #[cfg(not(cfail1))]
  204. #[rustc_clean(label="Hir", cfg="cfail2")]
  205. #[rustc_clean(label="Hir", cfg="cfail3")]
  206. trait TraitChangeModeSelfOwnToMut: Sized {
  207. #[rustc_clean(label="Hir", cfg="cfail2")]
  208. #[rustc_clean(label="Hir", cfg="cfail3")]
  209. #[rustc_dirty(label="HirBody", cfg="cfail2")]
  210. #[rustc_clean(label="HirBody", cfg="cfail3")]
  211. fn method(mut self) {}
  212. }
  213. #[cfg(cfail1)]
  214. trait TraitChangeModeSelfOwnToRef {
  215. fn method(self);
  216. }
  217. #[cfg(not(cfail1))]
  218. #[rustc_clean(label="Hir", cfg="cfail2")]
  219. #[rustc_clean(label="Hir", cfg="cfail3")]
  220. trait TraitChangeModeSelfOwnToRef {
  221. #[rustc_dirty(label="Hir", cfg="cfail2")]
  222. #[rustc_clean(label="Hir", cfg="cfail3")]
  223. fn method(&self);
  224. }
  225. // Add unsafe modifier to method --------------------------------------------------
  226. #[cfg(cfail1)]
  227. trait TraitAddUnsafeModifier {
  228. fn method();
  229. }
  230. #[cfg(not(cfail1))]
  231. #[rustc_clean(label="Hir", cfg="cfail2")]
  232. #[rustc_clean(label="Hir", cfg="cfail3")]
  233. trait TraitAddUnsafeModifier {
  234. #[rustc_dirty(label="Hir", cfg="cfail2")]
  235. #[rustc_clean(label="Hir", cfg="cfail3")]
  236. unsafe fn method();
  237. }
  238. // Add extern modifier to method --------------------------------------------------
  239. #[cfg(cfail1)]
  240. trait TraitAddExternModifier {
  241. fn method();
  242. }
  243. #[cfg(not(cfail1))]
  244. #[rustc_clean(label="Hir", cfg="cfail2")]
  245. #[rustc_clean(label="Hir", cfg="cfail3")]
  246. trait TraitAddExternModifier {
  247. #[rustc_dirty(label="Hir", cfg="cfail2")]
  248. #[rustc_clean(label="Hir", cfg="cfail3")]
  249. extern fn method();
  250. }
  251. // Change extern "C" to extern "rust-intrinsic" -----------------------------------
  252. #[cfg(cfail1)]
  253. trait TraitChangeExternCToRustIntrinsic {
  254. extern "C" fn method();
  255. }
  256. #[cfg(not(cfail1))]
  257. #[rustc_clean(label="Hir", cfg="cfail2")]
  258. #[rustc_clean(label="Hir", cfg="cfail3")]
  259. trait TraitChangeExternCToRustIntrinsic {
  260. #[rustc_dirty(label="Hir", cfg="cfail2")]
  261. #[rustc_clean(label="Hir", cfg="cfail3")]
  262. extern "rust-intrinsic" fn method();
  263. }
  264. // Add type parameter to method ---------------------------------------------------
  265. #[cfg(cfail1)]
  266. trait TraitAddTypeParameterToMethod {
  267. fn method();
  268. }
  269. #[cfg(not(cfail1))]
  270. #[rustc_clean(label="Hir", cfg="cfail2")]
  271. #[rustc_clean(label="Hir", cfg="cfail3")]
  272. trait TraitAddTypeParameterToMethod {
  273. #[rustc_dirty(label="Hir", cfg="cfail2")]
  274. #[rustc_clean(label="Hir", cfg="cfail3")]
  275. fn method<T>();
  276. }
  277. // Add lifetime parameter to method -----------------------------------------------
  278. #[cfg(cfail1)]
  279. trait TraitAddLifetimeParameterToMethod {
  280. fn method();
  281. }
  282. #[cfg(not(cfail1))]
  283. #[rustc_clean(label="Hir", cfg="cfail2")]
  284. #[rustc_clean(label="Hir", cfg="cfail3")]
  285. trait TraitAddLifetimeParameterToMethod {
  286. #[rustc_dirty(label="Hir", cfg="cfail2")]
  287. #[rustc_clean(label="Hir", cfg="cfail3")]
  288. fn method<'a>();
  289. }
  290. // dummy trait for bound
  291. trait ReferencedTrait0 { }
  292. trait ReferencedTrait1 { }
  293. // Add trait bound to method type parameter ---------------------------------------
  294. #[cfg(cfail1)]
  295. trait TraitAddTraitBoundToMethodTypeParameter {
  296. fn method<T>();
  297. }
  298. #[cfg(not(cfail1))]
  299. #[rustc_clean(label="Hir", cfg="cfail2")]
  300. #[rustc_clean(label="Hir", cfg="cfail3")]
  301. trait TraitAddTraitBoundToMethodTypeParameter {
  302. #[rustc_dirty(label="Hir", cfg="cfail2")]
  303. #[rustc_clean(label="Hir", cfg="cfail3")]
  304. fn method<T: ReferencedTrait0>();
  305. }
  306. // Add builtin bound to method type parameter -------------------------------------
  307. #[cfg(cfail1)]
  308. trait TraitAddBuiltinBoundToMethodTypeParameter {
  309. fn method<T>();
  310. }
  311. #[cfg(not(cfail1))]
  312. #[rustc_clean(label="Hir", cfg="cfail2")]
  313. #[rustc_clean(label="Hir", cfg="cfail3")]
  314. trait TraitAddBuiltinBoundToMethodTypeParameter {
  315. #[rustc_dirty(label="Hir", cfg="cfail2")]
  316. #[rustc_clean(label="Hir", cfg="cfail3")]
  317. fn method<T: Sized>();
  318. }
  319. // Add lifetime bound to method lifetime parameter ------------------------------------
  320. #[cfg(cfail1)]
  321. trait TraitAddLifetimeBoundToMethodLifetimeParameter {
  322. fn method<'a, 'b>(a: &'a u32, b: &'b u32);
  323. }
  324. #[cfg(not(cfail1))]
  325. #[rustc_clean(label="Hir", cfg="cfail2")]
  326. #[rustc_clean(label="Hir", cfg="cfail3")]
  327. trait TraitAddLifetimeBoundToMethodLifetimeParameter {
  328. #[rustc_dirty(label="Hir", cfg="cfail2")]
  329. #[rustc_clean(label="Hir", cfg="cfail3")]
  330. fn method<'a, 'b: 'a>(a: &'a u32, b: &'b u32);
  331. }
  332. // Add second trait bound to method type parameter --------------------------------
  333. #[cfg(cfail1)]
  334. trait TraitAddSecondTraitBoundToMethodTypeParameter {
  335. fn method<T: ReferencedTrait0>();
  336. }
  337. #[cfg(not(cfail1))]
  338. #[rustc_clean(label="Hir", cfg="cfail2")]
  339. #[rustc_clean(label="Hir", cfg="cfail3")]
  340. trait TraitAddSecondTraitBoundToMethodTypeParameter {
  341. #[rustc_dirty(label="Hir", cfg="cfail2")]
  342. #[rustc_clean(label="Hir", cfg="cfail3")]
  343. fn method<T: ReferencedTrait0 + ReferencedTrait1>();
  344. }
  345. // Add second builtin bound to method type parameter ------------------------------
  346. #[cfg(cfail1)]
  347. trait TraitAddSecondBuiltinBoundToMethodTypeParameter {
  348. fn method<T: Sized>();
  349. }
  350. #[cfg(not(cfail1))]
  351. #[rustc_clean(label="Hir", cfg="cfail2")]
  352. #[rustc_clean(label="Hir", cfg="cfail3")]
  353. trait TraitAddSecondBuiltinBoundToMethodTypeParameter {
  354. #[rustc_dirty(label="Hir", cfg="cfail2")]
  355. #[rustc_clean(label="Hir", cfg="cfail3")]
  356. fn method<T: Sized + Sync>();
  357. }
  358. // Add second lifetime bound to method lifetime parameter -----------------------------
  359. #[cfg(cfail1)]
  360. trait TraitAddSecondLifetimeBoundToMethodLifetimeParameter {
  361. fn method<'a, 'b, 'c: 'a>(a: &'a u32, b: &'b u32, c: &'c u32);
  362. }
  363. #[cfg(not(cfail1))]
  364. #[rustc_clean(label="Hir", cfg="cfail2")]
  365. #[rustc_clean(label="Hir", cfg="cfail3")]
  366. trait TraitAddSecondLifetimeBoundToMethodLifetimeParameter {
  367. #[rustc_dirty(label="Hir", cfg="cfail2")]
  368. #[rustc_clean(label="Hir", cfg="cfail3")]
  369. fn method<'a, 'b, 'c: 'a + 'b>(a: &'a u32, b: &'b u32, c: &'c u32);
  370. }
  371. // Add associated type ------------------------------------------------------------
  372. #[cfg(cfail1)]
  373. trait TraitAddAssociatedType {
  374. #[rustc_dirty(label="Hir", cfg="cfail2")]
  375. #[rustc_clean(label="Hir", cfg="cfail3")]
  376. fn method();
  377. }
  378. #[cfg(not(cfail1))]
  379. #[rustc_dirty(label="Hir", cfg="cfail2")]
  380. #[rustc_clean(label="Hir", cfg="cfail3")]
  381. trait TraitAddAssociatedType {
  382. type Associated;
  383. fn method();
  384. }
  385. // Add trait bound to associated type ---------------------------------------------
  386. #[cfg(cfail1)]
  387. trait TraitAddTraitBoundToAssociatedType {
  388. type Associated;
  389. fn method();
  390. }
  391. // Apparently the type bound contributes to the predicates of the trait, but
  392. // does not change the associated item itself.
  393. #[cfg(not(cfail1))]
  394. #[rustc_clean(label="Hir", cfg="cfail2")]
  395. #[rustc_clean(label="Hir", cfg="cfail3")]
  396. trait TraitAddTraitBoundToAssociatedType {
  397. #[rustc_dirty(label="Hir", cfg="cfail2")]
  398. #[rustc_clean(label="Hir", cfg="cfail3")]
  399. type Associated: ReferencedTrait0;
  400. fn method();
  401. }
  402. // Add lifetime bound to associated type ------------------------------------------
  403. #[cfg(cfail1)]
  404. trait TraitAddLifetimeBoundToAssociatedType<'a> {
  405. type Associated;
  406. fn method();
  407. }
  408. #[cfg(not(cfail1))]
  409. #[rustc_clean(label="Hir", cfg="cfail2")]
  410. #[rustc_clean(label="Hir", cfg="cfail3")]
  411. trait TraitAddLifetimeBoundToAssociatedType<'a> {
  412. #[rustc_dirty(label="Hir", cfg="cfail2")]
  413. #[rustc_clean(label="Hir", cfg="cfail3")]
  414. type Associated: 'a;
  415. fn method();
  416. }
  417. // Add default to associated type -------------------------------------------------
  418. #[cfg(cfail1)]
  419. trait TraitAddDefaultToAssociatedType {
  420. type Associated;
  421. fn method();
  422. }
  423. #[cfg(not(cfail1))]
  424. #[rustc_dirty(label="Hir", cfg="cfail2")]
  425. #[rustc_clean(label="Hir", cfg="cfail3")]
  426. trait TraitAddDefaultToAssociatedType {
  427. #[rustc_dirty(label="Hir", cfg="cfail2")]
  428. #[rustc_clean(label="Hir", cfg="cfail3")]
  429. type Associated = ReferenceType0;
  430. fn method();
  431. }
  432. // Add associated constant --------------------------------------------------------
  433. #[cfg(cfail1)]
  434. trait TraitAddAssociatedConstant {
  435. fn method();
  436. }
  437. #[cfg(not(cfail1))]
  438. #[rustc_dirty(label="Hir", cfg="cfail2")]
  439. #[rustc_clean(label="Hir", cfg="cfail3")]
  440. trait TraitAddAssociatedConstant {
  441. const Value: u32;
  442. fn method();
  443. }
  444. // Add initializer to associated constant -----------------------------------------
  445. #[cfg(cfail1)]
  446. trait TraitAddInitializerToAssociatedConstant {
  447. const Value: u32;
  448. fn method();
  449. }
  450. #[cfg(not(cfail1))]
  451. #[rustc_dirty(label="Hir", cfg="cfail2")]
  452. #[rustc_clean(label="Hir", cfg="cfail3")]
  453. trait TraitAddInitializerToAssociatedConstant {
  454. #[rustc_dirty(label="Hir", cfg="cfail2")]
  455. #[rustc_clean(label="Hir", cfg="cfail3")]
  456. const Value: u32 = 1;
  457. #[rustc_clean(label="Hir", cfg="cfail2")]
  458. #[rustc_clean(label="Hir", cfg="cfail3")]
  459. fn method();
  460. }
  461. // Change type of associated constant ---------------------------------------------
  462. #[cfg(cfail1)]
  463. trait TraitChangeTypeOfAssociatedConstant {
  464. const Value: u32;
  465. fn method();
  466. }
  467. #[cfg(not(cfail1))]
  468. #[rustc_clean(label="Hir", cfg="cfail2")]
  469. #[rustc_clean(label="Hir", cfg="cfail3")]
  470. trait TraitChangeTypeOfAssociatedConstant {
  471. #[rustc_dirty(label="Hir", cfg="cfail2")]
  472. #[rustc_clean(label="Hir", cfg="cfail3")]
  473. const Value: f64;
  474. #[rustc_clean(label="Hir", cfg="cfail2")]
  475. #[rustc_clean(label="Hir", cfg="cfail3")]
  476. fn method();
  477. }
  478. // Add super trait ----------------------------------------------------------------
  479. #[cfg(cfail1)]
  480. trait TraitAddSuperTrait { }
  481. #[cfg(not(cfail1))]
  482. #[rustc_dirty(label="Hir", cfg="cfail2")]
  483. #[rustc_clean(label="Hir", cfg="cfail3")]
  484. trait TraitAddSuperTrait : ReferencedTrait0 { }
  485. // Add builtin bound (Send or Copy) -----------------------------------------------
  486. #[cfg(cfail1)]
  487. trait TraitAddBuiltiBound { }
  488. #[cfg(not(cfail1))]
  489. #[rustc_dirty(label="Hir", cfg="cfail2")]
  490. #[rustc_clean(label="Hir", cfg="cfail3")]
  491. trait TraitAddBuiltiBound : Send { }
  492. // Add 'static lifetime bound to trait --------------------------------------------
  493. #[cfg(cfail1)]
  494. trait TraitAddStaticLifetimeBound { }
  495. #[cfg(not(cfail1))]
  496. #[rustc_dirty(label="Hir", cfg="cfail2")]
  497. #[rustc_clean(label="Hir", cfg="cfail3")]
  498. trait TraitAddStaticLifetimeBound : 'static { }
  499. // Add super trait as second bound ------------------------------------------------
  500. #[cfg(cfail1)]
  501. trait TraitAddTraitAsSecondBound : ReferencedTrait0 { }
  502. #[cfg(not(cfail1))]
  503. #[rustc_dirty(label="Hir", cfg="cfail2")]
  504. #[rustc_clean(label="Hir", cfg="cfail3")]
  505. trait TraitAddTraitAsSecondBound : ReferencedTrait0 + ReferencedTrait1 { }
  506. #[cfg(cfail1)]
  507. trait TraitAddTraitAsSecondBoundFromBuiltin : Send { }
  508. #[cfg(not(cfail1))]
  509. #[rustc_dirty(label="Hir", cfg="cfail2")]
  510. #[rustc_clean(label="Hir", cfg="cfail3")]
  511. trait TraitAddTraitAsSecondBoundFromBuiltin : Send + ReferencedTrait0 { }
  512. // Add builtin bound as second bound ----------------------------------------------
  513. #[cfg(cfail1)]
  514. trait TraitAddBuiltinBoundAsSecondBound : ReferencedTrait0 { }
  515. #[cfg(not(cfail1))]
  516. #[rustc_dirty(label="Hir", cfg="cfail2")]
  517. #[rustc_clean(label="Hir", cfg="cfail3")]
  518. trait TraitAddBuiltinBoundAsSecondBound : ReferencedTrait0 + Send { }
  519. #[cfg(cfail1)]
  520. trait TraitAddBuiltinBoundAsSecondBoundFromBuiltin : Send { }
  521. #[cfg(not(cfail1))]
  522. #[rustc_dirty(label="Hir", cfg="cfail2")]
  523. #[rustc_clean(label="Hir", cfg="cfail3")]
  524. trait TraitAddBuiltinBoundAsSecondBoundFromBuiltin: Send + Copy { }
  525. // Add 'static bounds as second bound ---------------------------------------------
  526. #[cfg(cfail1)]
  527. trait TraitAddStaticBoundAsSecondBound : ReferencedTrait0 { }
  528. #[cfg(not(cfail1))]
  529. #[rustc_dirty(label="Hir", cfg="cfail2")]
  530. #[rustc_clean(label="Hir", cfg="cfail3")]
  531. trait TraitAddStaticBoundAsSecondBound : ReferencedTrait0 + 'static { }
  532. #[cfg(cfail1)]
  533. trait TraitAddStaticBoundAsSecondBoundFromBuiltin : Send { }
  534. #[cfg(not(cfail1))]
  535. #[rustc_dirty(label="Hir", cfg="cfail2")]
  536. #[rustc_clean(label="Hir", cfg="cfail3")]
  537. trait TraitAddStaticBoundAsSecondBoundFromBuiltin : Send + 'static { }
  538. // Add type parameter to trait ----------------------------------------------------
  539. #[cfg(cfail1)]
  540. trait TraitAddTypeParameterToTrait { }
  541. #[cfg(not(cfail1))]
  542. #[rustc_dirty(label="Hir", cfg="cfail2")]
  543. #[rustc_clean(label="Hir", cfg="cfail3")]
  544. trait TraitAddTypeParameterToTrait<T> { }
  545. // Add lifetime parameter to trait ------------------------------------------------
  546. #[cfg(cfail1)]
  547. trait TraitAddLifetimeParameterToTrait { }
  548. #[cfg(not(cfail1))]
  549. #[rustc_dirty(label="Hir", cfg="cfail2")]
  550. #[rustc_clean(label="Hir", cfg="cfail3")]
  551. trait TraitAddLifetimeParameterToTrait<'a> { }
  552. // Add trait bound to type parameter of trait -------------------------------------
  553. #[cfg(cfail1)]
  554. trait TraitAddTraitBoundToTypeParameterOfTrait<T> { }
  555. #[cfg(not(cfail1))]
  556. #[rustc_dirty(label="Hir", cfg="cfail2")]
  557. #[rustc_clean(label="Hir", cfg="cfail3")]
  558. trait TraitAddTraitBoundToTypeParameterOfTrait<T: ReferencedTrait0> { }
  559. // Add lifetime bound to type parameter of trait ----------------------------------
  560. #[cfg(cfail1)]
  561. trait TraitAddLifetimeBoundToTypeParameterOfTrait<'a, T> { }
  562. #[cfg(not(cfail1))]
  563. #[rustc_dirty(label="Hir", cfg="cfail2")]
  564. #[rustc_clean(label="Hir", cfg="cfail3")]
  565. trait TraitAddLifetimeBoundToTypeParameterOfTrait<'a, T: 'a> { }
  566. // Add lifetime bound to lifetime parameter of trait ------------------------------
  567. #[cfg(cfail1)]
  568. trait TraitAddLifetimeBoundToLifetimeParameterOfTrait<'a, 'b> { }
  569. #[cfg(not(cfail1))]
  570. #[rustc_dirty(label="Hir", cfg="cfail2")]
  571. #[rustc_clean(label="Hir", cfg="cfail3")]
  572. trait TraitAddLifetimeBoundToLifetimeParameterOfTrait<'a: 'b, 'b> { }
  573. // Add builtin bound to type parameter of trait -----------------------------------
  574. #[cfg(cfail1)]
  575. trait TraitAddBuiltinBoundToTypeParameterOfTrait<T> { }
  576. #[cfg(not(cfail1))]
  577. #[rustc_dirty(label="Hir", cfg="cfail2")]
  578. #[rustc_clean(label="Hir", cfg="cfail3")]
  579. trait TraitAddBuiltinBoundToTypeParameterOfTrait<T: Send> { }
  580. // Add second type parameter to trait ---------------------------------------------
  581. #[cfg(cfail1)]
  582. trait TraitAddSecondTypeParameterToTrait<T> { }
  583. #[cfg(not(cfail1))]
  584. #[rustc_dirty(label="Hir", cfg="cfail2")]
  585. #[rustc_clean(label="Hir", cfg="cfail3")]
  586. trait TraitAddSecondTypeParameterToTrait<T, S> { }
  587. // Add second lifetime parameter to trait -----------------------------------------
  588. #[cfg(cfail1)]
  589. trait TraitAddSecondLifetimeParameterToTrait<'a> { }
  590. #[cfg(not(cfail1))]
  591. #[rustc_dirty(label="Hir", cfg="cfail2")]
  592. #[rustc_clean(label="Hir", cfg="cfail3")]
  593. trait TraitAddSecondLifetimeParameterToTrait<'a, 'b> { }
  594. // Add second trait bound to type parameter of trait ------------------------------
  595. #[cfg(cfail1)]
  596. trait TraitAddSecondTraitBoundToTypeParameterOfTrait<T: ReferencedTrait0> { }
  597. #[cfg(not(cfail1))]
  598. #[rustc_dirty(label="Hir", cfg="cfail2")]
  599. #[rustc_clean(label="Hir", cfg="cfail3")]
  600. trait TraitAddSecondTraitBoundToTypeParameterOfTrait<T: ReferencedTrait0 + ReferencedTrait1> { }
  601. // Add second lifetime bound to type parameter of trait ---------------------------
  602. #[cfg(cfail1)]
  603. trait TraitAddSecondLifetimeBoundToTypeParameterOfTrait<'a, 'b, T: 'a> { }
  604. #[cfg(not(cfail1))]
  605. #[rustc_dirty(label="Hir", cfg="cfail2")]
  606. #[rustc_clean(label="Hir", cfg="cfail3")]
  607. trait TraitAddSecondLifetimeBoundToTypeParameterOfTrait<'a, 'b, T: 'a + 'b> { }
  608. // Add second lifetime bound to lifetime parameter of trait------------------------
  609. #[cfg(cfail1)]
  610. trait TraitAddSecondLifetimeBoundToLifetimeParameterOfTrait<'a: 'b, 'b, 'c> { }
  611. #[cfg(not(cfail1))]
  612. #[rustc_dirty(label="Hir", cfg="cfail2")]
  613. #[rustc_clean(label="Hir", cfg="cfail3")]
  614. trait TraitAddSecondLifetimeBoundToLifetimeParameterOfTrait<'a: 'b + 'c, 'b, 'c> { }
  615. // Add second builtin bound to type parameter of trait ----------------------------
  616. #[cfg(cfail1)]
  617. trait TraitAddSecondBuiltinBoundToTypeParameterOfTrait<T: Send> { }
  618. #[cfg(not(cfail1))]
  619. #[rustc_dirty(label="Hir", cfg="cfail2")]
  620. #[rustc_clean(label="Hir", cfg="cfail3")]
  621. trait TraitAddSecondBuiltinBoundToTypeParameterOfTrait<T: Send + Sync> { }
  622. // --------------------------------------------------------------------------------
  623. struct ReferenceType0 {}
  624. struct ReferenceType1 {}
  625. // Add trait bound to type parameter of trait in where clause----------------------
  626. #[cfg(cfail1)]
  627. trait TraitAddTraitBoundToTypeParameterOfTraitWhere<T> { }
  628. #[cfg(not(cfail1))]
  629. #[rustc_dirty(label="Hir", cfg="cfail2")]
  630. #[rustc_clean(label="Hir", cfg="cfail3")]
  631. trait TraitAddTraitBoundToTypeParameterOfTraitWhere<T> where T: ReferencedTrait0 { }
  632. // Add lifetime bound to type parameter of trait in where clause-------------------
  633. #[cfg(cfail1)]
  634. trait TraitAddLifetimeBoundToTypeParameterOfTraitWhere<'a, T> { }
  635. #[cfg(not(cfail1))]
  636. #[rustc_dirty(label="Hir", cfg="cfail2")]
  637. #[rustc_clean(label="Hir", cfg="cfail3")]
  638. trait TraitAddLifetimeBoundToTypeParameterOfTraitWhere<'a, T> where T: 'a { }
  639. // Add lifetime bound to lifetime parameter of trait in where clause---------------
  640. #[cfg(cfail1)]
  641. trait TraitAddLifetimeBoundToLifetimeParameterOfTraitWhere<'a, 'b> { }
  642. #[cfg(not(cfail1))]
  643. #[rustc_dirty(label="Hir", cfg="cfail2")]
  644. #[rustc_clean(label="Hir", cfg="cfail3")]
  645. trait TraitAddLifetimeBoundToLifetimeParameterOfTraitWhere<'a, 'b> where 'a: 'b { }
  646. // Add builtin bound to type parameter of trait in where clause--------------------
  647. #[cfg(cfail1)]
  648. trait TraitAddBuiltinBoundToTypeParameterOfTraitWhere<T> { }
  649. #[cfg(not(cfail1))]
  650. #[rustc_dirty(label="Hir", cfg="cfail2")]
  651. #[rustc_clean(label="Hir", cfg="cfail3")]
  652. trait TraitAddBuiltinBoundToTypeParameterOfTraitWhere<T> where T: Send { }
  653. // Add second trait bound to type parameter of trait in where clause---------------
  654. #[cfg(cfail1)]
  655. trait TraitAddSecondTraitBoundToTypeParameterOfTraitWhere<T> where T: ReferencedTrait0 { }
  656. #[cfg(not(cfail1))]
  657. #[rustc_dirty(label="Hir", cfg="cfail2")]
  658. #[rustc_clean(label="Hir", cfg="cfail3")]
  659. trait TraitAddSecondTraitBoundToTypeParameterOfTraitWhere<T>
  660. where T: ReferencedTrait0 + ReferencedTrait1 { }
  661. // Add second lifetime bound to type parameter of trait in where clause------------
  662. #[cfg(cfail1)]
  663. trait TraitAddSecondLifetimeBoundToTypeParameterOfTraitWhere<'a, 'b, T> where T: 'a { }
  664. #[cfg(not(cfail1))]
  665. #[rustc_dirty(label="Hir", cfg="cfail2")]
  666. #[rustc_clean(label="Hir", cfg="cfail3")]
  667. trait TraitAddSecondLifetimeBoundToTypeParameterOfTraitWhere<'a, 'b, T> where T: 'a + 'b { }
  668. // Add second lifetime bound to lifetime parameter of trait in where clause--------
  669. #[cfg(cfail1)]
  670. trait TraitAddSecondLifetimeBoundToLifetimeParameterOfTraitWhere<'a, 'b, 'c> where 'a: 'b { }
  671. #[cfg(not(cfail1))]
  672. #[rustc_dirty(label="Hir", cfg="cfail2")]
  673. #[rustc_clean(label="Hir", cfg="cfail3")]
  674. trait TraitAddSecondLifetimeBoundToLifetimeParameterOfTraitWhere<'a, 'b, 'c> where 'a: 'b + 'c { }
  675. // Add second builtin bound to type parameter of trait in where clause-------------
  676. #[cfg(cfail1)]
  677. trait TraitAddSecondBuiltinBoundToTypeParameterOfTraitWhere<T> where T: Send { }
  678. #[cfg(not(cfail1))]
  679. #[rustc_dirty(label="Hir", cfg="cfail2")]
  680. #[rustc_clean(label="Hir", cfg="cfail3")]
  681. trait TraitAddSecondBuiltinBoundToTypeParameterOfTraitWhere<T> where T: Send + Sync { }
  682. // Change return type of method indirectly by modifying a use statement------------
  683. mod change_return_type_of_method_indirectly_use {
  684. #[cfg(cfail1)]
  685. use super::ReferenceType0 as ReturnType;
  686. #[cfg(not(cfail1))]
  687. use super::ReferenceType1 as ReturnType;
  688. #[rustc_clean(label="Hir", cfg="cfail2")]
  689. #[rustc_clean(label="Hir", cfg="cfail3")]
  690. trait TraitChangeReturnType {
  691. #[rustc_dirty(label="Hir", cfg="cfail2")]
  692. #[rustc_clean(label="Hir", cfg="cfail3")]
  693. fn method() -> ReturnType;
  694. }
  695. }
  696. // Change type of method parameter indirectly by modifying a use statement---------
  697. mod change_method_parameter_type_indirectly_by_use {
  698. #[cfg(cfail1)]
  699. use super::ReferenceType0 as ArgType;
  700. #[cfg(not(cfail1))]
  701. use super::ReferenceType1 as ArgType;
  702. #[rustc_clean(label="Hir", cfg="cfail2")]
  703. #[rustc_clean(label="Hir", cfg="cfail3")]
  704. trait TraitChangeArgType {
  705. #[rustc_dirty(label="Hir", cfg="cfail2")]
  706. #[rustc_clean(label="Hir", cfg="cfail3")]
  707. fn method(a: ArgType);
  708. }
  709. }
  710. // Change trait bound of method type parameter indirectly by modifying a use statement
  711. mod change_method_parameter_type_bound_indirectly_by_use {
  712. #[cfg(cfail1)]
  713. use super::ReferencedTrait0 as Bound;
  714. #[cfg(not(cfail1))]
  715. use super::ReferencedTrait1 as Bound;
  716. #[rustc_clean(label="Hir", cfg="cfail2")]
  717. #[rustc_clean(label="Hir", cfg="cfail3")]
  718. trait TraitChangeBoundOfMethodTypeParameter {
  719. #[rustc_dirty(label="Hir", cfg="cfail2")]
  720. #[rustc_clean(label="Hir", cfg="cfail3")]
  721. fn method<T: Bound>(a: T);
  722. }
  723. }
  724. // Change trait bound of method type parameter in where clause indirectly
  725. // by modifying a use statement
  726. mod change_method_parameter_type_bound_indirectly_by_use_where {
  727. #[cfg(cfail1)]
  728. use super::ReferencedTrait0 as Bound;
  729. #[cfg(not(cfail1))]
  730. use super::ReferencedTrait1 as Bound;
  731. #[rustc_clean(label="Hir", cfg="cfail2")]
  732. #[rustc_clean(label="Hir", cfg="cfail3")]
  733. trait TraitChangeBoundOfMethodTypeParameterWhere {
  734. #[rustc_dirty(label="Hir", cfg="cfail2")]
  735. #[rustc_clean(label="Hir", cfg="cfail3")]
  736. fn method<T>(a: T) where T: Bound;
  737. }
  738. }
  739. // Change trait bound of trait type parameter indirectly by modifying a use statement
  740. mod change_method_type_parameter_bound_indirectly {
  741. #[cfg(cfail1)]
  742. use super::ReferencedTrait0 as Bound;
  743. #[cfg(not(cfail1))]
  744. use super::ReferencedTrait1 as Bound;
  745. #[rustc_dirty(label="Hir", cfg="cfail2")]
  746. #[rustc_clean(label="Hir", cfg="cfail3")]
  747. trait TraitChangeTraitBound<T: Bound> {
  748. fn method(a: T);
  749. }
  750. }
  751. // Change trait bound of trait type parameter in where clause indirectly
  752. // by modifying a use statement
  753. mod change_method_type_parameter_bound_indirectly_where {
  754. #[cfg(cfail1)]
  755. use super::ReferencedTrait0 as Bound;
  756. #[cfg(not(cfail1))]
  757. use super::ReferencedTrait1 as Bound;
  758. #[rustc_dirty(label="Hir", cfg="cfail2")]
  759. #[rustc_clean(label="Hir", cfg="cfail3")]
  760. trait TraitChangeTraitBoundWhere<T> where T: Bound {
  761. fn method(a: T);
  762. }
  763. }