Skip to content

Commit bdee6b8

Browse files
committed
Move some macros.
1 parent d0a2a3f commit bdee6b8

File tree

3 files changed

+102
-100
lines changed

3 files changed

+102
-100
lines changed

src/librustc/lint/mod.rs

Lines changed: 0 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -169,56 +169,6 @@ macro_rules! declare_late_lint_pass {
169169

170170
late_lint_methods!(declare_late_lint_pass, [], ['tcx]);
171171

172-
#[macro_export]
173-
macro_rules! expand_combined_late_lint_pass_method {
174-
([$($passes:ident),*], $self: ident, $name: ident, $params:tt) => ({
175-
$($self.$passes.$name $params;)*
176-
})
177-
}
178-
179-
#[macro_export]
180-
macro_rules! expand_combined_late_lint_pass_methods {
181-
($passes:tt, [$($(#[$attr:meta])* fn $name:ident($($param:ident: $arg:ty),*);)*]) => (
182-
$(fn $name(&mut self, context: &LateContext<'a, 'tcx>, $($param: $arg),*) {
183-
expand_combined_late_lint_pass_method!($passes, self, $name, (context, $($param),*));
184-
})*
185-
)
186-
}
187-
188-
#[macro_export]
189-
macro_rules! declare_combined_late_lint_pass {
190-
([$v:vis $name:ident, [$($passes:ident: $constructor:expr,)*]], [$hir:tt], $methods:tt) => (
191-
#[allow(non_snake_case)]
192-
$v struct $name {
193-
$($passes: $passes,)*
194-
}
195-
196-
impl $name {
197-
$v fn new() -> Self {
198-
Self {
199-
$($passes: $constructor,)*
200-
}
201-
}
202-
203-
$v fn get_lints() -> LintArray {
204-
let mut lints = Vec::new();
205-
$(lints.extend_from_slice(&$passes::get_lints());)*
206-
lints
207-
}
208-
}
209-
210-
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for $name {
211-
expand_combined_late_lint_pass_methods!([$($passes),*], $methods);
212-
}
213-
214-
impl LintPass for $name {
215-
fn name(&self) -> &'static str {
216-
panic!()
217-
}
218-
}
219-
)
220-
}
221-
222172
#[macro_export]
223173
macro_rules! early_lint_methods {
224174
($macro:path, $args:tt) => (
@@ -296,56 +246,6 @@ macro_rules! declare_early_lint_pass {
296246

297247
early_lint_methods!(declare_early_lint_pass, []);
298248

299-
#[macro_export]
300-
macro_rules! expand_combined_early_lint_pass_method {
301-
([$($passes:ident),*], $self: ident, $name: ident, $params:tt) => ({
302-
$($self.$passes.$name $params;)*
303-
})
304-
}
305-
306-
#[macro_export]
307-
macro_rules! expand_combined_early_lint_pass_methods {
308-
($passes:tt, [$($(#[$attr:meta])* fn $name:ident($($param:ident: $arg:ty),*);)*]) => (
309-
$(fn $name(&mut self, context: &EarlyContext<'_>, $($param: $arg),*) {
310-
expand_combined_early_lint_pass_method!($passes, self, $name, (context, $($param),*));
311-
})*
312-
)
313-
}
314-
315-
#[macro_export]
316-
macro_rules! declare_combined_early_lint_pass {
317-
([$v:vis $name:ident, [$($passes:ident: $constructor:expr,)*]], $methods:tt) => (
318-
#[allow(non_snake_case)]
319-
$v struct $name {
320-
$($passes: $passes,)*
321-
}
322-
323-
impl $name {
324-
$v fn new() -> Self {
325-
Self {
326-
$($passes: $constructor,)*
327-
}
328-
}
329-
330-
$v fn get_lints() -> LintArray {
331-
let mut lints = Vec::new();
332-
$(lints.extend_from_slice(&$passes::get_lints());)*
333-
lints
334-
}
335-
}
336-
337-
impl EarlyLintPass for $name {
338-
expand_combined_early_lint_pass_methods!([$($passes),*], $methods);
339-
}
340-
341-
impl LintPass for $name {
342-
fn name(&self) -> &'static str {
343-
panic!()
344-
}
345-
}
346-
)
347-
}
348-
349249
/// A lint pass boxed up as a trait object.
350250
pub type EarlyLintPassObject = Box<dyn EarlyLintPass + sync::Send + sync::Sync + 'static>;
351251
pub type LateLintPassObject =

src/librustc_lint/early.rs

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,3 +381,54 @@ pub fn check_ast_crate<T: EarlyLintPass>(
381381
}
382382
}
383383
}
384+
385+
#[macro_export]
386+
macro_rules! expand_combined_early_lint_pass_method {
387+
([$($passes:ident),*], $self: ident, $name: ident, $params:tt) => ({
388+
$($self.$passes.$name $params;)*
389+
})
390+
}
391+
392+
#[macro_export]
393+
macro_rules! expand_combined_early_lint_pass_methods {
394+
($passes:tt, [$($(#[$attr:meta])* fn $name:ident($($param:ident: $arg:ty),*);)*]) => (
395+
$(fn $name(&mut self, context: &EarlyContext<'_>, $($param: $arg),*) {
396+
expand_combined_early_lint_pass_method!($passes, self, $name, (context, $($param),*));
397+
})*
398+
)
399+
}
400+
401+
#[macro_export]
402+
macro_rules! declare_combined_early_lint_pass {
403+
([$v:vis $name:ident, [$($passes:ident: $constructor:expr,)*]], $methods:tt) => (
404+
#[allow(non_snake_case)]
405+
$v struct $name {
406+
$($passes: $passes,)*
407+
}
408+
409+
impl $name {
410+
$v fn new() -> Self {
411+
Self {
412+
$($passes: $constructor,)*
413+
}
414+
}
415+
416+
$v fn get_lints() -> LintArray {
417+
let mut lints = Vec::new();
418+
$(lints.extend_from_slice(&$passes::get_lints());)*
419+
lints
420+
}
421+
}
422+
423+
impl EarlyLintPass for $name {
424+
expand_combined_early_lint_pass_methods!([$($passes),*], $methods);
425+
}
426+
427+
#[allow(rustc::lint_pass_impl_without_macro)]
428+
impl LintPass for $name {
429+
fn name(&self) -> &'static str {
430+
panic!()
431+
}
432+
}
433+
)
434+
}

src/librustc_lint/late.rs

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -471,3 +471,54 @@ pub fn check_crate<'tcx, T: for<'a> LateLintPass<'a, 'tcx>>(
471471
},
472472
);
473473
}
474+
475+
#[macro_export]
476+
macro_rules! expand_combined_late_lint_pass_method {
477+
([$($passes:ident),*], $self: ident, $name: ident, $params:tt) => ({
478+
$($self.$passes.$name $params;)*
479+
})
480+
}
481+
482+
#[macro_export]
483+
macro_rules! expand_combined_late_lint_pass_methods {
484+
($passes:tt, [$($(#[$attr:meta])* fn $name:ident($($param:ident: $arg:ty),*);)*]) => (
485+
$(fn $name(&mut self, context: &LateContext<'a, 'tcx>, $($param: $arg),*) {
486+
expand_combined_late_lint_pass_method!($passes, self, $name, (context, $($param),*));
487+
})*
488+
)
489+
}
490+
491+
#[macro_export]
492+
macro_rules! declare_combined_late_lint_pass {
493+
([$v:vis $name:ident, [$($passes:ident: $constructor:expr,)*]], [$hir:tt], $methods:tt) => (
494+
#[allow(non_snake_case)]
495+
$v struct $name {
496+
$($passes: $passes,)*
497+
}
498+
499+
impl $name {
500+
$v fn new() -> Self {
501+
Self {
502+
$($passes: $constructor,)*
503+
}
504+
}
505+
506+
$v fn get_lints() -> LintArray {
507+
let mut lints = Vec::new();
508+
$(lints.extend_from_slice(&$passes::get_lints());)*
509+
lints
510+
}
511+
}
512+
513+
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for $name {
514+
expand_combined_late_lint_pass_methods!([$($passes),*], $methods);
515+
}
516+
517+
#[allow(rustc::lint_pass_impl_without_macro)]
518+
impl LintPass for $name {
519+
fn name(&self) -> &'static str {
520+
panic!()
521+
}
522+
}
523+
)
524+
}

0 commit comments

Comments
 (0)