Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
9fbb2a9
Fix missing calls to drop on unwind with lto=fat; issue 64655.
pnkfelix Oct 2, 2019
a371972
Regression tests for issue 64655.
pnkfelix Oct 2, 2019
3adcc3e
fix typo
pnkfelix Oct 2, 2019
e7e6dec
Apply suggestions from code review
pnkfelix Oct 3, 2019
5e7e8cd
Update attributes.rs
pnkfelix Oct 3, 2019
71e5f78
Update issue-64655-extern-rust-must-allow-unwind.rs
pnkfelix Oct 3, 2019
1222cc9
permit asyncawait-ondeck to be added by anyone
nikomatsakis Oct 3, 2019
1fcbd90
Update triagebot.toml
nikomatsakis Oct 3, 2019
ed60cf2
When encountering chained operators use heuristics to recover from ba…
estebank Sep 30, 2019
6c9f298
review comments
estebank Sep 30, 2019
d7dceaa
Account for missing turbofish in paths too
estebank Sep 30, 2019
d27683a
Prove bad turbofish parser recovery in test
estebank Sep 30, 2019
dfdc369
review comments
estebank Oct 1, 2019
f1499a8
review comments
estebank Oct 1, 2019
02f57f8
review comments
estebank Oct 3, 2019
76456e7
review comments
estebank Oct 4, 2019
d896088
Upgrade librustc_macros dependencies
mati865 Oct 4, 2019
2d87bac
replace GeneratorSubsts with SubstsRef
csmoe Oct 3, 2019
fa7a87b
generate GeneratorSubsts from SubstsRef
csmoe Oct 3, 2019
774ea80
replace GeneratorSubsts inside related types
csmoe Oct 3, 2019
ef9fe10
remove GeneratorSubsts visitors
csmoe Oct 3, 2019
afc0bb9
clean up GeneratorSubsts
csmoe Oct 3, 2019
e9009c8
[const-prop] Fix ICE when trying to eval polymorphic promoted MIR
wesleywiser Oct 3, 2019
08ec3fe
dont run these tests on targets that default to panic=abort.
pnkfelix Oct 4, 2019
91a096a
move middle::liveness to rustc_passes
Mark-Simulacrum Oct 4, 2019
bb70782
middle::dead -> rustc_passes
Mark-Simulacrum Oct 4, 2019
82bfd8e
middle::entry -> rustc_passes
Mark-Simulacrum Oct 4, 2019
7c3f65b
middle::intrinsicck -> rustc_passes
Mark-Simulacrum Oct 4, 2019
c4ec53f
Rollup merge of #64909 - estebank:turbofish-reloaded, r=Centril
Mark-Simulacrum Oct 4, 2019
2889139
Rollup merge of #65020 - pnkfelix:targetted-fix-for-always-marking-ru…
Mark-Simulacrum Oct 4, 2019
b7c3e07
Rollup merge of #65064 - rust-lang:permit-asyncawait-ondeck-by-anyone…
Mark-Simulacrum Oct 4, 2019
dc87b27
Rollup merge of #65066 - wesleywiser:fix_const_prop_ice_on_polymorphi…
Mark-Simulacrum Oct 4, 2019
aa98a2b
Rollup merge of #65100 - csmoe:generator, r=nikomatsakis
Mark-Simulacrum Oct 4, 2019
18f62d7
Rollup merge of #65101 - mati865:rustc_macro-deps, r=nikomatsakis
Mark-Simulacrum Oct 4, 2019
4c094e1
Rollup merge of #65105 - Mark-Simulacrum:split-librustc, r=nikomatsakis
Mark-Simulacrum Oct 4, 2019
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
review comments
  • Loading branch information
estebank committed Oct 3, 2019
commit 02f57f83a9ea5903cb02bdc304800661c8f4296f
41 changes: 35 additions & 6 deletions src/librustc_errors/diagnostic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -298,9 +298,13 @@ impl Diagnostic {
/// * may contain a name of a function, variable, or type, but not whole expressions
///
/// See `CodeSuggestion` for more information.
pub fn span_suggestion(&mut self, sp: Span, msg: &str,
suggestion: String,
applicability: Applicability) -> &mut Self {
pub fn span_suggestion(
&mut self,
sp: Span,
msg: &str,
suggestion: String,
applicability: Applicability,
) -> &mut Self {
self.suggestions.push(CodeSuggestion {
substitutions: vec![Substitution {
parts: vec![SubstitutionPart {
Expand All @@ -315,10 +319,35 @@ impl Diagnostic {
self
}

pub fn span_suggestion_verbose(
&mut self,
sp: Span,
msg: &str,
suggestion: String,
applicability: Applicability,
) -> &mut Self {
self.suggestions.push(CodeSuggestion {
substitutions: vec![Substitution {
parts: vec![SubstitutionPart {
snippet: suggestion,
span: sp,
}],
}],
msg: msg.to_owned(),
style: SuggestionStyle::ShowAlways,
applicability,
});
self
}

/// Prints out a message with multiple suggested edits of the code.
pub fn span_suggestions(&mut self, sp: Span, msg: &str,
suggestions: impl Iterator<Item = String>, applicability: Applicability) -> &mut Self
{
pub fn span_suggestions(
&mut self,
sp: Span,
msg: &str,
suggestions: impl Iterator<Item = String>,
applicability: Applicability,
) -> &mut Self {
self.suggestions.push(CodeSuggestion {
substitutions: suggestions.map(|snippet| Substitution {
parts: vec![SubstitutionPart {
Expand Down
4 changes: 3 additions & 1 deletion src/librustc_errors/emitter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,9 @@ pub trait Emitter {
// when this style is set we want the suggestion to be a message, not inline
sugg.style != SuggestionStyle::HideCodeAlways &&
// trivial suggestion for tooling's sake, never shown
sugg.style != SuggestionStyle::CompletelyHidden
sugg.style != SuggestionStyle::CompletelyHidden &&
// subtle suggestion, never shown inline
sugg.style != SuggestionStyle::ShowAlways
{
let substitution = &sugg.substitutions[0].parts[0].snippet.trim();
let msg = if substitution.len() == 0 || sugg.style.hide_inline() {
Expand Down
2 changes: 2 additions & 0 deletions src/librustc_errors/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ pub enum SuggestionStyle {
/// This will *not* show the code if the suggestion is inline *and* the suggested code is
/// empty.
ShowCode,
/// Always show the suggested code independently.
ShowAlways,
}

impl SuggestionStyle {
Expand Down
57 changes: 32 additions & 25 deletions src/libsyntax/parse/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ use syntax_pos::{Span, DUMMY_SP, MultiSpan, SpanSnippetError};
use log::{debug, trace};
use std::mem;

const TURBOFISH: &'static str = "use the \"turbofish\" `::<...>` instead of `<...>` to specify \
type arguments";
const TURBOFISH: &'static str = "use `::<...>` instead of `<...>` to specify type arguments";
/// Creates a placeholder argument.
crate fn dummy_arg(ident: Ident) -> Param {
let pat = P(Pat {
Expand Down Expand Up @@ -585,7 +584,7 @@ impl<'a> Parser<'a> {
);

let suggest = |err: &mut DiagnosticBuilder<'_>| {
err.span_suggestion(
err.span_suggestion_verbose(
op_span.shrink_to_lo(),
TURBOFISH,
"::".to_string(),
Expand Down Expand Up @@ -647,29 +646,16 @@ impl<'a> Parser<'a> {
// We have high certainty that this was a bad turbofish at this point.
// `foo< bar >(`
suggest(&mut err);

let snapshot = self.clone();
self.bump(); // `(`

// Consume the fn call arguments.
let modifiers = [
(token::OpenDelim(token::Paren), 1),
(token::CloseDelim(token::Paren), -1),
];
self.consume_tts(1, &modifiers[..]);

if self.token.kind == token::Eof {
// Not entirely sure now, but we bubble the error up with the
// suggestion.
mem::replace(self, snapshot);
Err(err)
} else {
// 99% certain that the suggestion is correct, continue parsing.
err.emit();
// FIXME: actually check that the two expressions in the binop are
// paths and resynthesize new fn call expression instead of using
// `ExprKind::Err` placeholder.
mk_err_expr(self, lhs.span.to(self.prev_span))
match self.consume_fn_args() {
Err(()) => Err(err),
Ok(()) => {
err.emit();
// FIXME: actually check that the two expressions in the binop are
// paths and resynthesize new fn call expression instead of using
// `ExprKind::Err` placeholder.
mk_err_expr(self, lhs.span.to(self.prev_span))
}
}
} else {
// All we know is that this is `foo < bar >` and *nothing* else. Try to
Expand All @@ -687,6 +673,27 @@ impl<'a> Parser<'a> {
Ok(None)
}

fn consume_fn_args(&mut self) -> Result<(), ()> {
let snapshot = self.clone();
self.bump(); // `(`

// Consume the fn call arguments.
let modifiers = [
(token::OpenDelim(token::Paren), 1),
(token::CloseDelim(token::Paren), -1),
];
self.consume_tts(1, &modifiers[..]);

if self.token.kind == token::Eof {
// Not entirely sure that what we consumed were fn arguments, rollback.
mem::replace(self, snapshot);
Err(())
} else {
// 99% certain that the suggestion is correct, continue parsing.
Ok(())
}
}

crate fn maybe_report_ambiguous_plus(
&mut self,
allow_plus: bool,
Expand Down
6 changes: 3 additions & 3 deletions src/test/ui/did_you_mean/issue-40396.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ error: chained comparison operators require parentheses
|
LL | (0..13).collect<Vec<i32>>();
| ^^^^^
help: use the "turbofish" `::<...>` instead of `<...>` to specify type arguments
help: use `::<...>` instead of `<...>` to specify type arguments
|
LL | (0..13).collect::<Vec<i32>>();
| ^^
Expand All @@ -13,7 +13,7 @@ error: chained comparison operators require parentheses
|
LL | Vec<i32>::new();
| ^^^^^
help: use the "turbofish" `::<...>` instead of `<...>` to specify type arguments
help: use `::<...>` instead of `<...>` to specify type arguments
|
LL | Vec::<i32>::new();
| ^^
Expand All @@ -23,7 +23,7 @@ error: chained comparison operators require parentheses
|
LL | (0..13).collect<Vec<i32>();
| ^^^^^
help: use the "turbofish" `::<...>` instead of `<...>` to specify type arguments
help: use `::<...>` instead of `<...>` to specify type arguments
|
LL | (0..13).collect::<Vec<i32>();
| ^^
Expand Down
6 changes: 3 additions & 3 deletions src/test/ui/parser/require-parens-for-chained-comparison.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ fn main() {

f<X>();
//~^ ERROR chained comparison operators require parentheses
//~| HELP use the "turbofish" `::<...>` instead of `<...>` to specify type arguments
//~| HELP use `::<...>` instead of `<...>` to specify type arguments

f<Result<Option<X>, Option<Option<X>>>(1, 2);
//~^ ERROR chained comparison operators require parentheses
//~| HELP use the "turbofish" `::<...>` instead of `<...>` to specify type arguments
//~| HELP use `::<...>` instead of `<...>` to specify type arguments

use std::convert::identity;
let _ = identity<u8>;
//~^ ERROR chained comparison operators require parentheses
//~| HELP use the "turbofish" `::<...>` instead of `<...>` to specify type arguments
//~| HELP use `::<...>` instead of `<...>` to specify type arguments
//~| HELP or use `(...)` if you meant to specify fn arguments
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ error: chained comparison operators require parentheses
|
LL | f<X>();
| ^^^
help: use the "turbofish" `::<...>` instead of `<...>` to specify type arguments
help: use `::<...>` instead of `<...>` to specify type arguments
|
LL | f::<X>();
| ^^
Expand All @@ -25,7 +25,7 @@ error: chained comparison operators require parentheses
|
LL | f<Result<Option<X>, Option<Option<X>>>(1, 2);
| ^^^^^^^^
help: use the "turbofish" `::<...>` instead of `<...>` to specify type arguments
help: use `::<...>` instead of `<...>` to specify type arguments
|
LL | f::<Result<Option<X>, Option<Option<X>>>(1, 2);
| ^^
Expand All @@ -36,7 +36,7 @@ error: chained comparison operators require parentheses
LL | let _ = identity<u8>;
| ^^^^
|
= help: use the "turbofish" `::<...>` instead of `<...>` to specify type arguments
= help: use `::<...>` instead of `<...>` to specify type arguments
= help: or use `(...)` if you meant to specify fn arguments

error[E0308]: mismatched types
Expand Down