1
Fork 0

Prefer doc comments over //-comments in compiler

This commit is contained in:
Maybe Waffle 2022-11-27 11:15:06 +00:00
parent 0e9eee6811
commit 1d42936b18
83 changed files with 400 additions and 387 deletions

View file

@ -2,35 +2,35 @@ use rustc_middle::thir::*;
#[derive(Debug, PartialEq)]
pub(crate) enum Category {
// An assignable memory location like `x`, `x.f`, `foo()[3]`, that
// sort of thing. Something that could appear on the LHS of an `=`
// sign.
/// An assignable memory location like `x`, `x.f`, `foo()[3]`, that
/// sort of thing. Something that could appear on the LHS of an `=`
/// sign.
Place,
// A literal like `23` or `"foo"`. Does not include constant
// expressions like `3 + 5`.
/// A literal like `23` or `"foo"`. Does not include constant
/// expressions like `3 + 5`.
Constant,
// Something that generates a new value at runtime, like `x + y`
// or `foo()`.
/// Something that generates a new value at runtime, like `x + y`
/// or `foo()`.
Rvalue(RvalueFunc),
}
// Rvalues fall into different "styles" that will determine which fn
// is best suited to generate them.
/// Rvalues fall into different "styles" that will determine which fn
/// is best suited to generate them.
#[derive(Debug, PartialEq)]
pub(crate) enum RvalueFunc {
// Best generated by `into`. This is generally exprs that
// cause branching, like `match`, but also includes calls.
/// Best generated by `into`. This is generally exprs that
/// cause branching, like `match`, but also includes calls.
Into,
// Best generated by `as_rvalue`. This is usually the case.
/// Best generated by `as_rvalue`. This is usually the case.
AsRvalue,
}
/// Determines the category for a given expression. Note that scope
/// and paren expressions have no category.
impl Category {
/// Determines the category for a given expression. Note that scope
/// and paren expressions have no category.
pub(crate) fn of(ek: &ExprKind<'_>) -> Option<Category> {
match *ek {
ExprKind::Scope { .. } => None,

View file

@ -34,8 +34,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
Operand::Constant(constant)
}
// Returns a zero literal operand for the appropriate type, works for
// bool, char and integers.
/// Returns a zero literal operand for the appropriate type, works for
/// bool, char and integers.
pub(crate) fn zero_literal(&mut self, span: Span, ty: Ty<'tcx>) -> Operand<'tcx> {
let literal = ConstantKind::from_bits(self.tcx, 0, ty::ParamEnv::empty().and(ty));

View file

@ -443,8 +443,9 @@ impl<'tcx> Scopes<'tcx> {
impl<'a, 'tcx> Builder<'a, 'tcx> {
// Adding and removing scopes
// ==========================
// Start a breakable scope, which tracks where `continue`, `break` and
// `return` should branch to.
/// Start a breakable scope, which tracks where `continue`, `break` and
/// `return` should branch to.
pub(crate) fn in_breakable_scope<F>(
&mut self,
loop_block: Option<BasicBlock>,
@ -799,6 +800,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
// Finding scopes
// ==============
/// Returns the scope that we should use as the lifetime of an
/// operand. Basically, an operand must live until it is consumed.
/// This is similar to, but not quite the same as, the temporary
@ -824,6 +826,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
// Scheduling drops
// ================
pub(crate) fn schedule_drop_storage_and_value(
&mut self,
span: Span,
@ -996,6 +999,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
// Other
// =====
/// Returns the [DropIdx] for the innermost drop if the function unwound at
/// this point. The `DropIdx` will be created if it doesn't already exist.
fn diverge_cleanup(&mut self) -> DropIdx {