Skip to content

Commit

Permalink
middle::entry -> rustc_passes
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark-Simulacrum committed Oct 4, 2019
1 parent bb70782 commit 82bfd8e
Show file tree
Hide file tree
Showing 6 changed files with 92 additions and 86 deletions.
75 changes: 0 additions & 75 deletions src/librustc/error_codes.rs
Expand Up @@ -466,66 +466,6 @@ fn main() {
```
"##,

// This shouldn't really ever trigger since the repeated value error comes first
E0136: r##"
A binary can only have one entry point, and by default that entry point is the
function `main()`. If there are multiple such functions, please rename one.
"##,

E0137: r##"
More than one function was declared with the `#[main]` attribute.
Erroneous code example:
```compile_fail,E0137
#![feature(main)]
#[main]
fn foo() {}
#[main]
fn f() {} // error: multiple functions with a `#[main]` attribute
```
This error indicates that the compiler found multiple functions with the
`#[main]` attribute. This is an error because there must be a unique entry
point into a Rust program. Example:
```
#![feature(main)]
#[main]
fn f() {} // ok!
```
"##,

E0138: r##"
More than one function was declared with the `#[start]` attribute.
Erroneous code example:
```compile_fail,E0138
#![feature(start)]
#[start]
fn foo(argc: isize, argv: *const *const u8) -> isize {}
#[start]
fn f(argc: isize, argv: *const *const u8) -> isize {}
// error: multiple 'start' functions
```
This error indicates that the compiler found multiple functions with the
`#[start]` attribute. This is an error because there must be a unique entry
point into a Rust program. Example:
```
#![feature(start)]
#[start]
fn foo(argc: isize, argv: *const *const u8) -> isize { 0 } // ok!
```
"##,

E0139: r##"
#### Note: this error code is no longer emitted by the compiler.
Expand Down Expand Up @@ -1941,21 +1881,6 @@ fn main() {
```
"##,

E0601: r##"
No `main` function was found in a binary crate. To fix this error, add a
`main` function. For example:
```
fn main() {
// Your program will start here.
println!("Hello world!");
}
```
If you don't know the basics of Rust, you can go look to the Rust Book to get
started: https://doc.rust-lang.org/book/
"##,

E0602: r##"
An unknown lint was used on the command line.
Expand Down
1 change: 0 additions & 1 deletion src/librustc/lib.rs
Expand Up @@ -104,7 +104,6 @@ pub mod middle {
pub mod cstore;
pub mod dependency_format;
pub mod diagnostic_items;
pub mod entry;
pub mod exported_symbols;
pub mod free_region;
pub mod intrinsicck;
Expand Down
3 changes: 1 addition & 2 deletions src/librustc_interface/passes.rs
Expand Up @@ -785,7 +785,6 @@ pub fn default_provide(providers: &mut ty::query::Providers<'_>) {
rustc_passes::provide(providers);
rustc_traits::provide(providers);
middle::region::provide(providers);
middle::entry::provide(providers);
cstore::provide(providers);
lint::provide(providers);
rustc_lint::provide(providers);
Expand Down Expand Up @@ -891,7 +890,7 @@ fn analysis(tcx: TyCtxt<'_>, cnum: CrateNum) -> Result<()> {
time(sess, "misc checking 1", || {
parallel!({
entry_point = time(sess, "looking for entry point", || {
middle::entry::find_entry_point(tcx)
rustc_passes::entry::find_entry_point(tcx)
});

time(sess, "looking for plugin registrar", || {
Expand Down
16 changes: 8 additions & 8 deletions src/librustc/middle/entry.rs → src/librustc_passes/entry.rs
@@ -1,15 +1,15 @@
use crate::hir::map as hir_map;
use crate::hir::def_id::{CrateNum, CRATE_DEF_INDEX, DefId, LOCAL_CRATE};
use crate::session::{config, Session};
use crate::session::config::EntryFnType;
use rustc::hir::map as hir_map;
use rustc::hir::def_id::{CrateNum, CRATE_DEF_INDEX, DefId, LOCAL_CRATE};
use rustc::session::{config, Session};
use rustc::session::config::EntryFnType;
use syntax::attr;
use syntax::entry::EntryPointType;
use syntax::symbol::sym;
use syntax_pos::Span;
use crate::hir::{HirId, Item, ItemKind, ImplItem, TraitItem};
use crate::hir::itemlikevisit::ItemLikeVisitor;
use crate::ty::TyCtxt;
use crate::ty::query::Providers;
use rustc::hir::{HirId, Item, ItemKind, ImplItem, TraitItem};
use rustc::hir::itemlikevisit::ItemLikeVisitor;
use rustc::ty::TyCtxt;
use rustc::ty::query::Providers;

struct EntryContext<'a, 'tcx> {
session: &'a Session,
Expand Down
77 changes: 77 additions & 0 deletions src/librustc_passes/error_codes.rs
Expand Up @@ -319,6 +319,83 @@ async fn foo() {}
Switch to the Rust 2018 edition to use `async fn`.
"##,

// This shouldn't really ever trigger since the repeated value error comes first
E0136: r##"
A binary can only have one entry point, and by default that entry point is the
function `main()`. If there are multiple such functions, please rename one.
"##,

E0137: r##"
More than one function was declared with the `#[main]` attribute.
Erroneous code example:
```compile_fail,E0137
#![feature(main)]
#[main]
fn foo() {}
#[main]
fn f() {} // error: multiple functions with a `#[main]` attribute
```
This error indicates that the compiler found multiple functions with the
`#[main]` attribute. This is an error because there must be a unique entry
point into a Rust program. Example:
```
#![feature(main)]
#[main]
fn f() {} // ok!
```
"##,

E0138: r##"
More than one function was declared with the `#[start]` attribute.
Erroneous code example:
```compile_fail,E0138
#![feature(start)]
#[start]
fn foo(argc: isize, argv: *const *const u8) -> isize {}
#[start]
fn f(argc: isize, argv: *const *const u8) -> isize {}
// error: multiple 'start' functions
```
This error indicates that the compiler found multiple functions with the
`#[start]` attribute. This is an error because there must be a unique entry
point into a Rust program. Example:
```
#![feature(start)]
#[start]
fn foo(argc: isize, argv: *const *const u8) -> isize { 0 } // ok!
```
"##,

E0601: r##"
No `main` function was found in a binary crate. To fix this error, add a
`main` function. For example:
```
fn main() {
// Your program will start here.
println!("Hello world!");
}
```
If you don't know the basics of Rust, you can go look to the Rust Book to get
started: https://doc.rust-lang.org/book/
"##,

;
E0226, // only a single explicit lifetime bound is permitted
E0472, // asm! is unsupported on this target
Expand Down
6 changes: 6 additions & 0 deletions src/librustc_passes/lib.rs
Expand Up @@ -13,6 +13,10 @@

#[macro_use]
extern crate rustc;
#[macro_use]
extern crate log;
#[macro_use]
extern crate syntax;

use rustc::ty::query::Providers;

Expand All @@ -23,9 +27,11 @@ pub mod hir_stats;
pub mod layout_test;
pub mod loops;
pub mod dead;
pub mod entry;
mod liveness;

pub fn provide(providers: &mut Providers<'_>) {
entry::provide(providers);
loops::provide(providers);
liveness::provide(providers);
}

0 comments on commit 82bfd8e

Please sign in to comment.