Skip to content

Commit a49deb8

Browse files
authored
Rollup merge of rust-lang#59903 - estebank:after-main, r=oli-obk
Continue evaluating after missing main
2 parents 5522392 + 13a05a2 commit a49deb8

File tree

4 files changed

+55
-3
lines changed

4 files changed

+55
-3
lines changed

src/librustc/middle/entry.rs

-1
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,6 @@ fn configure_main(
163163
err.span_note(span, "here is a function named 'main'");
164164
}
165165
err.emit();
166-
tcx.sess.abort_if_errors();
167166
} else {
168167
if let Some(ref filename) = tcx.sess.local_crate_source_file {
169168
err.note(&format!("consider adding a `main` function to `{}`", filename.display()));

src/librustc_interface/passes.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -886,10 +886,11 @@ fn analysis<'tcx>(
886886
assert_eq!(cnum, LOCAL_CRATE);
887887

888888
let sess = tcx.sess;
889+
let mut entry_point = None;
889890

890891
time(sess, "misc checking 1", || {
891892
parallel!({
892-
time(sess, "looking for entry point", || {
893+
entry_point = time(sess, "looking for entry point", || {
893894
middle::entry::find_entry_point(tcx)
894895
});
895896

@@ -937,7 +938,10 @@ fn analysis<'tcx>(
937938

938939
// Abort so we don't try to construct MIR with liveness errors.
939940
// We also won't want to continue with errors from rvalue promotion
940-
tcx.sess.abort_if_errors();
941+
// We only do so if the only error found so far *isn't* a missing `fn main()`
942+
if !(entry_point.is_none() && sess.err_count() == 1) {
943+
tcx.sess.abort_if_errors();
944+
}
941945

942946
time(sess, "borrow checking", || {
943947
if tcx.use_ast_borrowck() {
+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#![allow(dead_code)]
2+
3+
// error-pattern:`main` function not found in crate
4+
5+
struct Tableau<'a, MP> {
6+
provider: &'a MP,
7+
}
8+
9+
impl<'adapted_matrix_provider, 'original_data, MP>
10+
Tableau<'adapted_matrix_provider, AdaptedMatrixProvider<'original_data, MP>>
11+
{
12+
fn provider(&self) -> &'adapted_matrix_provider AdaptedMatrixProvider</*'original_data,*/ MP> {
13+
self.provider
14+
}
15+
}
16+
17+
struct AdaptedMatrixProvider<'a, T> {
18+
original_problem: &'a T,
19+
}
20+
21+
impl<'a, T> AdaptedMatrixProvider<'a, T> {
22+
fn clone_with_extra_bound(&self) -> Self {
23+
AdaptedMatrixProvider { original_problem: self.original_problem }
24+
}
25+
}
26+
27+
fn create_and_solve_subproblems<'data_provider, 'original_data, MP>(
28+
tableau: Tableau<'data_provider, AdaptedMatrixProvider<'original_data, MP>>,
29+
) {
30+
let _: AdaptedMatrixProvider<'original_data, MP> = tableau.provider().clone_with_extra_bound();
31+
//~^ ERROR lifetime mismatch
32+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
error[E0601]: `main` function not found in crate `continue_after_missing_main`
2+
|
3+
= note: consider adding a `main` function to `$DIR/continue-after-missing-main.rs`
4+
5+
error[E0623]: lifetime mismatch
6+
--> $DIR/continue-after-missing-main.rs:30:56
7+
|
8+
LL | tableau: Tableau<'data_provider, AdaptedMatrixProvider<'original_data, MP>>,
9+
| ------------------------------------------------------------------ these two types are declared with different lifetimes...
10+
LL | ) {
11+
LL | let _: AdaptedMatrixProvider<'original_data, MP> = tableau.provider().clone_with_extra_bound();
12+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ...but data from `tableau` flows into `tableau` here
13+
14+
error: aborting due to 2 previous errors
15+
16+
Some errors occurred: E0601, E0623.
17+
For more information about an error, try `rustc --explain E0601`.

0 commit comments

Comments
 (0)