diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2021-10-08 22:30:43 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-10-08 22:30:43 +0200 |
| commit | cda07c740cc98088dd383229dcc45e972c39b0fb (patch) | |
| tree | db91de3bcf78004fcc93ed988e4d8507a7ec3cc0 | |
| parent | 4adc8ea2ac7160a82283cac053c5f1ff5d27c7a9 (diff) | |
| parent | 77fce75ba1c6d08a1919d270b53fa1a454c5067e (diff) | |
| download | rust-cda07c740cc98088dd383229dcc45e972c39b0fb.tar.gz rust-cda07c740cc98088dd383229dcc45e972c39b0fb.zip | |
Rollup merge of #89672 - klensy:unwrap-or-macro, r=jackh726
Remove unwrap_or! macro Removes `unwrap_or!` macro and replaces it with `match`. It's kinda cleanup, as rustc_ast not the best place for this macro and this is used only in 2 places anyway.
| -rw-r--r-- | compiler/rustc_ast/src/lib.rs | 10 | ||||
| -rw-r--r-- | compiler/rustc_lint/src/levels.rs | 6 | ||||
| -rw-r--r-- | compiler/rustc_resolve/src/imports.rs | 9 |
3 files changed, 8 insertions, 17 deletions
diff --git a/compiler/rustc_ast/src/lib.rs b/compiler/rustc_ast/src/lib.rs index a6167773003..e3c610585d9 100644 --- a/compiler/rustc_ast/src/lib.rs +++ b/compiler/rustc_ast/src/lib.rs @@ -20,16 +20,6 @@ #[macro_use] extern crate rustc_macros; -#[macro_export] -macro_rules! unwrap_or { - ($opt:expr, $default:expr) => { - match $opt { - Some(x) => x, - None => $default, - } - }; -} - pub mod util { pub mod classify; pub mod comments; diff --git a/compiler/rustc_lint/src/levels.rs b/compiler/rustc_lint/src/levels.rs index 66966e589e4..b6d66eb12d0 100644 --- a/compiler/rustc_lint/src/levels.rs +++ b/compiler/rustc_lint/src/levels.rs @@ -1,7 +1,6 @@ use crate::context::{CheckLintNameResult, LintStore}; use crate::late::unerased_lint_store; use rustc_ast as ast; -use rustc_ast::unwrap_or; use rustc_ast_pretty::pprust; use rustc_data_structures::fx::FxHashMap; use rustc_errors::{struct_span_err, Applicability, DiagnosticBuilder}; @@ -233,7 +232,10 @@ impl<'s> LintLevelsBuilder<'s> { Some(lvl) => lvl, }; - let mut metas = unwrap_or!(attr.meta_item_list(), continue); + let mut metas = match attr.meta_item_list() { + Some(x) => x, + None => continue, + }; if metas.is_empty() { // FIXME (#55112): issue unused-attributes lint for `#[level()]` diff --git a/compiler/rustc_resolve/src/imports.rs b/compiler/rustc_resolve/src/imports.rs index 9be568b2cf1..515b2c3fd27 100644 --- a/compiler/rustc_resolve/src/imports.rs +++ b/compiler/rustc_resolve/src/imports.rs @@ -9,7 +9,6 @@ use crate::{BindingKey, ModuleKind, ResolutionError, Resolver, Segment}; use crate::{CrateLint, Module, ModuleOrUniformRoot, ParentScope, PerNS, ScopeSet, Weak}; use crate::{NameBinding, NameBindingKind, PathResult, PrivacyError, ToNameBinding}; -use rustc_ast::unwrap_or; use rustc_ast::NodeId; use rustc_data_structures::fx::FxHashSet; use rustc_data_structures::ptr_key::PtrKey; @@ -349,10 +348,10 @@ impl<'a> Resolver<'a> { if !self.is_accessible_from(single_import.vis.get(), parent_scope.module) { continue; } - let module = unwrap_or!( - single_import.imported_module.get(), - return Err((Undetermined, Weak::No)) - ); + let module = match single_import.imported_module.get() { + Some(x) => x, + None => return Err((Undetermined, Weak::No)), + }; let ident = match single_import.kind { ImportKind::Single { source, .. } => source, _ => unreachable!(), |
