Skip to content

Commit

Permalink
Merge pull request #279 from baszalmstra/bump/rust_1_4_7
Browse files Browse the repository at this point in the history
bump: rust 1.47
baszalmstra authored Oct 10, 2020

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
2 parents d806389 + 640d94e commit 04003e1
Showing 13 changed files with 172 additions and 338 deletions.
10 changes: 2 additions & 8 deletions crates/mun_abi/src/type_info.rs
Original file line number Diff line number Diff line change
@@ -104,18 +104,12 @@ unsafe impl Sync for TypeInfo {}
impl TypeGroup {
/// Returns whether this is a fundamental type.
pub fn is_fundamental(self) -> bool {
match self {
TypeGroup::FundamentalTypes => true,
_ => false,
}
self == TypeGroup::FundamentalTypes
}

/// Returns whether this is a struct type.
pub fn is_struct(self) -> bool {
match self {
TypeGroup::StructTypes => true,
_ => false,
}
self == TypeGroup::StructTypes
}
}

5 changes: 1 addition & 4 deletions crates/mun_compiler/src/driver/display_color.rs
Original file line number Diff line number Diff line change
@@ -22,10 +22,7 @@ impl DisplayColor {
/// Decides whether the current terminal supports ANSI escape codes based on the `term` environment variable and the operating system.
fn terminal_support_ansi() -> bool {
let supports_color = match env::var("TERM") {
Ok(terminal) => match terminal.as_str() {
"dumb" => false,
_ => true,
},
Ok(terminal) => terminal.as_str() == "dumb",
Err(_) => {
#[cfg(target_os = "windows")]
let term_support = cmd_supports_ansi();
1 change: 1 addition & 0 deletions crates/mun_hir/src/expr.rs
Original file line number Diff line number Diff line change
@@ -935,6 +935,7 @@ pub fn resolver_for_expr(body: Arc<Body>, db: &dyn HirDatabase, expr_id: ExprId)
resolver_for_scope(body, db, scopes.scope_for(expr_id))
}

#[allow(clippy::needless_collect)] // false positive https://github.com/rust-lang/rust-clippy/issues/5991
pub(crate) fn resolver_for_scope(
body: Arc<Body>,
db: &dyn HirDatabase,
10 changes: 2 additions & 8 deletions crates/mun_hir/src/ty.rs
Original file line number Diff line number Diff line change
@@ -108,10 +108,7 @@ impl Ty {
}

pub fn is_never(&self) -> bool {
match self.as_simple() {
Some(TypeCtor::Never) => true,
_ => false,
}
self.as_simple() == Some(TypeCtor::Never)
}

/// Returns the callable definition for the given expression or `None` if the type does not
@@ -185,10 +182,7 @@ impl Ty {

/// Returns true if this instance represents a known type.
pub fn is_known(&self) -> bool {
match self {
Ty::Unknown => false,
_ => true,
}
*self == Ty::Unknown
}
}

10 changes: 2 additions & 8 deletions crates/mun_hir/src/ty/lower.rs
Original file line number Diff line number Diff line change
@@ -182,17 +182,11 @@ impl_froms!(CallableDef: Function, Struct);

impl CallableDef {
pub fn is_function(self) -> bool {
match self {
CallableDef::Function(_) => true,
_ => false,
}
matches!(self, CallableDef::Function(_))
}

pub fn is_struct(self) -> bool {
match self {
CallableDef::Struct(_) => true,
_ => false,
}
matches!(self, CallableDef::Struct(_))
}
}

8 changes: 4 additions & 4 deletions crates/mun_syntax/src/ast/extensions.rs
Original file line number Diff line number Diff line change
@@ -93,10 +93,10 @@ impl ast::PathSegment {
}

pub fn has_colon_colon(&self) -> bool {
match self.syntax.first_child_or_token().map(|s| s.kind()) {
Some(T![::]) => true,
_ => false,
}
matches!(
self.syntax.first_child_or_token().map(|s| s.kind()),
Some(T![::])
)
}
}

248 changes: 62 additions & 186 deletions crates/mun_syntax/src/ast/generated.rs

Large diffs are not rendered by default.

11 changes: 5 additions & 6 deletions crates/mun_syntax/src/ast/generated.rs.tera
Original file line number Diff line number Diff line change
@@ -24,14 +24,13 @@ pub struct {{ node }} {

impl AstNode for {{ node }} {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
matches!(kind,
{%- if methods.enum %}
{% for kind in methods.enum %} | {{ kind | SCREAM }} {%- endfor -%}
{% for kind in methods.enum %} {% if loop.index > 1 %}| {% endif %}{{ kind | SCREAM }} {%- endfor -%}
{% else %}
{{ node | SCREAM }}
{%- endif %} => true,
_ => false,
}
{%- endif %}
)
}
fn cast(syntax: SyntaxNode) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
@@ -109,4 +108,4 @@ impl {{ node }} {
{%- endif -%}
}

{% endfor %}
{% endfor %}
10 changes: 2 additions & 8 deletions crates/mun_syntax/src/parsing/grammar/paths.rs
Original file line number Diff line number Diff line change
@@ -3,10 +3,7 @@ use super::*;
pub(super) const PATH_FIRST: TokenSet = token_set![IDENT, SELF_KW, SUPER_KW, COLONCOLON];

pub(super) fn is_path_start(p: &Parser) -> bool {
match p.current() {
IDENT | T![::] => true,
_ => false,
}
matches!(p.current(), IDENT | T![::])
}

pub(super) fn type_path(p: &mut Parser) {
@@ -27,10 +24,7 @@ fn path(p: &mut Parser, mode: Mode) {
path_segment(p, mode, true);
let mut qualifier = path.complete(p, PATH);
loop {
let import_tree = match p.nth(1) {
T![*] | T!['{'] => true,
_ => false,
};
let import_tree = matches!(p.nth(1), T![*] | T!['{']);
if p.at(T![::]) && !import_tree {
let path = qualifier.precede(p);
p.bump(T![::]);
5 changes: 1 addition & 4 deletions crates/mun_syntax/src/syntax_kind.rs
Original file line number Diff line number Diff line change
@@ -17,9 +17,6 @@ pub(crate) struct SyntaxInfo {

impl SyntaxKind {
pub fn is_trivia(self) -> bool {
match self {
SyntaxKind::WHITESPACE | SyntaxKind::COMMENT => true,
_ => false,
}
matches!(self, SyntaxKind::WHITESPACE | SyntaxKind::COMMENT)
}
}
166 changes: 80 additions & 86 deletions crates/mun_syntax/src/syntax_kind/generated.rs
Original file line number Diff line number Diff line change
@@ -380,100 +380,94 @@ impl From<SyntaxKind> for u16 {
impl SyntaxKind {
#[rustfmt::skip]
pub fn is_keyword(self) -> bool {
match self {
| BREAK_KW
| DO_KW
| ELSE_KW
| FALSE_KW
| FOR_KW
| FN_KW
| IF_KW
| IN_KW
| NIL_KW
| RETURN_KW
| TRUE_KW
| WHILE_KW
| LOOP_KW
| LET_KW
| MUT_KW
| CLASS_KW
| STRUCT_KW
| NEVER_KW
| PUB_KW
| TYPE_KW
| PACKAGE_KW
| SUPER_KW
| SELF_KW
| EXTERN_KW
=> true,
_ => false
}
matches!(self,
BREAK_KW
| DO_KW
| ELSE_KW
| FALSE_KW
| FOR_KW
| FN_KW
| IF_KW
| IN_KW
| NIL_KW
| RETURN_KW
| TRUE_KW
| WHILE_KW
| LOOP_KW
| LET_KW
| MUT_KW
| CLASS_KW
| STRUCT_KW
| NEVER_KW
| PUB_KW
| TYPE_KW
| PACKAGE_KW
| SUPER_KW
| SELF_KW
| EXTERN_KW
)
}

#[rustfmt::skip]
pub fn is_symbol(self) -> bool {
match self {
| AMP
| PIPE
| PLUS
| MINUS
| STAR
| SLASH
| PERCENT
| CARET
| HASH
| DOT
| LT
| GT
| EQ
| L_PAREN
| R_PAREN
| L_CURLY
| R_CURLY
| L_BRACKET
| R_BRACKET
| SEMI
| COLON
| COMMA
| EXCLAMATION
| UNDERSCORE
| EQEQ
| NEQ
| LTEQ
| GTEQ
| DOTDOT
| DOTDOTDOT
| PLUSEQ
| MINUSEQ
| STAREQ
| SLASHEQ
| PERCENTEQ
| SHLEQ
| SHREQ
| AMPEQ
| PIPEEQ
| CARETEQ
| DOTDOTEQ
| COLONCOLON
| THIN_ARROW
| AMPAMP
| PIPEPIPE
| SHL
| SHR
=> true,
_ => false
}
matches!(self,
AMP
| PIPE
| PLUS
| MINUS
| STAR
| SLASH
| PERCENT
| CARET
| HASH
| DOT
| LT
| GT
| EQ
| L_PAREN
| R_PAREN
| L_CURLY
| R_CURLY
| L_BRACKET
| R_BRACKET
| SEMI
| COLON
| COMMA
| EXCLAMATION
| UNDERSCORE
| EQEQ
| NEQ
| LTEQ
| GTEQ
| DOTDOT
| DOTDOTDOT
| PLUSEQ
| MINUSEQ
| STAREQ
| SLASHEQ
| PERCENTEQ
| SHLEQ
| SHREQ
| AMPEQ
| PIPEEQ
| CARETEQ
| DOTDOTEQ
| COLONCOLON
| THIN_ARROW
| AMPAMP
| PIPEPIPE
| SHL
| SHR
)
}

#[rustfmt::skip]
pub fn is_literal(self) -> bool {
match self {
| INT_NUMBER
| FLOAT_NUMBER
| STRING
=> true,
_ => false
}
matches!(self,
INT_NUMBER
| FLOAT_NUMBER
| STRING
)
}

#[rustfmt::skip]
24 changes: 9 additions & 15 deletions crates/mun_syntax/src/syntax_kind/generated.rs.tera
Original file line number Diff line number Diff line change
@@ -70,35 +70,29 @@ impl From<SyntaxKind> for u16 {
impl SyntaxKind {
#[rustfmt::skip]
pub fn is_keyword(self) -> bool {
match self {
matches!(self,
{%- for kw in keywords %}
| {{kw | upper}}_KW
{% if loop.index > 1 %}| {% endif %}{{kw | upper}}_KW
{%- endfor %}
=> true,
_ => false
}
)
}

#[rustfmt::skip]
pub fn is_symbol(self) -> bool {
match self {
matches!(self,
{%- for t in concat(a=single_char_tokens, b=multi_char_tokens) %}
| {{t.1}}
{% if loop.index > 1 %}| {% endif %}{{t.1}}
{%- endfor %}
=> true,
_ => false
}
)
}

#[rustfmt::skip]
pub fn is_literal(self) -> bool {
match self {
matches!(self,
{%- for t in literals %}
| {{t}}
{% if loop.index > 1 %}| {% endif %}{{t}}
{%- endfor %}
=> true,
_ => false
}
)
}

#[rustfmt::skip]
2 changes: 1 addition & 1 deletion rust-toolchain
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.46.0
1.47.0

0 comments on commit 04003e1

Please sign in to comment.