Skip to content

Rollup of 7 pull requests #42178

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

Closed
wants to merge 31 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
f8b66a0
trace_macro: Show both the macro call and its expansion. #42072.
jorendorff May 19, 2017
0b85b64
libstd/sync/mpsc: relicense under rust license
dvyukov May 22, 2017
6dde3f4
Move some tests from compile-fail to ui
oli-obk May 16, 2017
ec1fa6d
Change macro typo helps to suggestions
oli-obk May 16, 2017
27359bd
Change enum variant help into a suggestion
oli-obk May 16, 2017
e328ef0
Change some "did you mean `self.*`" messages to suggestions
oli-obk May 16, 2017
8add02a
Changes in ui tests
oli-obk May 16, 2017
e618a4f
Add some guidelines for suggestion messages and follow them
oli-obk May 18, 2017
a9b54ab
Update ui tests output
oli-obk May 18, 2017
9d41d0e
Move a compile-fail test to ui
oli-obk May 18, 2017
bff4795
Tidy errors
oli-obk May 18, 2017
6f681c2
Fix line numbers in ui test
oli-obk May 22, 2017
1343bc6
Readd //~ERROR messages
oli-obk May 22, 2017
14b767d
Add example of recursive drop to Drop trait.
Havvy May 22, 2017
ca909c8
Add example of variable declaration drop order to Drop trait.
Havvy May 22, 2017
d7927ff
Add description of how values are dropped to Drop trait.
Havvy May 22, 2017
5f4b0ff
Fix trailing whitespace.
Havvy May 22, 2017
72eb010
update-all-references.sh doesn't deterministically work on ui-fulldeps
oli-obk May 23, 2017
b41b294
Suggested changes by birkenfeld
Havvy May 23, 2017
57f260d
Override size_hint and propagate ExactSizeIterator for iter::StepBy
scottmcm May 23, 2017
4be488c
Add iterator_step_by to the unstable book's summary
scottmcm May 21, 2017
fcb3a71
Update description of iter::StepBy
scottmcm May 21, 2017
794e572
Give step_trait a distinct tracking issue from step_by
scottmcm May 23, 2017
e860655
Remove some needless // gate-test- comments
est31 May 23, 2017
c20a157
Rollup merge of #42033 - oli-obk:suggestions, r=petrochenkov
Mark-Simulacrum May 23, 2017
84db8c1
Rollup merge of #42103 - jorendorff:master, r=estebank
Mark-Simulacrum May 23, 2017
7e4dda1
Rollup merge of #42149 - dvyukov:license, r=brson
Mark-Simulacrum May 23, 2017
20a5a5d
Rollup merge of #42159 - Havvy:doc-drop, r=steveklabnik
Mark-Simulacrum May 23, 2017
99dca25
Rollup merge of #42167 - scottmcm:iter-stepby-sizehint, r=alexcrichton
Mark-Simulacrum May 23, 2017
30a272e
Rollup merge of #42169 - scottmcm:new-step-trait-issue, r=alexcrichton
Mark-Simulacrum May 23, 2017
d8afdf1
Rollup merge of #42177 - est31:master, r=Mark-Simulacrum
Mark-Simulacrum May 23, 2017
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
Prev Previous commit
Next Next commit
Add some guidelines for suggestion messages and follow them
  • Loading branch information
oli-obk committed May 22, 2017
commit e618a4f82ba0fc43bb23b8c4765c84cd48a1a218
2 changes: 1 addition & 1 deletion src/librustc_borrowck/borrowck/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1002,7 +1002,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
.span_suggestion(err.span,
&format!("to force the closure to take ownership of {} \
(and any other referenced variables), \
use the `move` keyword, as shown:",
use the `move` keyword",
cmt_path_or_string),
suggestion)
.emit();
Expand Down
12 changes: 12 additions & 0 deletions src/librustc_errors/diagnostic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,18 @@ impl Diagnostic {

/// Prints out a message with a suggested edit of the code.
///
/// In case of short messages and a simple suggestion,
/// rustc displays it as a label like
///
/// "try adding parentheses: `(tup.0).1`"
///
/// The message
/// * should not end in any punctuation (a `:` is added automatically)
/// * should not be a question
/// * should not contain any parts like "the following", "as shown"
/// * may look like "to do xyz, use" or "to do xyz, use abc"
/// * may contain a name of a function, variable or type, but not whole expressions
///
/// See `diagnostic::CodeSuggestion` for more information.
pub fn span_suggestion(&mut self, sp: Span, msg: &str, suggestion: String) -> &mut Self {
self.suggestions.push(CodeSuggestion {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_errors/emitter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ impl Emitter for EmitterWriter {
// don't display multiline suggestions as labels
sugg.substitution_parts[0].substitutions[0].find('\n').is_none() {
let substitution = &sugg.substitution_parts[0].substitutions[0];
let msg = format!("help: {} `{}`", sugg.msg, substitution);
let msg = format!("help: {}: `{}`", sugg.msg, substitution);
primary_span.push_span_label(sugg.substitution_spans().next().unwrap(), msg);
} else {
// if there are multiple suggestions, print them all in full
Expand Down
12 changes: 6 additions & 6 deletions src/librustc_resolve/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2308,13 +2308,13 @@ impl<'a> Resolver<'a> {
enum_candidates.sort();
for (sp, variant_path, enum_path) in enum_candidates {
if sp == DUMMY_SP {
let msg = format!("there is an enum variant `{}`,\
did you mean to use `{}`?",
let msg = format!("there is an enum variant `{}`, \
try using `{}`?",
variant_path,
enum_path);
err.help(&msg);
} else {
err.span_suggestion(span, "did you mean the variant's enum", enum_path);
err.span_suggestion(span, "you can try using the variant's enum", enum_path);
}
}
}
Expand All @@ -2323,19 +2323,19 @@ impl<'a> Resolver<'a> {
let self_is_available = this.self_value_is_available(path[0].ctxt, span);
match candidate {
AssocSuggestion::Field => {
err.span_suggestion(span, "did you mean",
err.span_suggestion(span, "try",
format!("self.{}", path_str));
if !self_is_available {
err.span_label(span, format!("`self` value is only available in \
methods with `self` parameter"));
}
}
AssocSuggestion::MethodWithSelf if self_is_available => {
err.span_suggestion(span, "did you mean",
err.span_suggestion(span, "try",
format!("self.{}", path_str));
}
AssocSuggestion::MethodWithSelf | AssocSuggestion::AssocItem => {
err.span_suggestion(span, "did you mean",
err.span_suggestion(span, "try",
format!("Self::{}", path_str));
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_resolve/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -649,9 +649,9 @@ impl<'a> Resolver<'a> {
if let Some(suggestion) = suggestion {
if suggestion != name {
if let MacroKind::Bang = kind {
err.span_suggestion(span, "did you mean", format!("{}!", suggestion));
err.span_suggestion(span, "you could try the macro", format!("{}!", suggestion));
} else {
err.span_suggestion(span, "did you mean", suggestion.to_string());
err.span_suggestion(span, "try", suggestion.to_string());
}
} else {
err.help("have you added the `#[macro_use]` on the module/import?");
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_typeck/check/cast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ impl<'a, 'gcx, 'tcx> CastCheck<'tcx> {
match fcx.tcx.sess.codemap().span_to_snippet(self.cast_span) {
Ok(s) => {
err.span_suggestion(self.cast_span,
"try casting to a reference instead:",
"try casting to a reference instead",
format!("&{}{}", mtstr, s));
}
Err(_) => {
Expand All @@ -295,7 +295,7 @@ impl<'a, 'gcx, 'tcx> CastCheck<'tcx> {
match fcx.tcx.sess.codemap().span_to_snippet(self.cast_span) {
Ok(s) => {
err.span_suggestion(self.cast_span,
"try casting to a `Box` instead:",
"try casting to a `Box` instead",
format!("Box<{}>", s));
}
Err(_) => span_help!(err, self.cast_span, "did you mean `Box<{}>`?", tstr),
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_typeck/check/op.rs
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
from a string reference. String concatenation \
appends the string on the right to the string \
on the left and may require reallocation. This \
requires ownership of the string on the left."), suggestion);
requires ownership of the string on the left"), suggestion);
is_string_addition = true;
}

Expand Down
4 changes: 2 additions & 2 deletions src/libsyntax/parse/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1507,7 +1507,7 @@ impl<'a> Parser<'a> {
s.print_bounds(" +", &bounds)?;
s.pclose()
});
err.span_suggestion(sum_span, "try adding parentheses:", sum_with_parens);
err.span_suggestion(sum_span, "try adding parentheses", sum_with_parens);
}
TyKind::Ptr(..) | TyKind::BareFn(..) => {
err.span_label(sum_span, "perhaps you forgot parentheses?");
Expand Down Expand Up @@ -5180,7 +5180,7 @@ impl<'a> Parser<'a> {
`pub(in path::to::module)`: visible only on the specified path"##;
let path = self.parse_path(PathStyle::Mod)?;
let path_span = self.prev_span;
let help_msg = format!("make this visible only to module `{}` with `in`:", path);
let help_msg = format!("make this visible only to module `{}` with `in`", path);
self.expect(&token::CloseDelim(token::Paren))?; // `)`
let mut err = self.span_fatal_help(path_span, msg, suggestion);
err.span_suggestion(path_span, &help_msg, format!("in {}", path));
Expand Down