Skip to content

Commit 7496539

Browse files
committed
Change span_help calls to fileline_help where appropriate
1 parent 24a840d commit 7496539

File tree

23 files changed

+76
-50
lines changed

23 files changed

+76
-50
lines changed

src/librustc/metadata/loader.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ impl<'a> Context<'a> {
353353
}
354354
}
355355
if self.rejected_via_kind.len() > 0 {
356-
self.sess.span_help(self.span, "please recompile this crate using \
356+
self.sess.fileline_help(self.span, "please recompile this crate using \
357357
--crate-type lib");
358358
let mismatches = self.rejected_via_kind.iter();
359359
for (i, &CrateMismatch { ref path, .. }) in mismatches.enumerate() {

src/librustc/metadata/macro_import.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ impl<'a, 'v> Visitor<'v> for MacroLoader<'a> {
8484
}
8585
"plugin" => {
8686
self.sess.span_err(attr.span, "#[plugin] on `extern crate` is deprecated");
87-
self.sess.span_help(attr.span, &format!("use a crate attribute instead, \
87+
self.sess.fileline_help(attr.span, &format!("use a crate attribute instead, \
8888
i.e. #![plugin({})]",
8989
item.ident.as_str()));
9090
}

src/librustc/middle/check_match.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ fn check_for_bindings_named_the_same_as_variants(cx: &MatchCheckCtxt, pat: &Pat)
252252
"pattern binding `{}` is named the same as one \
253253
of the variants of the type `{}`",
254254
&token::get_ident(ident.node), ty_to_string(cx.tcx, pat_ty));
255-
span_help!(cx.tcx.sess, p.span,
255+
fileline_help!(cx.tcx.sess, p.span,
256256
"if you meant to match on a variant, \
257257
consider making the path in the pattern qualified: `{}::{}`",
258258
ty_to_string(cx.tcx, pat_ty), &token::get_ident(ident.node));

src/librustc/middle/infer/error_reporting.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
444444
// Does the required lifetime have a nice name we can print?
445445
span_err!(self.tcx.sess, origin.span(), E0309,
446446
"{} may not live long enough", labeled_user_string);
447-
self.tcx.sess.span_help(
447+
self.tcx.sess.fileline_help(
448448
origin.span(),
449449
&format!(
450450
"consider adding an explicit lifetime bound `{}: {}`...",
@@ -456,7 +456,7 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
456456
// Does the required lifetime have a nice name we can print?
457457
span_err!(self.tcx.sess, origin.span(), E0310,
458458
"{} may not live long enough", labeled_user_string);
459-
self.tcx.sess.span_help(
459+
self.tcx.sess.fileline_help(
460460
origin.span(),
461461
&format!(
462462
"consider adding an explicit lifetime bound `{}: 'static`...",
@@ -468,7 +468,7 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
468468
span_err!(self.tcx.sess, origin.span(), E0311,
469469
"{} may not live long enough",
470470
labeled_user_string);
471-
self.tcx.sess.span_help(
471+
self.tcx.sess.fileline_help(
472472
origin.span(),
473473
&format!(
474474
"consider adding an explicit lifetime bound for `{}`",

src/librustc_borrowck/borrowck/gather_loans/move_error.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ fn note_move_destination(bccx: &BorrowckCtxt,
165165
bccx.span_note(
166166
move_to_span,
167167
"attempting to move value to here");
168-
bccx.span_help(
168+
bccx.fileline_help(
169169
move_to_span,
170170
&format!("to prevent the move, \
171171
use `ref {0}` or `ref mut {0}` to capture value by \

src/librustc_borrowck/borrowck/mod.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -643,7 +643,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
643643
ol,
644644
moved_lp_msg,
645645
pat_ty.user_string(self.tcx)));
646-
self.tcx.sess.span_help(span,
646+
self.tcx.sess.fileline_help(span,
647647
"use `ref` to override");
648648
}
649649

@@ -675,7 +675,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
675675
moved_lp_msg,
676676
expr_ty.user_string(self.tcx),
677677
suggestion));
678-
self.tcx.sess.span_help(expr_span, help);
678+
self.tcx.sess.fileline_help(expr_span, help);
679679
}
680680
}
681681

@@ -741,6 +741,10 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
741741
self.tcx.sess.span_help(s, m);
742742
}
743743

744+
pub fn fileline_help(&self, s: Span, m: &str) {
745+
self.tcx.sess.fileline_help(s, m);
746+
}
747+
744748
pub fn bckerr_to_string(&self, err: &BckError<'tcx>) -> String {
745749
match err.code {
746750
err_mutbl => {
@@ -870,7 +874,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
870874
}
871875

872876
if is_closure {
873-
self.tcx.sess.span_help(
877+
self.tcx.sess.fileline_help(
874878
span,
875879
"closures behind references must be called via `&mut`");
876880
}

src/librustc_lint/builtin.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1921,7 +1921,8 @@ impl LintPass for UnconditionalRecursion {
19211921
for call in &self_call_spans {
19221922
sess.span_note(*call, "recursive call site")
19231923
}
1924-
sess.span_help(sp, "a `loop` may express intention better if this is on purpose")
1924+
sess.fileline_help(sp, "a `loop` may express intention \
1925+
better if this is on purpose")
19251926
}
19261927
}
19271928

src/librustc_resolve/lib.rs

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4115,10 +4115,14 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
41154115
uses it like a function name",
41164116
path_name));
41174117

4118-
self.session.span_help(expr.span,
4119-
&format!("Did you mean to write: \
4120-
`{} {{ /* fields */ }}`?",
4121-
path_name));
4118+
let msg = format!("Did you mean to write: \
4119+
`{} {{ /* fields */ }}`?",
4120+
path_name);
4121+
if self.emit_errors {
4122+
self.session.fileline_help(expr.span, &msg);
4123+
} else {
4124+
self.session.span_help(expr.span, &msg);
4125+
}
41224126
} else {
41234127
// Write the result into the def map.
41244128
debug!("(resolving expr) resolved `{}`",
@@ -4146,18 +4150,21 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
41464150
match type_res.map(|r| r.base_def) {
41474151
Some(DefTy(struct_id, _))
41484152
if self.structs.contains_key(&struct_id) => {
4149-
self.resolve_error(expr.span,
4153+
self.resolve_error(expr.span,
41504154
&format!("`{}` is a structure name, but \
41514155
this expression \
41524156
uses it like a function name",
41534157
path_name));
41544158

4155-
self.session.span_help(expr.span,
4156-
&format!("Did you mean to write: \
4157-
`{} {{ /* fields */ }}`?",
4158-
path_name));
4159-
4160-
}
4159+
let msg = format!("Did you mean to write: \
4160+
`{} {{ /* fields */ }}`?",
4161+
path_name);
4162+
if self.emit_errors {
4163+
self.session.fileline_help(expr.span, &msg);
4164+
} else {
4165+
self.session.span_help(expr.span, &msg);
4166+
}
4167+
}
41614168
_ => {
41624169
// Keep reporting some errors even if they're ignored above.
41634170
self.resolve_path(expr.id, path, 0, ValueNS, true);

src/librustc_trans/trans/foreign.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ fn gate_simd_ffi(tcx: &ty::ctxt, decl: &ast::FnDecl, ty: &ty::BareFnTy) {
440440
&format!("use of SIMD type `{}` in FFI is highly experimental and \
441441
may result in invalid code",
442442
pprust::ty_to_string(ast_ty)));
443-
tcx.sess.span_help(ast_ty.span,
443+
tcx.sess.fileline_help(ast_ty.span,
444444
"add #![feature(simd_ffi)] to the crate attributes to enable");
445445
}
446446
};

src/librustc_typeck/astconv.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -212,18 +212,18 @@ pub fn opt_ast_region_to_region<'tcx>(
212212
}
213213
}
214214
if len == 1 {
215-
span_help!(this.tcx().sess, default_span,
215+
fileline_help!(this.tcx().sess, default_span,
216216
"this function's return type contains a borrowed value, but \
217217
the signature does not say which {} it is borrowed from",
218218
m);
219219
} else if len == 0 {
220-
span_help!(this.tcx().sess, default_span,
220+
fileline_help!(this.tcx().sess, default_span,
221221
"this function's return type contains a borrowed value, but \
222222
there is no value for it to be borrowed from");
223-
span_help!(this.tcx().sess, default_span,
223+
fileline_help!(this.tcx().sess, default_span,
224224
"consider giving it a 'static lifetime");
225225
} else {
226-
span_help!(this.tcx().sess, default_span,
226+
fileline_help!(this.tcx().sess, default_span,
227227
"this function's return type contains a borrowed value, but \
228228
the signature does not say whether it is borrowed from {}",
229229
m);
@@ -705,7 +705,7 @@ fn ast_path_to_trait_ref<'a,'tcx>(
705705
span_err!(this.tcx().sess, span, E0215,
706706
"angle-bracket notation is not stable when \
707707
used with the `Fn` family of traits, use parentheses");
708-
span_help!(this.tcx().sess, span,
708+
fileline_help!(this.tcx().sess, span,
709709
"add `#![feature(unboxed_closures)]` to \
710710
the crate attributes to enable");
711711
}
@@ -719,7 +719,7 @@ fn ast_path_to_trait_ref<'a,'tcx>(
719719
span_err!(this.tcx().sess, span, E0216,
720720
"parenthetical notation is only stable when \
721721
used with the `Fn` family of traits");
722-
span_help!(this.tcx().sess, span,
722+
fileline_help!(this.tcx().sess, span,
723723
"add `#![feature(unboxed_closures)]` to \
724724
the crate attributes to enable");
725725
}
@@ -944,14 +944,14 @@ fn ast_ty_to_trait_ref<'tcx>(this: &AstConv<'tcx>,
944944
pprust::ty_to_string(ty));
945945
match ty.node {
946946
ast::TyRptr(None, ref mut_ty) => {
947-
span_help!(this.tcx().sess, ty.span,
947+
fileline_help!(this.tcx().sess, ty.span,
948948
"perhaps you meant `&{}({} +{})`? (per RFC 438)",
949949
ppaux::mutability_to_string(mut_ty.mutbl),
950950
pprust::ty_to_string(&*mut_ty.ty),
951951
pprust::bounds_to_string(bounds));
952952
}
953953
ast::TyRptr(Some(ref lt), ref mut_ty) => {
954-
span_help!(this.tcx().sess, ty.span,
954+
fileline_help!(this.tcx().sess, ty.span,
955955
"perhaps you meant `&{} {}({} +{})`? (per RFC 438)",
956956
pprust::lifetime_to_string(lt),
957957
ppaux::mutability_to_string(mut_ty.mutbl),
@@ -960,7 +960,7 @@ fn ast_ty_to_trait_ref<'tcx>(this: &AstConv<'tcx>,
960960
}
961961

962962
_ => {
963-
span_help!(this.tcx().sess, ty.span,
963+
fileline_help!(this.tcx().sess, ty.span,
964964
"perhaps you forgot parentheses? (per RFC 438)");
965965
}
966966
}

0 commit comments

Comments
 (0)