/src/test/incremental/hashes/inherent_impls.rs

https://gitlab.com/rust-lang/rust · Rust · 790 lines · 463 code · 101 blank · 226 comment · 0 complexity · e255424cc53cf811875ba7613961a5f4 MD5 · raw file

  1. // This test case tests the incremental compilation hash (ICH) implementation
  2. // for let expressions.
  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. // build-pass (FIXME(62277): could be check-pass?)
  7. // revisions: cfail1 cfail2 cfail3 cfail4 cfail5 cfail6
  8. // compile-flags: -Z query-dep-graph -O
  9. // [cfail1]compile-flags: -Zincremental-ignore-spans
  10. // [cfail2]compile-flags: -Zincremental-ignore-spans
  11. // [cfail3]compile-flags: -Zincremental-ignore-spans
  12. // [cfail4]compile-flags: -Zincremental-relative-spans
  13. // [cfail5]compile-flags: -Zincremental-relative-spans
  14. // [cfail6]compile-flags: -Zincremental-relative-spans
  15. #![allow(warnings)]
  16. #![feature(rustc_attrs)]
  17. #![crate_type="rlib"]
  18. pub struct Foo;
  19. // Change Method Name -----------------------------------------------------------
  20. #[cfg(any(cfail1,cfail4))]
  21. impl Foo {
  22. pub fn method_name() { }
  23. }
  24. #[cfg(not(any(cfail1,cfail4)))]
  25. #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,associated_item_def_ids")]
  26. #[rustc_clean(cfg="cfail3")]
  27. #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,associated_item_def_ids")]
  28. #[rustc_clean(cfg="cfail6")]
  29. impl Foo {
  30. #[rustc_clean(cfg="cfail3")]
  31. #[rustc_clean(cfg="cfail6")]
  32. pub fn method_name2() { }
  33. }
  34. // Change Method Body -----------------------------------------------------------
  35. //
  36. // This should affect the method itself, but not the impl.
  37. #[cfg(any(cfail1,cfail4))]
  38. impl Foo {
  39. //--------------------------------------------------------------------------------------
  40. //--------------------------
  41. //--------------------------------------------------------------------------------------
  42. //--------------------------
  43. pub fn method_body() {
  44. // -----------------------
  45. }
  46. }
  47. #[cfg(not(any(cfail1,cfail4)))]
  48. #[rustc_clean(cfg="cfail2")]
  49. #[rustc_clean(cfg="cfail3")]
  50. #[rustc_clean(cfg="cfail5")]
  51. #[rustc_clean(cfg="cfail6")]
  52. impl Foo {
  53. #[rustc_clean(cfg="cfail2", except="hir_owner_nodes,optimized_mir,promoted_mir,typeck")]
  54. #[rustc_clean(cfg="cfail3")]
  55. #[rustc_clean(cfg="cfail5", except="hir_owner_nodes,optimized_mir,promoted_mir,typeck")]
  56. #[rustc_clean(cfg="cfail6")]
  57. pub fn method_body() {
  58. println!("Hello, world!");
  59. }
  60. }
  61. // Change Method Body (inlined) ------------------------------------------------
  62. //
  63. // This should affect the method itself, but not the impl.
  64. #[cfg(any(cfail1,cfail4))]
  65. impl Foo {
  66. //------------
  67. //---------------
  68. //------------------------------------------------------------
  69. //
  70. //--------------------------
  71. //------------
  72. //---------------
  73. //------------------------------------------------------------
  74. //
  75. //--------------------------
  76. #[inline]
  77. pub fn method_body_inlined() {
  78. // -----------------------
  79. }
  80. }
  81. #[cfg(not(any(cfail1,cfail4)))]
  82. #[rustc_clean(cfg="cfail2")]
  83. #[rustc_clean(cfg="cfail3")]
  84. #[rustc_clean(cfg="cfail5")]
  85. #[rustc_clean(cfg="cfail6")]
  86. impl Foo {
  87. #[rustc_clean(
  88. cfg="cfail2",
  89. except="hir_owner_nodes,optimized_mir,promoted_mir,typeck"
  90. )]
  91. #[rustc_clean(cfg="cfail3")]
  92. #[rustc_clean(
  93. cfg="cfail5",
  94. except="hir_owner_nodes,optimized_mir,promoted_mir,typeck"
  95. )]
  96. #[rustc_clean(cfg="cfail6")]
  97. #[inline]
  98. pub fn method_body_inlined() {
  99. println!("Hello, world!");
  100. }
  101. }
  102. // Change Method Privacy -------------------------------------------------------
  103. #[cfg(any(cfail1,cfail4))]
  104. impl Foo {
  105. //----------------------------------------------------
  106. //--------------------------
  107. //------------------------------------------------------------------------------
  108. //--------------------------
  109. pub fn method_privacy() { }
  110. }
  111. #[cfg(not(any(cfail1,cfail4)))]
  112. #[rustc_clean(cfg="cfail2")]
  113. #[rustc_clean(cfg="cfail3")]
  114. #[rustc_clean(cfg="cfail5")]
  115. #[rustc_clean(cfg="cfail6")]
  116. impl Foo {
  117. #[rustc_clean(cfg="cfail2", except="associated_item")]
  118. #[rustc_clean(cfg="cfail3")]
  119. #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,associated_item")]
  120. #[rustc_clean(cfg="cfail6")]
  121. fn method_privacy() { }
  122. }
  123. // Change Method Selfness -----------------------------------------------------------
  124. #[cfg(any(cfail1,cfail4))]
  125. impl Foo {
  126. //------------
  127. //---------------
  128. //---------------------------------------------------------------------------------------------
  129. //
  130. //--------------------------
  131. //------------
  132. //---------------
  133. //---------------------------------------------------------------------------------------------
  134. //
  135. //--------------------------
  136. pub fn method_selfness() { }
  137. }
  138. #[cfg(not(any(cfail1,cfail4)))]
  139. #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes")]
  140. #[rustc_clean(cfg="cfail3")]
  141. #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes")]
  142. #[rustc_clean(cfg="cfail6")]
  143. impl Foo {
  144. #[rustc_clean(
  145. cfg="cfail2",
  146. except="hir_owner,hir_owner_nodes,fn_sig,generics_of,typeck,associated_item,optimized_mir",
  147. )]
  148. #[rustc_clean(cfg="cfail3")]
  149. #[rustc_clean(
  150. cfg="cfail5",
  151. except="hir_owner,hir_owner_nodes,fn_sig,generics_of,typeck,associated_item,optimized_mir",
  152. )]
  153. #[rustc_clean(cfg="cfail6")]
  154. pub fn method_selfness(&self) { }
  155. }
  156. // Change Method Selfmutness ---------------------------------------------------
  157. #[cfg(any(cfail1,cfail4))]
  158. impl Foo {
  159. //------------------------------------------------------------------------------------------
  160. //--------------------------
  161. //------------------------------------------------------------------------------------------
  162. //--------------------------
  163. pub fn method_selfmutness(& self) { }
  164. }
  165. #[cfg(not(any(cfail1,cfail4)))]
  166. #[rustc_clean(cfg="cfail2")]
  167. #[rustc_clean(cfg="cfail3")]
  168. #[rustc_clean(cfg="cfail5")]
  169. #[rustc_clean(cfg="cfail6")]
  170. impl Foo {
  171. #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,fn_sig,typeck,optimized_mir")]
  172. #[rustc_clean(cfg="cfail3")]
  173. #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,fn_sig,typeck,optimized_mir")]
  174. #[rustc_clean(cfg="cfail6")]
  175. pub fn method_selfmutness(&mut self) { }
  176. }
  177. // Add Method To Impl ----------------------------------------------------------
  178. #[cfg(any(cfail1,cfail4))]
  179. impl Foo {
  180. pub fn add_method_to_impl1(&self) { }
  181. }
  182. #[cfg(not(any(cfail1,cfail4)))]
  183. #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,associated_item_def_ids")]
  184. #[rustc_clean(cfg="cfail3")]
  185. #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,associated_item_def_ids")]
  186. #[rustc_clean(cfg="cfail6")]
  187. impl Foo {
  188. #[rustc_clean(cfg="cfail2")]
  189. #[rustc_clean(cfg="cfail3")]
  190. #[rustc_clean(cfg="cfail5")]
  191. #[rustc_clean(cfg="cfail6")]
  192. pub fn add_method_to_impl1(&self) { }
  193. #[rustc_clean(cfg="cfail3")]
  194. #[rustc_clean(cfg="cfail6")]
  195. pub fn add_method_to_impl2(&self) { }
  196. }
  197. // Add Method Parameter --------------------------------------------------------
  198. #[cfg(any(cfail1,cfail4))]
  199. impl Foo {
  200. //------------------------------------------------------------------------------------------
  201. //--------------------------
  202. //------------------------------------------------------------------------------------------
  203. //--------------------------
  204. pub fn add_method_parameter(&self ) { }
  205. }
  206. #[cfg(not(any(cfail1,cfail4)))]
  207. #[rustc_clean(cfg="cfail2")]
  208. #[rustc_clean(cfg="cfail3")]
  209. #[rustc_clean(cfg="cfail5")]
  210. #[rustc_clean(cfg="cfail6")]
  211. impl Foo {
  212. #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,fn_sig,typeck,optimized_mir")]
  213. #[rustc_clean(cfg="cfail3")]
  214. #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,fn_sig,typeck,optimized_mir")]
  215. #[rustc_clean(cfg="cfail6")]
  216. pub fn add_method_parameter(&self, _: i32) { }
  217. }
  218. // Change Method Parameter Name ------------------------------------------------
  219. #[cfg(any(cfail1,cfail4))]
  220. impl Foo {
  221. //------------------------------------------------------------------
  222. //--------------------------
  223. //------------------------------------------------------------------
  224. //--------------------------
  225. pub fn change_method_parameter_name(&self, a: i64) { }
  226. }
  227. #[cfg(not(any(cfail1,cfail4)))]
  228. #[rustc_clean(cfg="cfail2")]
  229. #[rustc_clean(cfg="cfail3")]
  230. #[rustc_clean(cfg="cfail5")]
  231. #[rustc_clean(cfg="cfail6")]
  232. impl Foo {
  233. #[rustc_clean(cfg="cfail2", except="hir_owner_nodes,optimized_mir")]
  234. #[rustc_clean(cfg="cfail3")]
  235. #[rustc_clean(cfg="cfail5", except="hir_owner_nodes,optimized_mir")]
  236. #[rustc_clean(cfg="cfail6")]
  237. pub fn change_method_parameter_name(&self, b: i64) { }
  238. }
  239. // Change Method Return Type ---------------------------------------------------
  240. #[cfg(any(cfail1,cfail4))]
  241. impl Foo {
  242. //------------------------------------------------------------------------------------------
  243. //--------------------------
  244. //------------------------------------------------------------------------------------------
  245. //--------------------------
  246. pub fn change_method_return_type(&self) -> u16 { 0 }
  247. }
  248. #[cfg(not(any(cfail1,cfail4)))]
  249. #[rustc_clean(cfg="cfail2")]
  250. #[rustc_clean(cfg="cfail3")]
  251. #[rustc_clean(cfg="cfail5")]
  252. #[rustc_clean(cfg="cfail6")]
  253. impl Foo {
  254. #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,fn_sig,optimized_mir,typeck")]
  255. #[rustc_clean(cfg="cfail3")]
  256. #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,fn_sig,optimized_mir,typeck")]
  257. #[rustc_clean(cfg="cfail6")]
  258. pub fn change_method_return_type(&self) -> u32 { 0 }
  259. }
  260. // Make Method #[inline] -------------------------------------------------------
  261. #[cfg(any(cfail1,cfail4))]
  262. impl Foo {
  263. //--------------------------
  264. //--------------------------
  265. //--------------------------
  266. //--------------------------
  267. //-------
  268. pub fn make_method_inline(&self) -> u8 { 0 }
  269. }
  270. #[cfg(not(any(cfail1,cfail4)))]
  271. #[rustc_clean(cfg="cfail2")]
  272. #[rustc_clean(cfg="cfail3")]
  273. #[rustc_clean(cfg="cfail5")]
  274. #[rustc_clean(cfg="cfail6")]
  275. impl Foo {
  276. #[rustc_clean(cfg="cfail2")]
  277. #[rustc_clean(cfg="cfail3")]
  278. #[rustc_clean(cfg="cfail5")]
  279. #[rustc_clean(cfg="cfail6")]
  280. #[inline]
  281. pub fn make_method_inline(&self) -> u8 { 0 }
  282. }
  283. // Change order of parameters -------------------------------------------------
  284. #[cfg(any(cfail1,cfail4))]
  285. impl Foo {
  286. //------------------------------------------------------------------
  287. //--------------------------
  288. //------------------------------------------------------------------
  289. //--------------------------
  290. pub fn change_method_parameter_order(&self, a: i64, b: i64) { }
  291. }
  292. #[cfg(not(any(cfail1,cfail4)))]
  293. #[rustc_clean(cfg="cfail2")]
  294. #[rustc_clean(cfg="cfail3")]
  295. #[rustc_clean(cfg="cfail5")]
  296. #[rustc_clean(cfg="cfail6")]
  297. impl Foo {
  298. #[rustc_clean(cfg="cfail2", except="hir_owner_nodes,optimized_mir")]
  299. #[rustc_clean(cfg="cfail3")]
  300. #[rustc_clean(cfg="cfail5", except="hir_owner_nodes,optimized_mir")]
  301. #[rustc_clean(cfg="cfail6")]
  302. pub fn change_method_parameter_order(&self, b: i64, a: i64) { }
  303. }
  304. // Make method unsafe ----------------------------------------------------------
  305. #[cfg(any(cfail1,cfail4))]
  306. impl Foo {
  307. //------------------------------------------------------------------------------------------
  308. //--------------------------
  309. //------------------------------------------------------------------------------------------
  310. //--------------------------
  311. pub fn make_method_unsafe(&self) { }
  312. }
  313. #[cfg(not(any(cfail1,cfail4)))]
  314. #[rustc_clean(cfg="cfail2")]
  315. #[rustc_clean(cfg="cfail3")]
  316. #[rustc_clean(cfg="cfail5")]
  317. #[rustc_clean(cfg="cfail6")]
  318. impl Foo {
  319. #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,fn_sig,typeck,optimized_mir")]
  320. #[rustc_clean(cfg="cfail3")]
  321. #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,fn_sig,typeck,optimized_mir")]
  322. #[rustc_clean(cfg="cfail6")]
  323. pub unsafe fn make_method_unsafe(&self) { }
  324. }
  325. // Make method extern ----------------------------------------------------------
  326. #[cfg(any(cfail1,cfail4))]
  327. impl Foo {
  328. //----------------------------------------------------------------------------
  329. //--------------------------
  330. //----------------------------------------------------------------------------
  331. //--------------------------
  332. pub fn make_method_extern(&self) { }
  333. }
  334. #[cfg(not(any(cfail1,cfail4)))]
  335. #[rustc_clean(cfg="cfail2")]
  336. #[rustc_clean(cfg="cfail3")]
  337. #[rustc_clean(cfg="cfail5")]
  338. #[rustc_clean(cfg="cfail6")]
  339. impl Foo {
  340. #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,fn_sig,typeck")]
  341. #[rustc_clean(cfg="cfail3")]
  342. #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,fn_sig,typeck")]
  343. #[rustc_clean(cfg="cfail6")]
  344. pub extern "C" fn make_method_extern(&self) { }
  345. }
  346. // Change method calling convention --------------------------------------------
  347. #[cfg(any(cfail1,cfail4))]
  348. impl Foo {
  349. //----------------------------------------------------------------------------
  350. //--------------------------
  351. //----------------------------------------------------------------------------
  352. //--------------------------
  353. pub extern "C" fn change_method_calling_convention(&self) { }
  354. }
  355. #[cfg(not(any(cfail1,cfail4)))]
  356. #[rustc_clean(cfg="cfail2")]
  357. #[rustc_clean(cfg="cfail3")]
  358. #[rustc_clean(cfg="cfail5")]
  359. #[rustc_clean(cfg="cfail6")]
  360. impl Foo {
  361. #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,fn_sig,typeck")]
  362. #[rustc_clean(cfg="cfail3")]
  363. #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,fn_sig,typeck")]
  364. #[rustc_clean(cfg="cfail6")]
  365. pub extern "system" fn change_method_calling_convention(&self) { }
  366. }
  367. // Add Lifetime Parameter to Method --------------------------------------------
  368. #[cfg(any(cfail1,cfail4))]
  369. impl Foo {
  370. // -----------------------------------------------------
  371. // ---------------------------------------------------------
  372. // ----------------------------------------------------------
  373. // -------------------------------------------------------
  374. // -------------------------------------------------------
  375. // --------------------------------------------------------
  376. // ----------------------------------------------------------
  377. // -----------------------------------------------------------
  378. // ----------------------------------------------------------
  379. // --------------------------------------------------------------------
  380. // -------------------------
  381. // --------------------------------------------------------------------------------
  382. // -------------------------
  383. pub fn add_lifetime_parameter_to_method (&self) { }
  384. }
  385. #[cfg(not(any(cfail1,cfail4)))]
  386. #[rustc_clean(cfg="cfail2")]
  387. #[rustc_clean(cfg="cfail3")]
  388. #[rustc_clean(cfg="cfail5")]
  389. #[rustc_clean(cfg="cfail6")]
  390. impl Foo {
  391. // Warning: Note that `typeck` are coming up clean here.
  392. // The addition or removal of lifetime parameters that don't
  393. // appear in the arguments or fn body in any way does not, in
  394. // fact, affect the `typeck` in any semantic way (at least
  395. // as of this writing). **However,** altering the order of
  396. // lowering **can** cause it appear to affect the `typeck`:
  397. // if we lower generics before the body, then the `HirId` for
  398. // things in the body will be affected. So if you start to see
  399. // `typeck` appear dirty, that might be the cause. -nmatsakis
  400. #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,fn_sig")]
  401. #[rustc_clean(cfg="cfail3")]
  402. #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,fn_sig,generics_of")]
  403. #[rustc_clean(cfg="cfail6")]
  404. pub fn add_lifetime_parameter_to_method<'a>(&self) { }
  405. }
  406. // Add Type Parameter To Method ------------------------------------------------
  407. #[cfg(any(cfail1,cfail4))]
  408. impl Foo {
  409. // -----------------------------------------------------
  410. // ---------------------------------------------------------------
  411. // -------------------------------------------------------------
  412. // -----------------------------------------------------
  413. // -------------------------------------------------------------
  414. // ---------------------------------------------------
  415. // ------------------------------------------------------------
  416. // ------------------------------------------------------
  417. // -------------------------------------------------
  418. // -----------
  419. // --------------
  420. // ----------------------------------------------------------------------
  421. //
  422. // -------------------------
  423. // -----------
  424. // --------------
  425. // ----------------------------------------------------------------------
  426. //
  427. // -------------------------
  428. pub fn add_type_parameter_to_method (&self) { }
  429. }
  430. #[cfg(not(any(cfail1,cfail4)))]
  431. #[rustc_clean(cfg="cfail2")]
  432. #[rustc_clean(cfg="cfail3")]
  433. #[rustc_clean(cfg="cfail5")]
  434. #[rustc_clean(cfg="cfail6")]
  435. impl Foo {
  436. // Warning: Note that `typeck` are coming up clean here.
  437. // The addition or removal of type parameters that don't appear in
  438. // the arguments or fn body in any way does not, in fact, affect
  439. // the `typeck` in any semantic way (at least as of this
  440. // writing). **However,** altering the order of lowering **can**
  441. // cause it appear to affect the `typeck`: if we lower
  442. // generics before the body, then the `HirId` for things in the
  443. // body will be affected. So if you start to see `typeck`
  444. // appear dirty, that might be the cause. -nmatsakis
  445. #[rustc_clean(
  446. cfg="cfail2",
  447. except="hir_owner,hir_owner_nodes,generics_of,predicates_of,type_of",
  448. )]
  449. #[rustc_clean(cfg="cfail3")]
  450. #[rustc_clean(
  451. cfg="cfail5",
  452. except="hir_owner,hir_owner_nodes,generics_of,predicates_of,type_of",
  453. )]
  454. #[rustc_clean(cfg="cfail6")]
  455. pub fn add_type_parameter_to_method<T>(&self) { }
  456. }
  457. // Add Lifetime Bound to Lifetime Parameter of Method --------------------------
  458. #[cfg(any(cfail1,cfail4))]
  459. impl Foo {
  460. //------------
  461. //---------------
  462. //-----------------------------------------------------------------------------
  463. //
  464. //--------------------------
  465. //------------
  466. //---------------
  467. //-----------------------------------------------------------------------------
  468. //
  469. //--------------------------
  470. pub fn add_lifetime_bound_to_lifetime_param_of_method<'a, 'b >(&self) { }
  471. }
  472. #[cfg(not(any(cfail1,cfail4)))]
  473. #[rustc_clean(cfg="cfail2")]
  474. #[rustc_clean(cfg="cfail3")]
  475. #[rustc_clean(cfg="cfail5")]
  476. #[rustc_clean(cfg="cfail6")]
  477. impl Foo {
  478. #[rustc_clean(
  479. cfg="cfail2",
  480. except="hir_owner,hir_owner_nodes,generics_of,predicates_of,type_of,fn_sig"
  481. )]
  482. #[rustc_clean(cfg="cfail3")]
  483. #[rustc_clean(
  484. cfg="cfail5",
  485. except="hir_owner,hir_owner_nodes,generics_of,predicates_of,type_of,fn_sig"
  486. )]
  487. #[rustc_clean(cfg="cfail6")]
  488. pub fn add_lifetime_bound_to_lifetime_param_of_method<'a, 'b: 'a>(&self) { }
  489. }
  490. // Add Lifetime Bound to Type Parameter of Method ------------------------------
  491. #[cfg(any(cfail1,cfail4))]
  492. impl Foo {
  493. // -----------------------------------------------------
  494. // ----------------------------------------------------------
  495. // -------------------------------------------------------------
  496. // -------------------------------------------------
  497. // -------------------------------------------------------------
  498. // ---------------------------------------------------
  499. // ------------------------------------------------------------
  500. // ------------------------------------------------------
  501. // -------------------------------------------------
  502. // -----------
  503. // --------------
  504. // ----------------------------------------------------------------------------
  505. //
  506. // -------------------------
  507. // -----------
  508. // --------------
  509. // ----------------------------------------------------------------------------
  510. //
  511. // -------------------------
  512. pub fn add_lifetime_bound_to_type_param_of_method<'a, T >(&self) { }
  513. }
  514. #[cfg(not(any(cfail1,cfail4)))]
  515. #[rustc_clean(cfg="cfail2")]
  516. #[rustc_clean(cfg="cfail3")]
  517. #[rustc_clean(cfg="cfail5")]
  518. #[rustc_clean(cfg="cfail6")]
  519. impl Foo {
  520. // Warning: Note that `typeck` are coming up clean here.
  521. // The addition or removal of bounds that don't appear in the
  522. // arguments or fn body in any way does not, in fact, affect the
  523. // `typeck` in any semantic way (at least as of this
  524. // writing). **However,** altering the order of lowering **can**
  525. // cause it appear to affect the `typeck`: if we lower
  526. // generics before the body, then the `HirId` for things in the
  527. // body will be affected. So if you start to see `typeck`
  528. // appear dirty, that might be the cause. -nmatsakis
  529. #[rustc_clean(
  530. cfg="cfail2",
  531. except="hir_owner,hir_owner_nodes,generics_of,predicates_of,type_of,fn_sig"
  532. )]
  533. #[rustc_clean(cfg="cfail3")]
  534. #[rustc_clean(
  535. cfg="cfail5",
  536. except="hir_owner,hir_owner_nodes,generics_of,predicates_of,type_of,fn_sig"
  537. )]
  538. #[rustc_clean(cfg="cfail6")]
  539. pub fn add_lifetime_bound_to_type_param_of_method<'a, T: 'a>(&self) { }
  540. }
  541. // Add Trait Bound to Type Parameter of Method ------------------------------
  542. #[cfg(any(cfail1,cfail4))]
  543. impl Foo {
  544. // -----------------------------------------------------
  545. // ----------------------------------------------------------
  546. // -------------------------------------------------------------
  547. // -------------------------------------------------
  548. // -------------------------------------------------------------
  549. // ---------------------------------------------------
  550. // ------------------------------------------------------------
  551. // ------------------------------------------------------
  552. // -------------------------------------------------
  553. // ---------------------------------------------------------------------------
  554. // -------------------------
  555. // ---------------------------------------------------------------------------
  556. // -------------------------
  557. pub fn add_trait_bound_to_type_param_of_method<T >(&self) { }
  558. }
  559. #[cfg(not(any(cfail1,cfail4)))]
  560. #[rustc_clean(cfg="cfail2")]
  561. #[rustc_clean(cfg="cfail3")]
  562. #[rustc_clean(cfg="cfail5")]
  563. #[rustc_clean(cfg="cfail6")]
  564. impl Foo {
  565. // Warning: Note that `typeck` are coming up clean here.
  566. // The addition or removal of bounds that don't appear in the
  567. // arguments or fn body in any way does not, in fact, affect the
  568. // `typeck` in any semantic way (at least as of this
  569. // writing). **However,** altering the order of lowering **can**
  570. // cause it appear to affect the `typeck`: if we lower
  571. // generics before the body, then the `HirId` for things in the
  572. // body will be affected. So if you start to see `typeck`
  573. // appear dirty, that might be the cause. -nmatsakis
  574. #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,predicates_of")]
  575. #[rustc_clean(cfg="cfail3")]
  576. #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,predicates_of")]
  577. #[rustc_clean(cfg="cfail6")]
  578. pub fn add_trait_bound_to_type_param_of_method<T: Clone>(&self) { }
  579. }
  580. // Add #[no_mangle] to Method --------------------------------------------------
  581. #[cfg(any(cfail1,cfail4))]
  582. impl Foo {
  583. //--------------------------
  584. //--------------------------
  585. //--------------------------
  586. //--------------------------
  587. //----------
  588. pub fn add_no_mangle_to_method(&self) { }
  589. }
  590. #[cfg(not(any(cfail1,cfail4)))]
  591. #[rustc_clean(cfg="cfail2")]
  592. #[rustc_clean(cfg="cfail3")]
  593. #[rustc_clean(cfg="cfail5")]
  594. #[rustc_clean(cfg="cfail6")]
  595. impl Foo {
  596. #[rustc_clean(cfg="cfail2")]
  597. #[rustc_clean(cfg="cfail3")]
  598. #[rustc_clean(cfg="cfail5")]
  599. #[rustc_clean(cfg="cfail6")]
  600. #[no_mangle]
  601. pub fn add_no_mangle_to_method(&self) { }
  602. }
  603. struct Bar<T>(T);
  604. // Add Type Parameter To Impl --------------------------------------------------
  605. #[cfg(any(cfail1,cfail4))]
  606. impl Bar<u32> {
  607. pub fn add_type_parameter_to_impl(&self) { }
  608. }
  609. #[cfg(not(any(cfail1,cfail4)))]
  610. #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,generics_of")]
  611. #[rustc_clean(cfg="cfail3")]
  612. #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,generics_of")]
  613. #[rustc_clean(cfg="cfail6")]
  614. impl<T> Bar<T> {
  615. #[rustc_clean(
  616. cfg="cfail2",
  617. except="generics_of,fn_sig,typeck,type_of,optimized_mir"
  618. )]
  619. #[rustc_clean(cfg="cfail3")]
  620. #[rustc_clean(
  621. cfg="cfail5",
  622. except="generics_of,fn_sig,typeck,type_of,optimized_mir"
  623. )]
  624. #[rustc_clean(cfg="cfail6")]
  625. pub fn add_type_parameter_to_impl(&self) { }
  626. }
  627. // Change Self Type of Impl ----------------------------------------------------
  628. #[cfg(any(cfail1,cfail4))]
  629. impl Bar<u32> {
  630. pub fn change_impl_self_type(&self) { }
  631. }
  632. #[cfg(not(any(cfail1,cfail4)))]
  633. #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes")]
  634. #[rustc_clean(cfg="cfail3")]
  635. #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes")]
  636. #[rustc_clean(cfg="cfail6")]
  637. impl Bar<u64> {
  638. #[rustc_clean(cfg="cfail2", except="fn_sig,optimized_mir,typeck")]
  639. #[rustc_clean(cfg="cfail3")]
  640. #[rustc_clean(cfg="cfail5", except="fn_sig,optimized_mir,typeck")]
  641. #[rustc_clean(cfg="cfail6")]
  642. pub fn change_impl_self_type(&self) { }
  643. }
  644. // Add Lifetime Bound to Impl --------------------------------------------------
  645. #[cfg(any(cfail1,cfail4))]
  646. impl<T> Bar<T> {
  647. pub fn add_lifetime_bound_to_impl_parameter(&self) { }
  648. }
  649. #[cfg(not(any(cfail1,cfail4)))]
  650. #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes")]
  651. #[rustc_clean(cfg="cfail3")]
  652. #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes")]
  653. #[rustc_clean(cfg="cfail6")]
  654. impl<T: 'static> Bar<T> {
  655. #[rustc_clean(cfg="cfail2")]
  656. #[rustc_clean(cfg="cfail3")]
  657. #[rustc_clean(cfg="cfail5")]
  658. #[rustc_clean(cfg="cfail6")]
  659. pub fn add_lifetime_bound_to_impl_parameter(&self) { }
  660. }
  661. // Add Trait Bound to Impl Parameter -------------------------------------------
  662. #[cfg(any(cfail1,cfail4))]
  663. impl<T> Bar<T> {
  664. pub fn add_trait_bound_to_impl_parameter(&self) { }
  665. }
  666. #[cfg(not(any(cfail1,cfail4)))]
  667. #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes")]
  668. #[rustc_clean(cfg="cfail3")]
  669. #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes")]
  670. #[rustc_clean(cfg="cfail6")]
  671. impl<T: Clone> Bar<T> {
  672. #[rustc_clean(cfg="cfail2")]
  673. #[rustc_clean(cfg="cfail3")]
  674. #[rustc_clean(cfg="cfail5")]
  675. #[rustc_clean(cfg="cfail6")]
  676. pub fn add_trait_bound_to_impl_parameter(&self) { }
  677. }
  678. // Force instantiation of some fns so we can check their hash.
  679. pub fn instantiation_root() {
  680. Foo::method_privacy();
  681. #[cfg(any(cfail1,cfail4))]
  682. {
  683. Bar(0u32).change_impl_self_type();
  684. }
  685. #[cfg(not(any(cfail1,cfail4)))]
  686. {
  687. Bar(0u64).change_impl_self_type();
  688. }
  689. }