Skip to content

Commit 77fce75

Browse files
committed
remove unwrap_or! macro
1 parent 44995f7 commit 77fce75

File tree

3 files changed

+8
-17
lines changed

3 files changed

+8
-17
lines changed

compiler/rustc_ast/src/lib.rs

-10
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,6 @@
2020
#[macro_use]
2121
extern crate rustc_macros;
2222

23-
#[macro_export]
24-
macro_rules! unwrap_or {
25-
($opt:expr, $default:expr) => {
26-
match $opt {
27-
Some(x) => x,
28-
None => $default,
29-
}
30-
};
31-
}
32-
3323
pub mod util {
3424
pub mod classify;
3525
pub mod comments;

compiler/rustc_lint/src/levels.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use crate::context::{CheckLintNameResult, LintStore};
22
use crate::late::unerased_lint_store;
33
use rustc_ast as ast;
4-
use rustc_ast::unwrap_or;
54
use rustc_ast_pretty::pprust;
65
use rustc_data_structures::fx::FxHashMap;
76
use rustc_errors::{struct_span_err, Applicability, DiagnosticBuilder};
@@ -233,7 +232,10 @@ impl<'s> LintLevelsBuilder<'s> {
233232
Some(lvl) => lvl,
234233
};
235234

236-
let mut metas = unwrap_or!(attr.meta_item_list(), continue);
235+
let mut metas = match attr.meta_item_list() {
236+
Some(x) => x,
237+
None => continue,
238+
};
237239

238240
if metas.is_empty() {
239241
// FIXME (#55112): issue unused-attributes lint for `#[level()]`

compiler/rustc_resolve/src/imports.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ use crate::{BindingKey, ModuleKind, ResolutionError, Resolver, Segment};
99
use crate::{CrateLint, Module, ModuleOrUniformRoot, ParentScope, PerNS, ScopeSet, Weak};
1010
use crate::{NameBinding, NameBindingKind, PathResult, PrivacyError, ToNameBinding};
1111

12-
use rustc_ast::unwrap_or;
1312
use rustc_ast::NodeId;
1413
use rustc_data_structures::fx::FxHashSet;
1514
use rustc_data_structures::ptr_key::PtrKey;
@@ -349,10 +348,10 @@ impl<'a> Resolver<'a> {
349348
if !self.is_accessible_from(single_import.vis.get(), parent_scope.module) {
350349
continue;
351350
}
352-
let module = unwrap_or!(
353-
single_import.imported_module.get(),
354-
return Err((Undetermined, Weak::No))
355-
);
351+
let module = match single_import.imported_module.get() {
352+
Some(x) => x,
353+
None => return Err((Undetermined, Weak::No)),
354+
};
356355
let ident = match single_import.kind {
357356
ImportKind::Single { source, .. } => source,
358357
_ => unreachable!(),

0 commit comments

Comments
 (0)