From a907fec96730b88a7282e778a4919ef3691e4233 Mon Sep 17 00:00:00 2001 From: sofia Date: Wed, 9 Jul 2025 20:07:30 +0300 Subject: [PATCH] Fix module docs --- reid-llvm-lib/src/builder.rs | 5 ++-- reid-llvm-lib/src/compile.rs | 7 +++--- reid-llvm-lib/src/debug.rs | 3 ++- reid-llvm-lib/src/lib.rs | 7 +++--- reid/src/mir/mod.rs | 6 +++-- reid/src/mir/pass.rs | 5 ++-- reid/src/mir/typecheck.rs | 4 ++-- reid/src/pad_adapter.rs | 45 ++++++++++++++++++------------------ reid/src/token_stream.rs | 5 ++-- reid/src/util.rs | 7 +++--- 10 files changed, 52 insertions(+), 42 deletions(-) diff --git a/reid-llvm-lib/src/builder.rs b/reid-llvm-lib/src/builder.rs index a993d49..ec0dadc 100644 --- a/reid-llvm-lib/src/builder.rs +++ b/reid-llvm-lib/src/builder.rs @@ -1,5 +1,6 @@ -/// This module contains simply [`Builder`] and it's related utility Values. -/// Builder is the actual struct being modified when building the LLIR. +//! This module contains simply [`Builder`] and it's related utility Values. +//! Builder is the actual struct being modified when building the LLIR. + use std::{cell::RefCell, rc::Rc}; use crate::{ diff --git a/reid-llvm-lib/src/compile.rs b/reid-llvm-lib/src/compile.rs index 768f28e..ea123e4 100644 --- a/reid-llvm-lib/src/compile.rs +++ b/reid-llvm-lib/src/compile.rs @@ -1,6 +1,7 @@ -/// This module contains all of the relevant code that is needed to compile the -/// LLIR ([`Context`]) into LLVM IR. This module is the only one that interfaces -/// with the LLVM API. +//! This module contains all of the relevant code that is needed to compile the +//! LLIR ([`Context`]) into LLVM IR. This module is the only one that interfaces +//! with the LLVM API. + use std::{collections::HashMap, ffi::CString, ptr::null_mut}; use llvm_sys::{ diff --git a/reid-llvm-lib/src/debug.rs b/reid-llvm-lib/src/debug.rs index 1eeb0dc..f179bab 100644 --- a/reid-llvm-lib/src/debug.rs +++ b/reid-llvm-lib/src/debug.rs @@ -1,4 +1,5 @@ -/// Debug implementations for relevant types +//! Debug implementations for relevant types + use std::fmt::{Debug, Write}; use crate::{CmpPredicate, InstructionData, InstructionKind, TerminatorKind, builder::*}; diff --git a/reid-llvm-lib/src/lib.rs b/reid-llvm-lib/src/lib.rs index 993d93a..b0d3c79 100644 --- a/reid-llvm-lib/src/lib.rs +++ b/reid-llvm-lib/src/lib.rs @@ -1,6 +1,7 @@ -/// Reid LLVM Lib is an ergonomic Rust'y API which is used to produce a -/// Low-Level IR (LLIR) using [`Context`] and [`Builder`]. This Builder can then -/// be used at the end to compile said LLIR into LLVM IR. +//! Reid LLVM Lib is an ergonomic Rust'y API which is used to produce a +//! Low-Level IR (LLIR) using [`Context`] and [`Builder`]. This Builder can then +//! be used at the end to compile said LLIR into LLVM IR. + use std::marker::PhantomData; use builder::{BlockValue, Builder, FunctionValue, InstructionValue, ModuleValue}; diff --git a/reid/src/mir/mod.rs b/reid/src/mir/mod.rs index 1951cdd..76cf592 100644 --- a/reid/src/mir/mod.rs +++ b/reid/src/mir/mod.rs @@ -1,5 +1,7 @@ -/// In this module are defined structs that are used for performing passes on -/// Reid. It contains a simplified version of Reid which can be e.g. typechecked. +//! In this module are defined structs that are used for performing passes on +//! Reid. It contains a simplified version of Reid which can be e.g. +//! typechecked. + use crate::token_stream::TokenRange; mod display; diff --git a/reid/src/mir/pass.rs b/reid/src/mir/pass.rs index c75ade4..5fb448e 100644 --- a/reid/src/mir/pass.rs +++ b/reid/src/mir/pass.rs @@ -1,5 +1,6 @@ -/// This module contains relevant code for [`Pass`] and shared code between -/// passes. Passes can be performed on Reid MIR to e.g. typecheck the code. +//! This module contains relevant code for [`Pass`] and shared code between +//! passes. Passes can be performed on Reid MIR to e.g. typecheck the code. + use std::collections::HashMap; use std::error::Error as STDError; diff --git a/reid/src/mir/typecheck.rs b/reid/src/mir/typecheck.rs index 77c5c01..334d525 100644 --- a/reid/src/mir/typecheck.rs +++ b/reid/src/mir/typecheck.rs @@ -1,5 +1,5 @@ -/// This module contains code relevant to doing a type checking pass on the MIR. -/// During typechecking relevant types are also coerced if possible. +//! This module contains code relevant to doing a type checking pass on the MIR. +//! During typechecking relevant types are also coerced if possible. use std::{convert::Infallible, iter}; use crate::{mir::*, util::try_all}; diff --git a/reid/src/pad_adapter.rs b/reid/src/pad_adapter.rs index 2a367ff..0280a4d 100644 --- a/reid/src/pad_adapter.rs +++ b/reid/src/pad_adapter.rs @@ -1,25 +1,26 @@ -/// Copied from -/// https://github.com/rust-lang/rust/blob/6b3ae3f6e45a33c2d95fa0362c9b2593e567fd34/library/core/src/fmt/builders.rs#L102 -/// -/// Copyright (c) The Rust Project Contributors -/// -/// Permission is hereby granted, free of charge, to any person obtaining a copy -/// of this software and associated documentation files (the "Software"), to -/// deal in the Software without restriction, including without limitation the -/// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -/// sell copies of the Software, and to permit persons to whom the Software is -/// furnished to do so, subject to the following conditions: -/// -/// The above copyright notice and this permission notice shall be included in -/// all copies or substantial portions of the Software. -/// -/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -/// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -/// IN THE SOFTWARE. +//! Copied from +//! https://github.com/rust-lang/rust/blob/6b3ae3f6e45a33c2d95fa0362c9b2593e567fd34/library/core/src/fmt/builders.rs#L102 + +// Copyright (c) The Rust Project Contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + use std::fmt; pub struct PadAdapter<'buf, 'state> { diff --git a/reid/src/token_stream.rs b/reid/src/token_stream.rs index 617cf1f..dc9903e 100644 --- a/reid/src/token_stream.rs +++ b/reid/src/token_stream.rs @@ -1,5 +1,6 @@ -/// Contains relevant code for parsing tokens received from -/// Lexing/Tokenizing-stage. +//! Contains relevant code for parsing tokens received from +//! Lexing/Tokenizing-stage. + use crate::{ ast::parse::Parse, lexer::{FullToken, Position, Token}, diff --git a/reid/src/util.rs b/reid/src/util.rs index dc84b14..61b2cd8 100644 --- a/reid/src/util.rs +++ b/reid/src/util.rs @@ -1,6 +1,7 @@ -/// Take a list of Results, and try to unwrap all of them. Returns a Result -/// which either contains every Result unwrapped, or every error that exists -/// within the array. +//! Take a list of Results, and try to unwrap all of them. Returns a Result +//! which either contains every Result unwrapped, or every error that exists +//! within the array. + pub fn try_all(list: Vec>) -> Result, Vec> { let mut successes = Vec::with_capacity(list.len()); let mut failures = Vec::with_capacity(list.len());