diff options
| author | Nadrieril <nadrieril+git@gmail.com> | 2023-12-11 20:46:35 +0100 |
|---|---|---|
| committer | Nadrieril <nadrieril+git@gmail.com> | 2023-12-15 16:58:37 +0100 |
| commit | 16bd6ac3ed3e63cd6f2464b54026dbeb90ba6bbe (patch) | |
| tree | 72ee0a128439ca447912eada407deb1ecc495dd9 /compiler/rustc_pattern_analysis/src/lib.rs | |
| parent | 42f43938248d1272c0b3edc85385bde322a9c7fc (diff) | |
| download | rust-16bd6ac3ed3e63cd6f2464b54026dbeb90ba6bbe.tar.gz rust-16bd6ac3ed3e63cd6f2464b54026dbeb90ba6bbe.zip | |
Gate rustc-specific code under a feature
Diffstat (limited to 'compiler/rustc_pattern_analysis/src/lib.rs')
| -rw-r--r-- | compiler/rustc_pattern_analysis/src/lib.rs | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/compiler/rustc_pattern_analysis/src/lib.rs b/compiler/rustc_pattern_analysis/src/lib.rs index d0eff55f5a1..8b7898af5b1 100644 --- a/compiler/rustc_pattern_analysis/src/lib.rs +++ b/compiler/rustc_pattern_analysis/src/lib.rs @@ -1,31 +1,40 @@ //! Analysis of patterns, notably match exhaustiveness checking. pub mod constructor; +#[cfg(feature = "rustc")] pub mod errors; +#[cfg(feature = "rustc")] pub(crate) mod lints; pub mod pat; +#[cfg(feature = "rustc")] pub mod rustc; pub mod usefulness; #[macro_use] extern crate tracing; +#[cfg(feature = "rustc")] #[macro_use] extern crate rustc_middle; +#[cfg(feature = "rustc")] rustc_fluent_macro::fluent_messages! { "../messages.ftl" } use std::fmt; -use constructor::{Constructor, ConstructorSet}; -use lints::PatternColumn; -use rustc_hir::HirId; use rustc_index::Idx; +#[cfg(feature = "rustc")] use rustc_middle::ty::Ty; -use usefulness::{compute_match_usefulness, ValidityConstraint}; -use crate::lints::{lint_nonexhaustive_missing_variants, lint_overlapping_range_endpoints}; +use crate::constructor::{Constructor, ConstructorSet}; +#[cfg(feature = "rustc")] +use crate::lints::{ + lint_nonexhaustive_missing_variants, lint_overlapping_range_endpoints, PatternColumn, +}; use crate::pat::DeconstructedPat; +#[cfg(feature = "rustc")] use crate::rustc::RustcCtxt; +#[cfg(feature = "rustc")] +use crate::usefulness::{compute_match_usefulness, ValidityConstraint}; pub trait MatchCx: Sized + Clone + fmt::Debug { type Ty: Copy + Clone + fmt::Debug; // FIXME: remove Copy @@ -72,6 +81,7 @@ impl<'p, Cx: MatchCx> Copy for MatchArm<'p, Cx> {} /// The entrypoint for this crate. Computes whether a match is exhaustive and which of its arms are /// useful, and runs some lints. +#[cfg(feature = "rustc")] pub fn analyze_match<'p, 'tcx>( cx: &RustcCtxt<'p, 'tcx>, arms: &[rustc::MatchArm<'p, 'tcx>], |
