Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Continue evaluating after missing main #59903

Merged
merged 1 commit into from
Apr 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/librustc/middle/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@ fn configure_main(
err.span_note(span, "here is a function named 'main'");
}
err.emit();
tcx.sess.abort_if_errors();
} else {
if let Some(ref filename) = tcx.sess.local_crate_source_file {
err.note(&format!("consider adding a `main` function to `{}`", filename.display()));
Expand Down
8 changes: 6 additions & 2 deletions src/librustc_interface/passes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -888,10 +888,11 @@ fn analysis<'tcx>(
assert_eq!(cnum, LOCAL_CRATE);

let sess = tcx.sess;
let mut entry_point = None;

time(sess, "misc checking 1", || {
parallel!({
time(sess, "looking for entry point", || {
entry_point = time(sess, "looking for entry point", || {
middle::entry::find_entry_point(tcx)
});

Expand Down Expand Up @@ -939,7 +940,10 @@ fn analysis<'tcx>(

// Abort so we don't try to construct MIR with liveness errors.
// We also won't want to continue with errors from rvalue promotion
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well, we actually want to, but that's not really a problem of this PR. Have you checked how bad the fallout is if we remove this abort_if_errors?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe that there were some useless errors coming from const evaluation, but those might have come from removing the later check at https://github.com/rust-lang/rust/pull/59903/files/13a05a27e9a5747cad090b1670c0a6b0baa624b9#diff-24c5c945888bb0d041e769bfb852de6cR976

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you check? I'd rather remove it entirely. Const eval should not evaluate MIR with typeck errors or borrowck errors.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@oli-obk most of the extra errors are not too bad, but src/test/ui/consts/match_ice.rs starts ICEing again. I'll need to dig deeper to fix the ICE and would like to remove the duplicated errors/warnings before merging that change, but it is certainly doable.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm... Those look like deeper issues to me where some things should be querified more or just produce dummy values in case of errors. Please open an issue linking to the fallout of 8395dbd and mentioning the problems.

tcx.sess.abort_if_errors();
// We only do so if the only error found so far *isn't* a missing `fn main()`
if !(entry_point.is_none() && sess.err_count() == 1) {
tcx.sess.abort_if_errors();
}

time(sess, "borrow checking", || {
if tcx.use_ast_borrowck() {
Expand Down
32 changes: 32 additions & 0 deletions src/test/ui/continue-after-missing-main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#![allow(dead_code)]

// error-pattern:`main` function not found in crate

struct Tableau<'a, MP> {
provider: &'a MP,
}

impl<'adapted_matrix_provider, 'original_data, MP>
Tableau<'adapted_matrix_provider, AdaptedMatrixProvider<'original_data, MP>>
{
fn provider(&self) -> &'adapted_matrix_provider AdaptedMatrixProvider</*'original_data,*/ MP> {
self.provider
}
}

struct AdaptedMatrixProvider<'a, T> {
original_problem: &'a T,
}

impl<'a, T> AdaptedMatrixProvider<'a, T> {
fn clone_with_extra_bound(&self) -> Self {
AdaptedMatrixProvider { original_problem: self.original_problem }
}
}

fn create_and_solve_subproblems<'data_provider, 'original_data, MP>(
tableau: Tableau<'data_provider, AdaptedMatrixProvider<'original_data, MP>>,
) {
let _: AdaptedMatrixProvider<'original_data, MP> = tableau.provider().clone_with_extra_bound();
//~^ ERROR lifetime mismatch
}
17 changes: 17 additions & 0 deletions src/test/ui/continue-after-missing-main.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
error[E0601]: `main` function not found in crate `continue_after_missing_main`
|
= note: consider adding a `main` function to `$DIR/continue-after-missing-main.rs`

error[E0623]: lifetime mismatch
--> $DIR/continue-after-missing-main.rs:30:56
|
LL | tableau: Tableau<'data_provider, AdaptedMatrixProvider<'original_data, MP>>,
| ------------------------------------------------------------------ these two types are declared with different lifetimes...
LL | ) {
LL | let _: AdaptedMatrixProvider<'original_data, MP> = tableau.provider().clone_with_extra_bound();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ...but data from `tableau` flows into `tableau` here

error: aborting due to 2 previous errors

Some errors occurred: E0601, E0623.
For more information about an error, try `rustc --explain E0601`.