This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +42
-4
lines changed Expand file tree Collapse file tree 4 files changed +42
-4
lines changed Original file line number Diff line number Diff line change @@ -179,6 +179,26 @@ impl rustc_driver::Callbacks for MiriBeRustCompilerCalls {
179179 } ) ;
180180 }
181181 }
182+
183+ fn after_analysis < ' tcx > (
184+ & mut self ,
185+ _: & rustc_interface:: interface:: Compiler ,
186+ queries : & ' tcx rustc_interface:: Queries < ' tcx > ,
187+ ) -> Compilation {
188+ queries. global_ctxt ( ) . unwrap ( ) . enter ( |tcx| {
189+ if self . target_crate {
190+ // cargo-miri has patched the compiler flags to make these into check-only builds,
191+ // but we are still emulating regular rustc builds, which would perform post-mono
192+ // const-eval during collection. So let's also do that here, even if we might be
193+ // running with `--emit=metadata`. In particular this is needed to make
194+ // `compile_fail` doc tests trigger post-mono errors.
195+ // In general `collect_and_partition_mono_items` is not safe to call in check-only
196+ // builds, but we are setting `-Zalways-encode-mir` which avoids those issues.
197+ let _ = tcx. collect_and_partition_mono_items ( ( ) ) ;
198+ }
199+ } ) ;
200+ Compilation :: Continue
201+ }
182202}
183203
184204fn show_error ( msg : & impl std:: fmt:: Display ) -> ! {
Original file line number Diff line number Diff line change 11/// Doc-test test
2+ ///
23/// ```rust
34/// assert!(cargo_miri_test::make_true());
45/// ```
6+ ///
7+ /// `no_run` test:
8+ ///
59/// ```rust,no_run
610/// assert!(!cargo_miri_test::make_true());
711/// ```
12+ ///
13+ /// `compile_fail` test:
14+ ///
815/// ```rust,compile_fail
916/// assert!(cargo_miri_test::make_true() == 5);
1017/// ```
18+ ///
19+ /// Post-monomorphization error in `compile_fail` test:
20+ ///
21+ /// ```rust,compile_fail
22+ /// struct Fail<T>(T);
23+ /// impl<T> Fail<T> {
24+ /// const C: () = panic!();
25+ /// }
26+ ///
27+ /// let _val = Fail::<i32>::C;
28+ /// ```
1129#[ no_mangle]
1230pub fn make_true ( ) -> bool {
1331 issue_1567:: use_the_dependency ( ) ;
Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ running 6 tests
1010test result: ok. 5 passed; 0 failed; 1 ignored; 0 measured; 0 filtered out
1111
1212
13- running 4 tests
14- ....
15- test result: ok. 4 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME
13+ running 5 tests
14+ .....
15+ test result: ok. 5 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME
1616
Original file line number Diff line number Diff line change @@ -13,5 +13,5 @@ test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 5 filtered out
1313
1414running 0 tests
1515
16- test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 4 filtered out; finished in $TIME
16+ test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 5 filtered out; finished in $TIME
1717
You can’t perform that action at this time.
0 commit comments