[−][src]Struct rustc_lint::context::LateContext
Context for lint checking after type checking.
Fields
tcx: TyCtxt<'tcx>Type context we're checking in.
enclosing_body: Option<BodyId>Current body, or None if outside a body.
cached_typeck_results: Cell<Option<&'tcx TypeckResults<'tcx>>>Type-checking results for the current body. Access using the typeck_results
and maybe_typeck_results methods, which handle querying the typeck results on demand.
param_env: ParamEnv<'tcx>Parameter environment for the item we are in.
access_levels: &'tcx AccessLevelsItems accessible from the crate being checked.
lint_store: &'tcx LintStoreThe store of registered lints and the lint levels.
last_node_with_lint_attrs: HirIdgenerics: Option<&'tcx Generics<'tcx>>Generic type parameters in scope for the item we are in.
only_module: boolWe are only looking at one module
Implementations
impl<'tcx> LateContext<'tcx>[src]
pub fn maybe_typeck_results(&self) -> Option<&'tcx TypeckResults<'tcx>>[src]
Gets the type-checking results for the current body,
or None if outside a body.
pub fn typeck_results(&self) -> &'tcx TypeckResults<'tcx>[src]
Gets the type-checking results for the current body.
As this will ICE if called outside bodies, only call when working with
Expr or Pat nodes (they are guaranteed to be found only in bodies).
pub fn qpath_res(&self, qpath: &QPath<'_>, id: HirId) -> Res[src]
Returns the final resolution of a QPath, or Res::Err if unavailable.
Unlike .typeck_results().qpath_res(qpath, id), this can be used even outside
bodies (e.g. for paths in hir::Ty), without any risk of ICE-ing.
pub fn match_def_path(&self, def_id: DefId, path: &[Symbol]) -> bool[src]
Check if a DefId's path matches the given absolute type path usage.
Anonymous scopes such as extern imports are matched with kw::Invalid;
inherent impl blocks are matched with the name of the type.
Instead of using this method, it is often preferable to instead use
rustc_diagnostic_item or a lang_item. This is less prone to errors
as paths get invalidated if the target definition moves.
Examples
if cx.match_def_path(def_id, &[sym::core, sym::option, sym::Option]) { // The given `def_id` is that of an `Option` type }
pub fn get_def_path(&self, def_id: DefId) -> Vec<Symbol>[src]
Gets the absolute path of def_id as a vector of Symbol.
Examples
let def_path = cx.get_def_path(def_id); if let &[sym::core, sym::option, sym::Option] = &def_path[..] { // The given `def_id` is that of an `Option` type }
Trait Implementations
impl<'tcx> LayoutOf for LateContext<'tcx>[src]
type Ty = Ty<'tcx>
type TyAndLayout = Result<TyAndLayout<'tcx>, LayoutError<'tcx>>
pub fn layout_of(&self, ty: Ty<'tcx>) -> Self::TyAndLayout[src]
pub fn spanned_layout_of(&self, ty: Self::Ty, _span: Span) -> Self::TyAndLayout[src]
impl<'_> LintContext for LateContext<'_>[src]
type PassObject = Box<dyn LateLintPass<'tcx> + Send + Sync + 'static>
pub fn sess(&self) -> &Session[src]
Gets the overall compiler Session object.
pub fn lints(&self) -> &LintStore[src]
pub fn lookup<S: Into<MultiSpan>>(
&self,
lint: &'static Lint,
span: Option<S>,
decorate: impl for<'a> FnOnce(LintDiagnosticBuilder<'a>)
)[src]
&self,
lint: &'static Lint,
span: Option<S>,
decorate: impl for<'a> FnOnce(LintDiagnosticBuilder<'a>)
)
pub fn lookup_with_diagnostics(
&self,
lint: &'static Lint,
span: Option<impl Into<MultiSpan>>,
decorate: impl for<'a> FnOnce(LintDiagnosticBuilder<'a>),
diagnostic: BuiltinLintDiagnostics
)[src]
&self,
lint: &'static Lint,
span: Option<impl Into<MultiSpan>>,
decorate: impl for<'a> FnOnce(LintDiagnosticBuilder<'a>),
diagnostic: BuiltinLintDiagnostics
)
pub fn struct_span_lint<S: Into<MultiSpan>>(
&self,
lint: &'static Lint,
span: S,
decorate: impl for<'a> FnOnce(LintDiagnosticBuilder<'a>)
)[src]
&self,
lint: &'static Lint,
span: S,
decorate: impl for<'a> FnOnce(LintDiagnosticBuilder<'a>)
)
pub fn lint(
&self,
lint: &'static Lint,
decorate: impl for<'a> FnOnce(LintDiagnosticBuilder<'a>)
)[src]
&self,
lint: &'static Lint,
decorate: impl for<'a> FnOnce(LintDiagnosticBuilder<'a>)
)
Auto Trait Implementations
impl<'tcx> !RefUnwindSafe for LateContext<'tcx>
impl<'tcx> !Send for LateContext<'tcx>
impl<'tcx> !Sync for LateContext<'tcx>
impl<'tcx> Unpin for LateContext<'tcx>
impl<'tcx> !UnwindSafe for LateContext<'tcx>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T[src]
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,