Repository: rust-lang/rust
File: compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs (Rust)

Code before:
        }
    }

    pub(crate) fn node_ty_opt(&self, id: HirId) -> Option<Ty<'tcx>> {
        match self.typeck_results.borrow().node_types().get(id) {
            Some(&t) => Some(t),
            None if let Some(e) = self.tainted_by_errors() => Some(Ty::new_error(self.tcx, e)),
            None => None,
        }
    }

    /// Registers an obligation for checking later, during regionck, that `arg` is well-formed.
    pub(crate) fn register_wf_obligation(
        &self,
        term: ty::Term<'tcx>,
        span: Span,
        code: traits::ObligationCauseCode<'tcx>,
    ) {
        // WF obligations never themselves fail, so no real need to give a detailed cause:
        let cause = self.cause(span, code);
        self.register_predicate(traits::Obligation::new(
            self.tcx,
            cause,
            self.param_env,
            ty::ClauseKind::WellFormed(term),
        ));
    }

    /// Registers obligations that all `args` are well-formed.
    pub(crate) fn add_wf_bounds(&self, args: GenericArgsRef<'tcx>, span: Span) {
        for term in args.iter().filter_map(ty::GenericArg::as_term) {
            self.register_wf_obligation(term, span, ObligationCauseCode::WellFormed(None));
        }
    }

    // FIXME(arielb1): use this instead of field.ty everywhere
    // Only for fields! Returns <none> for methods>
    // Indifferent to privacy flags
    pub(crate) fn field_ty(
        &self,
        span: Span,
        field: &'tcx ty::FieldDef,
        args: GenericArgsRef<'tcx>,
    ) -> Ty<'tcx> {
        self.normalize(span, field.ty(self.tcx, args))
    }

    /// Drain all obligations that are stalled on coroutines defined in this body.
    #[instrument(level = "debug", skip(self))]
    pub(crate) fn drain_stalled_coroutine_obligations(&self) {
        // Make as much inference progress as possible before

Review comment (suggestion):
```suggestion
        FIXME(mgca): should this also count stuff with infer consts
        t.has_free_regions() || t.has_aliases() || t.has_infer_types() || t.has_param()
```
drive by fixme xd

Code after:
        &self,
        const_arg: &'tcx hir::ConstArg<'tcx>,
        ty: Ty<'tcx>,
    ) -> ty::Const<'tcx> {
        let ct = self.lowerer().lower_const_arg(const_arg, ty);
        self.register_wf_obligation(
            ct.into(),
            self.tcx.hir_span(const_arg.hir_id),
            ObligationCauseCode::WellFormed(None),
        );
        ct
    }

    // If the type given by the user has free regions, save it for later, since
    // NLL would like to enforce those. Also pass in types that involve
    // projections, since those can resolve to `'static` bounds (modulo #54940,
    // which hopefully will be fixed by the time you see this comment, dear
    // reader, although I have my doubts). Also pass in types with inference
    // types, because they may be repeated. Other sorts of things are already
    // sufficiently enforced with erased regions. =)
    fn can_contain_user_lifetime_bounds<T>(t: T) -> bool
    where
        T: TypeVisitable<TyCtxt<'tcx>>,
    {
        // FIXME(mgca): should this also count stuff with infer consts
        t.has_free_regions() || t.has_aliases() || t.has_infer_types() || t.has_param()
    }

    pub(crate) fn node_ty(&self, id: HirId) -> Ty<'tcx> {
        match self.typeck_results.borrow().node_types().get(id) {
            Some(&t) => t,
            None if let Some(e) = self.tainted_by_errors() => Ty::new_error(self.tcx, e),
            None => {
                bug!("no type for node {} in fcx {}", self.tcx.hir_id_to_string(id), self.tag());
            }
        }
    }

    pub(crate) fn node_ty_opt(&self, id: HirId) -> Option<Ty<'tcx>> {
        match self.typeck_results.borrow().node_types().get(id) {
            Some(&t) => Some(t),
            None if let Some(e) = self.tainted_by_errors() => Some(Ty::new_error(self.tcx, e)),
            None => None,
        }
    }

    /// Registers an obligation for checking later, during regionck, that `arg` is well-formed.
    pub(crate) fn register_wf_obligation(
        &self,
        term: ty::Term<'tcx>,
        span: Span,