Skip to content
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

Rollup of 8 pull requests #100881

Merged
merged 25 commits into from
Aug 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
90abfe9
expand inner `or` pattern
ouz-a Jun 17, 2022
661d488
use true recursion
ouz-a Jun 24, 2022
f7d8805
Fix `Ipv6Addr::is_global` to check for global reachability rather tha…
CDirkx Jun 25, 2021
f299064
Change `Ipv4Addr::is_global` to be in line with `Ipv6Addr::is_global`
CDirkx Jun 25, 2021
3365b06
Reincorporated changes from #87689
chotchki Jul 30, 2022
f659088
Original branch seems to have missed excluding the benchmark range fr…
chotchki Jul 30, 2022
2bb7e1e
Guarantee `try_reserve` preserves the contents on error
lo48576 Aug 9, 2022
ee30cc8
make some const prop tests unit-test
Noratrieb Jul 26, 2022
ddf23cb
add new test and combine old ones
ouz-a Aug 17, 2022
ed084ba
Remove useless pointer cast
WaffleLapkin Aug 19, 2022
efef211
Make use of `pointer::is_aligned[_to]`
WaffleLapkin Aug 19, 2022
ffcaa0d
Migrate diagnostics in parser/expr to SessionDiagnostic
Xiretza Aug 17, 2022
0227b71
Add guarantee that Vec::default() does not alloc
JanBeh Aug 22, 2022
d744f36
Fix wf check on `#[const_trait]` return types
fee1-dead Aug 9, 2022
460daf3
remove stray comment
fee1-dead Aug 22, 2022
f019b6c
Overhaul 100222 test; wf always remap to nonconst
fee1-dead Aug 22, 2022
f1db3be
fix tidy
fee1-dead Aug 22, 2022
56ba13a
Rollup merge of #98200 - ouz-a:issue-98177, r=oli-obk
Dylan-DPC Aug 22, 2022
e77c208
Rollup merge of #99770 - Nilstrieb:mir-pass-unit-test, r=oli-obk
Dylan-DPC Aug 22, 2022
c1a5ec7
Rollup merge of #99957 - chotchki:ip-globally-reachable_rebase, r=Mar…
Dylan-DPC Aug 22, 2022
382ba73
Rollup merge of #100331 - lo48576:try-reserve-preserve-on-failure, r=…
Dylan-DPC Aug 22, 2022
14c8a68
Rollup merge of #100336 - fee1-dead-contrib:fix-wf-const-trait, r=oli…
Dylan-DPC Aug 22, 2022
75b7089
Rollup merge of #100713 - Xiretza:parser-expr-session-diagnostics, r=…
Dylan-DPC Aug 22, 2022
58d2373
Rollup merge of #100820 - WaffleLapkin:use_ptr_is_aligned_methods, r=…
Dylan-DPC Aug 22, 2022
4ed8fa4
Rollup merge of #100872 - JanBeh:PR_vec_default_alloc_doc, r=fee1-dead
Dylan-DPC Aug 22, 2022
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
109 changes: 109 additions & 0 deletions compiler/rustc_error_messages/locales/en-US/parser.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,112 @@ parser_switch_mut_let_order =
parser_missing_let_before_mut = missing keyword
parser_use_let_not_auto = write `let` instead of `auto` to introduce a new variable
parser_use_let_not_var = write `let` instead of `var` to introduce a new variable

parser_invalid_comparison_operator = invalid comparison operator `{$invalid}`
.use_instead = `{$invalid}` is not a valid comparison operator, use `{$correct}`
.spaceship_operator_invalid = `<=>` is not a valid comparison operator, use `std::cmp::Ordering`

parser_invalid_logical_operator = `{$incorrect}` is not a logical operator
.note = unlike in e.g., python and PHP, `&&` and `||` are used for logical operators
.use_amp_amp_for_conjunction = use `&&` to perform logical conjunction
.use_pipe_pipe_for_disjunction = use `||` to perform logical disjunction

parser_tilde_is_not_unary_operator = `~` cannot be used as a unary operator
.suggestion = use `!` to perform bitwise not

parser_unexpected_token_after_not = unexpected {$negated_desc} after identifier
.suggestion = use `!` to perform logical negation

parser_malformed_loop_label = malformed loop label
.suggestion = use the correct loop label format

parser_lifetime_in_borrow_expression = borrow expressions cannot be annotated with lifetimes
.suggestion = remove the lifetime annotation
.label = annotated with lifetime here

parser_field_expression_with_generic = field expressions cannot have generic arguments

parser_macro_invocation_with_qualified_path = macros cannot use qualified paths

parser_unexpected_token_after_label = expected `while`, `for`, `loop` or `{"{"}` after a label

parser_require_colon_after_labeled_expression = labeled expression must be followed by `:`
.note = labels are used before loops and blocks, allowing e.g., `break 'label` to them
.label = the label
.suggestion = add `:` after the label

parser_do_catch_syntax_removed = found removed `do catch` syntax
.note = following RFC #2388, the new non-placeholder syntax is `try`
.suggestion = replace with the new syntax

parser_float_literal_requires_integer_part = float literals must have an integer part
.suggestion = must have an integer part

parser_invalid_int_literal_width = invalid width `{$width}` for integer literal
.help = valid widths are 8, 16, 32, 64 and 128

parser_invalid_num_literal_base_prefix = invalid base prefix for number literal
.note = base prefixes (`0xff`, `0b1010`, `0o755`) are lowercase
.suggestion = try making the prefix lowercase

parser_invalid_num_literal_suffix = invalid suffix `{$suffix}` for number literal
.label = invalid suffix `{$suffix}`
.help = the suffix must be one of the numeric types (`u32`, `isize`, `f32`, etc.)

parser_invalid_float_literal_width = invalid width `{$width}` for float literal
.help = valid widths are 32 and 64

parser_invalid_float_literal_suffix = invalid suffix `{$suffix}` for float literal
.label = invalid suffix `{$suffix}`
.help = valid suffixes are `f32` and `f64`

parser_int_literal_too_large = integer literal is too large

parser_missing_semicolon_before_array = expected `;`, found `[`
.suggestion = consider adding `;` here

parser_invalid_block_macro_segment = cannot use a `block` macro fragment here
.label = the `block` fragment is within this context

parser_if_expression_missing_then_block = this `if` expression is missing a block after the condition
.add_then_block = add a block here
.condition_possibly_unfinished = this binary operation is possibly unfinished

parser_if_expression_missing_condition = missing condition for `if` expression
.condition_label = expected condition here
.block_label = if this block is the condition of the `if` expression, then it must be followed by another block

parser_expected_expression_found_let = expected expression, found `let` statement

parser_expected_else_block = expected `{"{"}`, found {$first_tok}
.label = expected an `if` or a block after this `else`
.suggestion = add an `if` if this is the condition of a chained `else if` statement

parser_outer_attribute_not_allowed_on_if_else = outer attributes are not allowed on `if` and `else` branches
.branch_label = the attributes are attached to this branch
.ctx_label = the branch belongs to this `{$ctx}`
.suggestion = remove the attributes

parser_missing_in_in_for_loop = missing `in` in `for` loop
.use_in_not_of = try using `in` here instead
.add_in = try adding `in` here

parser_missing_comma_after_match_arm = expected `,` following `match` arm
.suggestion = missing a comma here to end this `match` arm

parser_catch_after_try = keyword `catch` cannot follow a `try` block
.help = try using `match` on the result of the `try` block instead

parser_comma_after_base_struct = cannot use a comma after the base struct
.note = the base struct must always be the last field
.suggestion = remove this comma

parser_eq_field_init = expected `:`, found `=`
.suggestion = replace equals symbol with a colon

parser_dotdotdot = unexpected token: `...`
.suggest_exclusive_range = use `..` for an exclusive range
.suggest_inclusive_range = or `..=` for an inclusive range

parser_left_arrow_operator = unexpected token: `<-`
.suggestion = if you meant to write a comparison against a negative value, add a space in between `<` and `-`
23 changes: 19 additions & 4 deletions compiler/rustc_mir_build/src/thir/pattern/usefulness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -364,8 +364,8 @@ impl<'a, 'p, 'tcx> fmt::Debug for PatCtxt<'a, 'p, 'tcx> {
/// A row of a matrix. Rows of len 1 are very common, which is why `SmallVec[_; 2]`
/// works well.
#[derive(Clone)]
struct PatStack<'p, 'tcx> {
pats: SmallVec<[&'p DeconstructedPat<'p, 'tcx>; 2]>,
pub(crate) struct PatStack<'p, 'tcx> {
pub(crate) pats: SmallVec<[&'p DeconstructedPat<'p, 'tcx>; 2]>,
}

impl<'p, 'tcx> PatStack<'p, 'tcx> {
Expand Down Expand Up @@ -403,6 +403,21 @@ impl<'p, 'tcx> PatStack<'p, 'tcx> {
})
}

// Recursively expand all patterns into their subpatterns and push each `PatStack` to matrix.
fn expand_and_extend<'a>(&'a self, matrix: &mut Matrix<'p, 'tcx>) {
if !self.is_empty() && self.head().is_or_pat() {
for pat in self.head().iter_fields() {
let mut new_patstack = PatStack::from_pattern(pat);
new_patstack.pats.extend_from_slice(&self.pats[1..]);
if !new_patstack.is_empty() && new_patstack.head().is_or_pat() {
new_patstack.expand_and_extend(matrix);
} else if !new_patstack.is_empty() {
matrix.push(new_patstack);
}
}
}
}

/// This computes `S(self.head().ctor(), self)`. See top of the file for explanations.
///
/// Structure patterns with a partial wild pattern (Foo { a: 42, .. }) have their missing
Expand Down Expand Up @@ -436,7 +451,7 @@ impl<'p, 'tcx> fmt::Debug for PatStack<'p, 'tcx> {
/// A 2D matrix.
#[derive(Clone)]
pub(super) struct Matrix<'p, 'tcx> {
patterns: Vec<PatStack<'p, 'tcx>>,
pub patterns: Vec<PatStack<'p, 'tcx>>,
}

impl<'p, 'tcx> Matrix<'p, 'tcx> {
Expand All @@ -453,7 +468,7 @@ impl<'p, 'tcx> Matrix<'p, 'tcx> {
/// expands it.
fn push(&mut self, row: PatStack<'p, 'tcx>) {
if !row.is_empty() && row.head().is_or_pat() {
self.patterns.extend(row.expand_or_pat());
row.expand_and_extend(self);
} else {
self.patterns.push(row);
}
Expand Down
Loading