Various tweaks

This commit is contained in:
Esteban Küber 2017-12-19 19:53:39 -08:00
parent 8749250327
commit eed98d55fb
12 changed files with 42 additions and 49 deletions

View File

@ -170,7 +170,7 @@ fn configure_main(this: &mut EntryContext) {
defined at the crate level. Either move the definition or \ defined at the crate level. Either move the definition or \
attach the `#[main]` attribute to override this behavior."); attach the `#[main]` attribute to override this behavior.");
for &(_, span) in &this.non_main_fns { for &(_, span) in &this.non_main_fns {
err.span_label(span, "here is a function named 'main'"); err.span_note(span, "here is a function named 'main'");
} }
err.emit(); err.emit();
this.session.abort_if_errors(); this.session.abort_if_errors();

View File

@ -402,8 +402,8 @@ fn check_arms<'a, 'tcx>(cx: &mut MatchCheckCtxt<'a, 'tcx>,
); );
// if we had a catchall pattern, hint at that // if we had a catchall pattern, hint at that
if let Some(catchall) = catchall { if let Some(catchall) = catchall {
err.span_label(pat.span, "this is an unreachable pattern"); err.span_label(pat.span, "unreachable pattern");
err.span_label(catchall, "this pattern matches any value"); err.span_label(catchall, "matches any value");
} }
err.emit(); err.emit();
}, },

View File

@ -220,7 +220,7 @@ impl<'a> Resolver<'a> {
ResolutionError::SelfImportCanOnlyAppearOnceInTheList); ResolutionError::SelfImportCanOnlyAppearOnceInTheList);
for other_span in self_spans.iter().skip(1) { for other_span in self_spans.iter().skip(1) {
e.span_note(*other_span, "another `self` import appears here"); e.span_label(*other_span, "another `self` import appears here");
} }
e.emit(); e.emit();

View File

@ -290,17 +290,17 @@ fn resolve_struct_error<'sess, 'a>(resolver: &'sess Resolver,
"`self` imports are only allowed within a { } list") "`self` imports are only allowed within a { } list")
} }
ResolutionError::SelfImportCanOnlyAppearOnceInTheList => { ResolutionError::SelfImportCanOnlyAppearOnceInTheList => {
struct_span_err!(resolver.session, let mut err = struct_span_err!(resolver.session, span, E0430,
span, "`self` import can only appear once in an import list");
E0430, err.span_label(span, "can only appear once in an import list");
"`self` import can only appear once in the list") err
} }
ResolutionError::SelfImportOnlyInImportListWithNonEmptyPrefix => { ResolutionError::SelfImportOnlyInImportListWithNonEmptyPrefix => {
struct_span_err!(resolver.session, let mut err = struct_span_err!(resolver.session, span, E0431,
span, "`self` import can only appear in an import list with \
E0431, a non-empty prefix");
"`self` import can only appear in an import list with a \ err.span_label(span, "can only appear in an import list with a non-empty prefix");
non-empty prefix") err
} }
ResolutionError::UnresolvedImport(name) => { ResolutionError::UnresolvedImport(name) => {
let (span, msg) = match name { let (span, msg) = match name {
@ -320,18 +320,17 @@ fn resolve_struct_error<'sess, 'a>(resolver: &'sess Resolver,
err err
} }
ResolutionError::CannotCaptureDynamicEnvironmentInFnItem => { ResolutionError::CannotCaptureDynamicEnvironmentInFnItem => {
struct_span_err!(resolver.session, let mut err = struct_span_err!(resolver.session,
span, span,
E0434, E0434,
"{}", "{}",
"can't capture dynamic environment in a fn item; use the || { ... } \ "can't capture dynamic environment in a fn item");
closure form instead") err.help("use the `|| { ... }` closure form instead");
err
} }
ResolutionError::AttemptToUseNonConstantValueInConstant => { ResolutionError::AttemptToUseNonConstantValueInConstant => {
let mut err = struct_span_err!(resolver.session, let mut err = struct_span_err!(resolver.session, span, E0435,
span, "attempt to use a non-constant value in a constant");
E0435,
"attempt to use a non-constant value in a constant");
err.span_label(span, "non-constant value"); err.span_label(span, "non-constant value");
err err
} }
@ -351,8 +350,7 @@ fn resolve_struct_error<'sess, 'a>(resolver: &'sess Resolver,
let mut err = struct_span_err!(resolver.session, span, E0128, let mut err = struct_span_err!(resolver.session, span, E0128,
"type parameters with a default cannot use \ "type parameters with a default cannot use \
forward declared identifiers"); forward declared identifiers");
err.span_label(span, format!("defaulted type parameters \ err.span_label(span, format!("defaulted type parameters cannot be forward declared"));
cannot be forward declared"));
err err
} }
} }
@ -3941,7 +3939,7 @@ impl<'a> Resolver<'a> {
feature_err(&self.session.parse_sess, feature, feature_err(&self.session.parse_sess, feature,
attr.span, GateIssue::Language, msg) attr.span, GateIssue::Language, msg)
.span_note(binding.span(), "procedural macro imported here") .span_label(binding.span(), "procedural macro imported here")
.emit(); .emit();
} }
} }

View File

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
// error-pattern: can't capture dynamic environment in a fn item; // error-pattern: can't capture dynamic environment in a fn item
fn foo() { fn foo() {
let x: isize; let x: isize;
fn bar() { log(debug, x); } fn bar() { log(debug, x); }

View File

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
// error-pattern: can't capture dynamic environment in a fn item; // error-pattern: can't capture dynamic environment in a fn item
fn foo(x: isize) { fn foo(x: isize) {
fn bar() { log(debug, x); } fn bar() { log(debug, x); }
} }

View File

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
// error-pattern: can't capture dynamic environment in a fn item; // error-pattern: can't capture dynamic environment in a fn item
fn foo(x: isize) { fn foo(x: isize) {
fn mth() { fn mth() {
fn bar() { log(debug, x); } fn bar() { log(debug, x); }

View File

@ -9,7 +9,7 @@
// except according to those terms. // except according to those terms.
// error-pattern: can't capture dynamic environment in a fn item; // error-pattern: can't capture dynamic environment in a fn item
fn main() { fn main() {
let bar: isize = 5; let bar: isize = 5;

View File

@ -10,10 +10,10 @@ error: unreachable pattern
--> $DIR/issue-30302.rs:25:9 --> $DIR/issue-30302.rs:25:9
| |
23 | Nil => true, 23 | Nil => true,
| --- this pattern matches any value | --- matches any value
24 | //~^ WARN pattern binding `Nil` is named the same as one of the variants of the type `Stack` 24 | //~^ WARN pattern binding `Nil` is named the same as one of the variants of the type `Stack`
25 | _ => false 25 | _ => false
| ^ this is an unreachable pattern | ^ unreachable pattern
| |
note: lint level defined here note: lint level defined here
--> $DIR/issue-30302.rs:14:9 --> $DIR/issue-30302.rs:14:9

View File

@ -2,9 +2,9 @@ error: unreachable pattern
--> $DIR/issue-31221.rs:28:9 --> $DIR/issue-31221.rs:28:9
| |
27 | Var3 => (), 27 | Var3 => (),
| ---- this pattern matches any value | ---- matches any value
28 | Var2 => (), 28 | Var2 => (),
| ^^^^ this is an unreachable pattern | ^^^^ unreachable pattern
| |
note: lint level defined here note: lint level defined here
--> $DIR/issue-31221.rs:14:9 --> $DIR/issue-31221.rs:14:9
@ -16,19 +16,17 @@ error: unreachable pattern
--> $DIR/issue-31221.rs:34:9 --> $DIR/issue-31221.rs:34:9
| |
33 | &Var3 => (), 33 | &Var3 => (),
| ----- this pattern matches any value | ----- matches any value
34 | &Var2 => (), 34 | &Var2 => (),
| ^^^^^ this is an unreachable pattern | ^^^^^ unreachable pattern
|
error: unreachable pattern error: unreachable pattern
--> $DIR/issue-31221.rs:41:9 --> $DIR/issue-31221.rs:41:9
| |
40 | (c, d) => (), 40 | (c, d) => (),
| ------ this pattern matches any value | ------ matches any value
41 | anything => () 41 | anything => ()
| ^^^^^^^^ this is an unreachable pattern | ^^^^^^^^ unreachable pattern
|
error: aborting due to 3 previous errors error: aborting due to 3 previous errors

View File

@ -10,7 +10,7 @@
use foo::bar::{ use foo::bar::{
self, self,
//~^ ERROR `self` import can only appear once in the list //~^ ERROR `self` import can only appear once in an import list
Bar, Bar,
self self
//~^ ERROR the name `bar` is defined multiple times //~^ ERROR the name `bar` is defined multiple times

View File

@ -1,20 +1,17 @@
error[E0430]: `self` import can only appear once in the list error[E0430]: `self` import can only appear once in an import list
--> $DIR/use-mod.rs:12:5 --> $DIR/use-mod.rs:12:5
| |
12 | self, 12 | self,
| ^^^^ | ^^^^ can only appear once in an import list
| ...
note: another `self` import appears here
--> $DIR/use-mod.rs:15:5
|
15 | self 15 | self
| ^^^^ | ---- another `self` import appears here
error[E0431]: `self` import can only appear in an import list with a non-empty prefix error[E0431]: `self` import can only appear in an import list with a non-empty prefix
--> $DIR/use-mod.rs:19:6 --> $DIR/use-mod.rs:19:6
| |
19 | use {self}; 19 | use {self};
| ^^^^ | ^^^^ can only appear in an import list with a non-empty prefix
error[E0252]: the name `bar` is defined multiple times error[E0252]: the name `bar` is defined multiple times
--> $DIR/use-mod.rs:15:5 --> $DIR/use-mod.rs:15:5