Skip to content

Commit 82bfd8e

Browse files
middle::entry -> rustc_passes
1 parent bb70782 commit 82bfd8e

File tree

6 files changed

+92
-86
lines changed

6 files changed

+92
-86
lines changed

src/librustc/error_codes.rs

-75
Original file line numberDiff line numberDiff line change
@@ -466,66 +466,6 @@ fn main() {
466466
```
467467
"##,
468468

469-
// This shouldn't really ever trigger since the repeated value error comes first
470-
E0136: r##"
471-
A binary can only have one entry point, and by default that entry point is the
472-
function `main()`. If there are multiple such functions, please rename one.
473-
"##,
474-
475-
E0137: r##"
476-
More than one function was declared with the `#[main]` attribute.
477-
478-
Erroneous code example:
479-
480-
```compile_fail,E0137
481-
#![feature(main)]
482-
483-
#[main]
484-
fn foo() {}
485-
486-
#[main]
487-
fn f() {} // error: multiple functions with a `#[main]` attribute
488-
```
489-
490-
This error indicates that the compiler found multiple functions with the
491-
`#[main]` attribute. This is an error because there must be a unique entry
492-
point into a Rust program. Example:
493-
494-
```
495-
#![feature(main)]
496-
497-
#[main]
498-
fn f() {} // ok!
499-
```
500-
"##,
501-
502-
E0138: r##"
503-
More than one function was declared with the `#[start]` attribute.
504-
505-
Erroneous code example:
506-
507-
```compile_fail,E0138
508-
#![feature(start)]
509-
510-
#[start]
511-
fn foo(argc: isize, argv: *const *const u8) -> isize {}
512-
513-
#[start]
514-
fn f(argc: isize, argv: *const *const u8) -> isize {}
515-
// error: multiple 'start' functions
516-
```
517-
518-
This error indicates that the compiler found multiple functions with the
519-
`#[start]` attribute. This is an error because there must be a unique entry
520-
point into a Rust program. Example:
521-
522-
```
523-
#![feature(start)]
524-
525-
#[start]
526-
fn foo(argc: isize, argv: *const *const u8) -> isize { 0 } // ok!
527-
```
528-
"##,
529469

530470
E0139: r##"
531471
#### Note: this error code is no longer emitted by the compiler.
@@ -1941,21 +1881,6 @@ fn main() {
19411881
```
19421882
"##,
19431883

1944-
E0601: r##"
1945-
No `main` function was found in a binary crate. To fix this error, add a
1946-
`main` function. For example:
1947-
1948-
```
1949-
fn main() {
1950-
// Your program will start here.
1951-
println!("Hello world!");
1952-
}
1953-
```
1954-
1955-
If you don't know the basics of Rust, you can go look to the Rust Book to get
1956-
started: https://doc.rust-lang.org/book/
1957-
"##,
1958-
19591884
E0602: r##"
19601885
An unknown lint was used on the command line.
19611886

src/librustc/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@ pub mod middle {
104104
pub mod cstore;
105105
pub mod dependency_format;
106106
pub mod diagnostic_items;
107-
pub mod entry;
108107
pub mod exported_symbols;
109108
pub mod free_region;
110109
pub mod intrinsicck;

src/librustc_interface/passes.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -785,7 +785,6 @@ pub fn default_provide(providers: &mut ty::query::Providers<'_>) {
785785
rustc_passes::provide(providers);
786786
rustc_traits::provide(providers);
787787
middle::region::provide(providers);
788-
middle::entry::provide(providers);
789788
cstore::provide(providers);
790789
lint::provide(providers);
791790
rustc_lint::provide(providers);
@@ -891,7 +890,7 @@ fn analysis(tcx: TyCtxt<'_>, cnum: CrateNum) -> Result<()> {
891890
time(sess, "misc checking 1", || {
892891
parallel!({
893892
entry_point = time(sess, "looking for entry point", || {
894-
middle::entry::find_entry_point(tcx)
893+
rustc_passes::entry::find_entry_point(tcx)
895894
});
896895

897896
time(sess, "looking for plugin registrar", || {

src/librustc/middle/entry.rs renamed to src/librustc_passes/entry.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
use crate::hir::map as hir_map;
2-
use crate::hir::def_id::{CrateNum, CRATE_DEF_INDEX, DefId, LOCAL_CRATE};
3-
use crate::session::{config, Session};
4-
use crate::session::config::EntryFnType;
1+
use rustc::hir::map as hir_map;
2+
use rustc::hir::def_id::{CrateNum, CRATE_DEF_INDEX, DefId, LOCAL_CRATE};
3+
use rustc::session::{config, Session};
4+
use rustc::session::config::EntryFnType;
55
use syntax::attr;
66
use syntax::entry::EntryPointType;
77
use syntax::symbol::sym;
88
use syntax_pos::Span;
9-
use crate::hir::{HirId, Item, ItemKind, ImplItem, TraitItem};
10-
use crate::hir::itemlikevisit::ItemLikeVisitor;
11-
use crate::ty::TyCtxt;
12-
use crate::ty::query::Providers;
9+
use rustc::hir::{HirId, Item, ItemKind, ImplItem, TraitItem};
10+
use rustc::hir::itemlikevisit::ItemLikeVisitor;
11+
use rustc::ty::TyCtxt;
12+
use rustc::ty::query::Providers;
1313

1414
struct EntryContext<'a, 'tcx> {
1515
session: &'a Session,

src/librustc_passes/error_codes.rs

+77
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,83 @@ async fn foo() {}
319319
320320
Switch to the Rust 2018 edition to use `async fn`.
321321
"##,
322+
323+
// This shouldn't really ever trigger since the repeated value error comes first
324+
E0136: r##"
325+
A binary can only have one entry point, and by default that entry point is the
326+
function `main()`. If there are multiple such functions, please rename one.
327+
"##,
328+
329+
E0137: r##"
330+
More than one function was declared with the `#[main]` attribute.
331+
332+
Erroneous code example:
333+
334+
```compile_fail,E0137
335+
#![feature(main)]
336+
337+
#[main]
338+
fn foo() {}
339+
340+
#[main]
341+
fn f() {} // error: multiple functions with a `#[main]` attribute
342+
```
343+
344+
This error indicates that the compiler found multiple functions with the
345+
`#[main]` attribute. This is an error because there must be a unique entry
346+
point into a Rust program. Example:
347+
348+
```
349+
#![feature(main)]
350+
351+
#[main]
352+
fn f() {} // ok!
353+
```
354+
"##,
355+
356+
E0138: r##"
357+
More than one function was declared with the `#[start]` attribute.
358+
359+
Erroneous code example:
360+
361+
```compile_fail,E0138
362+
#![feature(start)]
363+
364+
#[start]
365+
fn foo(argc: isize, argv: *const *const u8) -> isize {}
366+
367+
#[start]
368+
fn f(argc: isize, argv: *const *const u8) -> isize {}
369+
// error: multiple 'start' functions
370+
```
371+
372+
This error indicates that the compiler found multiple functions with the
373+
`#[start]` attribute. This is an error because there must be a unique entry
374+
point into a Rust program. Example:
375+
376+
```
377+
#![feature(start)]
378+
379+
#[start]
380+
fn foo(argc: isize, argv: *const *const u8) -> isize { 0 } // ok!
381+
```
382+
"##,
383+
384+
E0601: r##"
385+
No `main` function was found in a binary crate. To fix this error, add a
386+
`main` function. For example:
387+
388+
```
389+
fn main() {
390+
// Your program will start here.
391+
println!("Hello world!");
392+
}
393+
```
394+
395+
If you don't know the basics of Rust, you can go look to the Rust Book to get
396+
started: https://doc.rust-lang.org/book/
397+
"##,
398+
322399
;
323400
E0226, // only a single explicit lifetime bound is permitted
324401
E0472, // asm! is unsupported on this target

src/librustc_passes/lib.rs

+6
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313

1414
#[macro_use]
1515
extern crate rustc;
16+
#[macro_use]
17+
extern crate log;
18+
#[macro_use]
19+
extern crate syntax;
1620

1721
use rustc::ty::query::Providers;
1822

@@ -23,9 +27,11 @@ pub mod hir_stats;
2327
pub mod layout_test;
2428
pub mod loops;
2529
pub mod dead;
30+
pub mod entry;
2631
mod liveness;
2732

2833
pub fn provide(providers: &mut Providers<'_>) {
34+
entry::provide(providers);
2935
loops::provide(providers);
3036
liveness::provide(providers);
3137
}

0 commit comments

Comments
 (0)