Rollup merge of #138682 - Alexendoo:extra-symbols, r=fee1-dead
Allow drivers to supply a list of extra symbols to intern
Allows adding new symbols as `const`s in external drivers, desirable in Clippy so we can use them in patterns to replace code like 75530e9f72/src/tools/clippy/clippy_lints/src/casts/cast_ptr_alignment.rs (L66)
The Clippy change adds a couple symbols as a demo, the exact `clippy_utils` API and replacing other usages can be done on the Clippy side to minimise sync conflicts
---
try-job: aarch64-gnu
This commit is contained in:
commit
65105f1324
7 changed files with 33 additions and 6 deletions
|
|
@ -3,6 +3,7 @@
|
|||
#![feature(f128)]
|
||||
#![feature(f16)]
|
||||
#![feature(if_let_guard)]
|
||||
#![feature(macro_metavar_expr)]
|
||||
#![feature(macro_metavar_expr_concat)]
|
||||
#![feature(let_chains)]
|
||||
#![feature(never_type)]
|
||||
|
|
@ -74,6 +75,7 @@ pub mod qualify_min_const_fn;
|
|||
pub mod source;
|
||||
pub mod str_utils;
|
||||
pub mod sugg;
|
||||
pub mod sym;
|
||||
pub mod ty;
|
||||
pub mod usage;
|
||||
pub mod visitors;
|
||||
|
|
@ -126,7 +128,7 @@ use rustc_middle::ty::{
|
|||
use rustc_span::hygiene::{ExpnKind, MacroKind};
|
||||
use rustc_span::source_map::SourceMap;
|
||||
use rustc_span::symbol::{Ident, Symbol, kw};
|
||||
use rustc_span::{InnerSpan, Span, sym};
|
||||
use rustc_span::{InnerSpan, Span};
|
||||
use visitors::{Visitable, for_each_unconsumed_temporary};
|
||||
|
||||
use crate::consts::{ConstEvalCtxt, Constant, mir_to_const};
|
||||
|
|
|
|||
23
clippy_utils/src/sym.rs
Normal file
23
clippy_utils/src/sym.rs
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
#![allow(non_upper_case_globals)]
|
||||
|
||||
use rustc_span::symbol::{Symbol, PREDEFINED_SYMBOLS_COUNT};
|
||||
|
||||
pub use rustc_span::sym::*;
|
||||
|
||||
macro_rules! generate {
|
||||
($($sym:ident,)*) => {
|
||||
/// To be supplied to `rustc_interface::Config`
|
||||
pub const EXTRA_SYMBOLS: &[&str] = &[
|
||||
$(stringify!($sym),)*
|
||||
];
|
||||
|
||||
$(
|
||||
pub const $sym: Symbol = Symbol::new(PREDEFINED_SYMBOLS_COUNT + ${index()});
|
||||
)*
|
||||
};
|
||||
}
|
||||
|
||||
generate! {
|
||||
rustfmt_skip,
|
||||
unused_extern_crates,
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue