Skip to content

remove deprecated suggestion functions #57907

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

Merged
merged 2 commits into from
Jan 27, 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
2 changes: 1 addition & 1 deletion src/librustc/hir/lowering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1829,7 +1829,7 @@ impl<'a> LoweringContext<'a> {
if let Ok(snippet) = self.sess.source_map().span_to_snippet(data.span) {
// Do not suggest going from `Trait()` to `Trait<>`
if data.inputs.len() > 0 {
err.span_suggestion_with_applicability(
err.span_suggestion(
data.span,
"use angle brackets instead",
format!("<{}>", &snippet[1..snippet.len() - 1]),
Expand Down
8 changes: 4 additions & 4 deletions src/librustc/infer/error_reporting/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
if let Some(ty::error::ExpectedFound { found, .. }) = exp_found {
if ty.is_box() && ty.boxed_ty() == found {
if let Ok(snippet) = self.tcx.sess.source_map().span_to_snippet(span) {
err.span_suggestion_with_applicability(
err.span_suggestion(
span,
"consider dereferencing the boxed value",
format!("*{}", snippet),
Expand Down Expand Up @@ -532,7 +532,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
err.span_label(then, "expected because of this");
outer.map(|sp| err.span_label(sp, "if and else have incompatible types"));
if let Some(sp) = semicolon {
err.span_suggestion_short_with_applicability(
err.span_suggestion_short(
sp,
"consider removing this semicolon",
String::new(),
Expand Down Expand Up @@ -1084,7 +1084,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
self.tcx.sess.source_map().span_to_snippet(span),
show_suggestion,
) {
diag.span_suggestion_with_applicability(
diag.span_suggestion(
span,
msg,
format!("{}.as_ref()", snippet),
Expand Down Expand Up @@ -1273,7 +1273,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
let tail = if has_lifetimes { " + " } else { "" };
format!("{}: {}{}", bound_kind, sub, tail)
};
err.span_suggestion_short_with_applicability(
err.span_suggestion_short(
sp,
&consider,
suggestion,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ impl<'a, 'gcx, 'tcx> NiceRegionError<'a, 'gcx, 'tcx> {
E0621,
"explicit lifetime required in {}",
error_var
).span_suggestion_with_applicability(
).span_suggestion(
new_ty_span,
&format!("add explicit lifetime `{}` to {}", named, span_label_var),
new_ty.to_string(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ impl<'a, 'gcx, 'tcx> NiceRegionError<'a, 'gcx, 'tcx> {
_ => "'_".to_owned(),
};
if let Ok(snippet) = self.tcx.sess.source_map().span_to_snippet(return_sp) {
err.span_suggestion_with_applicability(
err.span_suggestion(
return_sp,
&format!(
"you can add a constraint to the return type to make it last \
Expand Down
13 changes: 4 additions & 9 deletions src/librustc/lint/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ impl BuiltinLintDiagnostics {
Ok(s) => (format!("dyn {}", s), Applicability::MachineApplicable),
Err(_) => ("dyn <type>".to_string(), Applicability::HasPlaceholders)
};
db.span_suggestion_with_applicability(span, "use `dyn`", sugg, app);
db.span_suggestion(span, "use `dyn`", sugg, app);
}
BuiltinLintDiagnostics::AbsPathWithModule(span) => {
let (sugg, app) = match sess.source_map().span_to_snippet(span) {
Expand All @@ -490,7 +490,7 @@ impl BuiltinLintDiagnostics {
}
Err(_) => ("crate::<path>".to_string(), Applicability::HasPlaceholders)
};
db.span_suggestion_with_applicability(span, "use `crate`", sugg, app);
db.span_suggestion(span, "use `crate`", sugg, app);
}
BuiltinLintDiagnostics::DuplicatedMacroExports(ident, earlier_span, later_span) => {
db.span_label(later_span, format!("`{}` already exported", ident));
Expand Down Expand Up @@ -531,20 +531,15 @@ impl BuiltinLintDiagnostics {
(insertion_span, anon_lts)
}
};
db.span_suggestion_with_applicability(
db.span_suggestion(
replace_span,
&format!("indicate the anonymous lifetime{}", if n >= 2 { "s" } else { "" }),
suggestion,
Applicability::MachineApplicable
);
}
BuiltinLintDiagnostics::UnknownCrateTypes(span, note, sugg) => {
db.span_suggestion_with_applicability(
span,
&note,
sugg,
Applicability::MaybeIncorrect
);
db.span_suggestion(span, &note, sugg, Applicability::MaybeIncorrect);
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/librustc/lint/levels.rs
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ impl<'a> LintLevelsBuilder<'a> {
Some(li.span.into()),
&msg,
);
err.span_suggestion_with_applicability(
err.span_suggestion(
li.span,
"change it to",
new_lint_name.to_string(),
Expand Down Expand Up @@ -362,7 +362,7 @@ impl<'a> LintLevelsBuilder<'a> {
Some(li.span.into()),
&msg);
if let Some(new_name) = renamed {
err.span_suggestion_with_applicability(
err.span_suggestion(
li.span,
"use the new name",
new_name,
Expand All @@ -386,7 +386,7 @@ impl<'a> LintLevelsBuilder<'a> {
&msg);

if let Some(suggestion) = suggestion {
db.span_suggestion_with_applicability(
db.span_suggestion(
li.span,
"did you mean",
suggestion.to_string(),
Expand Down
14 changes: 9 additions & 5 deletions src/librustc/middle/liveness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1600,12 +1600,16 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
let mut err = self.ir.tcx
.struct_span_lint_hir(lint::builtin::UNUSED_VARIABLES, hir_id, sp, &msg);
if self.ir.variable_is_shorthand(var) {
err.span_suggestion_with_applicability(sp, "try ignoring the field",
format!("{}: _", name),
Applicability::MachineApplicable);
err.span_suggestion(
sp,
"try ignoring the field",
format!("{}: _", name),
Applicability::MachineApplicable,
);
} else {
err.span_suggestion_short_with_applicability(
sp, &suggest_underscore_msg,
err.span_suggestion_short(
sp,
&suggest_underscore_msg,
format!("_{}", name),
Applicability::MachineApplicable,
);
Expand Down
8 changes: 4 additions & 4 deletions src/librustc/middle/resolve_lifetime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1526,14 +1526,14 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
// place ("start at" because the latter includes trailing
// whitespace), then this is an in-band lifetime
if decl_span.shrink_to_lo() == use_span.shrink_to_lo() {
err.span_suggestion_with_applicability(
err.span_suggestion(
use_span,
"elide the single-use lifetime",
String::new(),
Applicability::MachineApplicable,
);
} else {
err.multipart_suggestion_with_applicability(
err.multipart_suggestion(
"elide the single-use lifetime",
vec![(decl_span, String::new()), (use_span, String::new())],
Applicability::MachineApplicable,
Expand Down Expand Up @@ -1644,7 +1644,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
if let Some(generics) = self.tcx.hir().get_generics(parent_def_id) {
let unused_lt_span = self.lifetime_deletion_span(name, generics);
if let Some(span) = unused_lt_span {
err.span_suggestion_with_applicability(
err.span_suggestion(
span,
"elide the unused lifetime",
String::new(),
Expand Down Expand Up @@ -2350,7 +2350,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
} else {
(format!("{} + 'static", snippet), Applicability::MaybeIncorrect)
};
db.span_suggestion_with_applicability(span, msg, sugg, applicability);
db.span_suggestion(span, msg, sugg, applicability);
false
}
Err(_) => {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/session/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ impl Session {
}
DiagnosticBuilderMethod::SpanSuggestion(suggestion) => {
let span = span_maybe.expect("span_suggestion_* needs a span");
diag_builder.span_suggestion_with_applicability(
diag_builder.span_suggestion(
span,
message,
suggestion,
Expand Down
24 changes: 12 additions & 12 deletions src/librustc/traits/error_reporting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -904,7 +904,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
if let Some(ref expr) = local.init {
if let hir::ExprKind::Index(_, _) = expr.node {
if let Ok(snippet) = self.tcx.sess.source_map().span_to_snippet(expr.span) {
err.span_suggestion_with_applicability(
err.span_suggestion(
expr.span,
"consider borrowing here",
format!("&{}", snippet),
Expand Down Expand Up @@ -952,7 +952,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
let format_str = format!("consider removing {} leading `&`-references",
remove_refs);

err.span_suggestion_short_with_applicability(
err.span_suggestion_short(
sp, &format_str, String::new(), Applicability::MachineApplicable
);
break;
Expand Down Expand Up @@ -1109,7 +1109,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
// For example, if `expected_args_length` is 2, suggest `|_, _|`.
if found_args.is_empty() && is_closure {
let underscores = vec!["_"; expected_args.len()].join(", ");
err.span_suggestion_with_applicability(
err.span_suggestion(
pipe_span,
&format!(
"consider changing the closure to take and ignore the expected argument{}",
Expand All @@ -1130,11 +1130,12 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
.map(|(name, _)| name.to_owned())
.collect::<Vec<String>>()
.join(", ");
err.span_suggestion_with_applicability(found_span,
"change the closure to take multiple \
arguments instead of a single tuple",
format!("|{}|", sugg),
Applicability::MachineApplicable);
err.span_suggestion(
found_span,
"change the closure to take multiple arguments instead of a single tuple",
format!("|{}|", sugg),
Applicability::MachineApplicable,
);
}
}
if let &[ArgKind::Tuple(_, ref fields)] = &expected_args[..] {
Expand Down Expand Up @@ -1162,12 +1163,11 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
String::new()
},
);
err.span_suggestion_with_applicability(
err.span_suggestion(
found_span,
"change the closure to accept a tuple instead of \
individual arguments",
"change the closure to accept a tuple instead of individual arguments",
sugg,
Applicability::MachineApplicable
Applicability::MachineApplicable,
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/ty/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
{
if let Ok(snippet) = self.sess.source_map().span_to_snippet(sp) {
if snippet.chars().all(|c| c.is_digit(10) || c == '-' || c == '_') {
db.span_suggestion_with_applicability(
db.span_suggestion(
sp,
"use a float literal",
format!("{}.0", snippet),
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_borrowck/borrowck/gather_loans/move_error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ fn report_move_errors<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>, errors: &[MoveErr
let initializer =
e.init.as_ref().expect("should have an initializer to get an error");
if let Ok(snippet) = bccx.tcx.sess.source_map().span_to_snippet(initializer.span) {
err.span_suggestion_with_applicability(
err.span_suggestion(
initializer.span,
"consider using a reference instead",
format!("&{}", snippet),
Expand Down
12 changes: 6 additions & 6 deletions src/librustc_borrowck/borrowck/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -850,15 +850,15 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
}) = cmt.cat {
db.note(fn_closure_msg);
} else {
db.span_suggestion_with_applicability(
db.span_suggestion(
sp,
msg,
suggestion,
Applicability::Unspecified,
);
}
} else {
db.span_suggestion_with_applicability(
db.span_suggestion(
sp,
msg,
suggestion,
Expand Down Expand Up @@ -1229,7 +1229,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
let let_span = self.tcx.hir().span(node_id);
let suggestion = suggest_ref_mut(self.tcx, let_span);
if let Some(replace_str) = suggestion {
db.span_suggestion_with_applicability(
db.span_suggestion(
let_span,
"use a mutable reference instead",
replace_str,
Expand Down Expand Up @@ -1291,15 +1291,15 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
)) = ty.map(|t| &t.node)
{
let borrow_expr_id = self.tcx.hir().get_parent_node(borrowed_node_id);
db.span_suggestion_with_applicability(
db.span_suggestion(
self.tcx.hir().span(borrow_expr_id),
"consider removing the `&mut`, as it is an \
immutable binding to a mutable reference",
snippet,
Applicability::MachineApplicable,
);
} else {
db.span_suggestion_with_applicability(
db.span_suggestion(
let_span,
"make this binding mutable",
format!("mut {}", snippet),
Expand All @@ -1326,7 +1326,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
&cmt_path_or_string,
capture_span,
Origin::Ast)
.span_suggestion_with_applicability(
.span_suggestion(
err.span,
&format!("to force the closure to take ownership of {} \
(and any other referenced variables), \
Expand Down
5 changes: 3 additions & 2 deletions src/librustc_borrowck/borrowck/unused.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,12 @@ impl<'a, 'tcx> UnusedMutCx<'a, 'tcx> {
hir_id,
span,
"variable does not need to be mutable")
.span_suggestion_short_with_applicability(
.span_suggestion_short(
mut_span,
"remove this `mut`",
String::new(),
Applicability::MachineApplicable)
Applicability::MachineApplicable,
)
.emit();
}
}
Expand Down
Loading