Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Aggregation of cosmetic changes made during work on REPL PRs: misc. #64275

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions src/bootstrap/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,7 @@ impl Config {

pub fn default_opts() -> Config {
let mut config = Config::default();

config.llvm_optimize = true;
config.llvm_version_check = true;
config.backtrace = true;
Expand All @@ -376,7 +377,7 @@ impl Config {
config.deny_warnings = true;
config.missing_tools = false;

// set by bootstrap.py
// set by `bootstrap.py`
config.build = INTERNER.intern_str(&env::var("BUILD").expect("'BUILD' to be set"));
config.src = Config::path_from_python("SRC");
config.out = Config::path_from_python("BUILD_DIR");
Expand Down Expand Up @@ -410,7 +411,7 @@ impl Config {
config.out = dir;
}

// If --target was specified but --host wasn't specified, don't run any host-only tests.
// If `--target` was specified but `--host` wasn't specified, don't run any host-only tests.
let has_hosts = !flags.host.is_empty();
let has_targets = !flags.target.is_empty();
config.skip_only_host_steps = !has_hosts && has_targets;
Expand All @@ -428,7 +429,7 @@ impl Config {
}).unwrap_or_else(|| TomlConfig::default());

let build = toml.build.clone().unwrap_or_default();
// set by bootstrap.py
// set by `bootstrap.py`
config.hosts.push(config.build.clone());
for host in build.host.iter() {
let host = INTERNER.intern_str(host);
Expand Down Expand Up @@ -487,8 +488,8 @@ impl Config {
config.mandir = install.mandir.clone().map(PathBuf::from);
}

// Store off these values as options because if they're not provided
// we'll infer default values for them later
// Store away these values as options because if they're not provided
// we'll infer default values for them later.
let mut llvm_assertions = None;
let mut debug = None;
let mut debug_assertions = None;
Expand Down Expand Up @@ -552,7 +553,7 @@ impl Config {
set(&mut config.channel, rust.channel.clone());
set(&mut config.rust_dist_src, rust.dist_src);
set(&mut config.verbose_tests, rust.verbose_tests);
// in the case "false" is set explicitly, do not overwrite the command line args
// In the case "false" is set explicitly, do not overwrite the command-line args.
if let Some(true) = rust.incremental {
config.incremental = true;
}
Expand Down
10 changes: 5 additions & 5 deletions src/bootstrap/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -997,27 +997,27 @@ impl Build {
self.package_vers(channel::CFG_RELEASE_NUM)
}

/// Returns the value of `package_vers` above for Cargo
/// Returns the value of `package_vers` above for Cargo.
fn cargo_package_vers(&self) -> String {
self.package_vers(&self.release_num("cargo"))
}

/// Returns the value of `package_vers` above for rls
/// Returns the value of `package_vers` above for rls.
fn rls_package_vers(&self) -> String {
self.package_vers(&self.release_num("rls"))
}

/// Returns the value of `package_vers` above for clippy
/// Returns the value of `package_vers` above for clippy.
fn clippy_package_vers(&self) -> String {
self.package_vers(&self.release_num("clippy"))
}

/// Returns the value of `package_vers` above for miri
/// Returns the value of `package_vers` above for miri.
fn miri_package_vers(&self) -> String {
self.package_vers(&self.release_num("miri"))
}

/// Returns the value of `package_vers` above for rustfmt
/// Returns the value of `package_vers` above for rustfmt.
fn rustfmt_package_vers(&self) -> String {
self.package_vers(&self.release_num("rustfmt"))
}
Expand Down
6 changes: 3 additions & 3 deletions src/libfmt_macros/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ impl<'a> Parser<'a> {
&self.input[start..self.input.len()]
}

/// Parses an Argument structure, or what's contained within braces inside the format string
/// Parses an `Argument` structure, or what's contained within braces inside the format string.
fn argument(&mut self) -> Argument<'a> {
let pos = self.position();
let format = self.format();
Expand Down Expand Up @@ -464,7 +464,7 @@ impl<'a> Parser<'a> {
}

/// Parses a format specifier at the current position, returning all of the
/// relevant information in the FormatSpec struct.
/// relevant information in the `FormatSpec` struct.
fn format(&mut self) -> FormatSpec<'a> {
let mut spec = FormatSpec {
fill: None,
Expand Down Expand Up @@ -571,7 +571,7 @@ impl<'a> Parser<'a> {
spec
}

/// Parses a Count parameter at the current position. This does not check
/// Parses a `Count` parameter at the current position. This does not check
/// for 'CountIsNextParam' because that is only used in precision, not
/// width.
fn count(&mut self, start: usize) -> (Count, Option<InnerSpan>) {
Expand Down
50 changes: 25 additions & 25 deletions src/librustc_ast_borrowck/borrowck/move_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ use log::debug;

#[derive(Default)]
pub struct MoveData<'tcx> {
/// Move paths. See section "Move paths" in `README.md`.
/// Move paths. See the section "Move paths" in `README.md`.
pub paths: RefCell<Vec<MovePath<'tcx>>>,

/// Cache of loan path to move path index, for easy lookup.
/// A cache of move path indexes by loan paths, for easy lookup.
pub path_map: RefCell<FxHashMap<Rc<LoanPath<'tcx>>, MovePathIndex>>,

/// Each move or uninitialized variable gets an entry here.
Expand Down Expand Up @@ -48,7 +48,7 @@ pub struct FlowedMoveData<'tcx> {
pub dfcx_assign: AssignDataFlow<'tcx>,
}

/// Index into `MoveData.paths`, used like a pointer
/// Index into `MoveData.paths`, used like a pointer.
#[derive(Copy, PartialEq, Eq, PartialOrd, Ord, Debug)]
pub struct MovePathIndex(usize);

Expand All @@ -67,7 +67,7 @@ impl Clone for MovePathIndex {
#[allow(non_upper_case_globals)]
const InvalidMovePathIndex: MovePathIndex = MovePathIndex(usize::MAX);

/// Index into `MoveData.moves`, used like a pointer
/// Index into `MoveData.moves`, used like a pointer.
#[derive(Copy, Clone, PartialEq)]
pub struct MoveIndex(usize);

Expand All @@ -81,17 +81,17 @@ impl MoveIndex {
const InvalidMoveIndex: MoveIndex = MoveIndex(usize::MAX);

pub struct MovePath<'tcx> {
/// Loan path corresponding to this move path
/// Loan path corresponding to this move path.
pub loan_path: Rc<LoanPath<'tcx>>,

/// Parent pointer, `InvalidMovePathIndex` if root
/// Parent pointer, `InvalidMovePathIndex` if root.
pub parent: MovePathIndex,

/// Head of linked list of moves to this path,
/// `InvalidMoveIndex` if not moved
/// `InvalidMoveIndex` if not moved.
pub first_move: MoveIndex,

/// First node in linked list of children, `InvalidMovePathIndex` if leaf
/// First node in linked list of children, `InvalidMovePathIndex` if leaf.
pub first_child: MovePathIndex,

/// Next node in linked list of parent's children (siblings),
Expand All @@ -102,25 +102,25 @@ pub struct MovePath<'tcx> {

#[derive(Copy, Clone)]
pub struct Move {
/// Path being moved.
/// The path being moved.
pub path: MovePathIndex,

/// ID of node that is doing the move.
/// The ID of the node that is doing the move.
pub id: hir::ItemLocalId,

/// Next node in linked list of moves from `path`, or `InvalidMoveIndex`
/// The next node in the linked list of moves from `path`, or `InvalidMoveIndex`.
pub next_move: MoveIndex
}

#[derive(Copy, Clone)]
pub struct Assignment {
/// Path being assigned.
/// The path being assigned.
pub path: MovePathIndex,

/// ID where assignment occurs
/// The ID where assignment occurs.
pub id: hir::ItemLocalId,

/// span of node where assignment occurs
/// The span of node where assignment occurs.
pub span: Span,
}

Expand Down Expand Up @@ -200,12 +200,12 @@ impl MoveData<'tcx> {
}

fn move_next_move(&self, index: MoveIndex) -> MoveIndex {
//! Type safe indexing operator
//! Type-safe indexing operator.
(*self.moves.borrow())[index.get()].next_move
}

fn is_var_path(&self, index: MovePathIndex) -> bool {
//! True if `index` refers to a variable
//! `true` if `index` refers to a variable.
self.path_parent(index) == InvalidMovePathIndex
}

Expand Down Expand Up @@ -274,7 +274,7 @@ impl MoveData<'tcx> {
}

/// Adds any existing move path indices for `lp` and any base paths of `lp` to `result`, but
/// does not add new move paths
/// does not add new move paths.
fn add_existing_base_paths(&self, lp: &Rc<LoanPath<'tcx>>,
result: &mut Vec<MovePathIndex>) {
match self.path_map.borrow().get(lp).cloned() {
Expand Down Expand Up @@ -486,7 +486,7 @@ impl MoveData<'tcx> {
return true;
}

// FIXME(#19596) This is a workaround, but there should be better way to do this
// FIXME(#19596): this is a workaround, but there should be better way to do this.
fn each_extending_path_<F>(&self, index: MovePathIndex, f: &mut F) -> bool where
F: FnMut(MovePathIndex) -> bool,
{
Expand Down Expand Up @@ -630,7 +630,7 @@ impl<'tcx> FlowedMoveData<'tcx> {
//
// OK scenario:
//
// 4. move of `a.b.c`, use of `a.b.d`
// 4. Move of `a.b.c`, use of `a.b.d`

let base_indices = self.move_data.existing_base_paths(loan_path);
if base_indices.is_empty() {
Expand All @@ -656,7 +656,7 @@ impl<'tcx> FlowedMoveData<'tcx> {
let cont = self.move_data.each_base_path(moved_path, |p| {
if p == loan_path_index {
// Scenario 3: some extension of `loan_path`
// was moved
// was moved.
f(the_move,
&self.move_data.path_loan_path(moved_path))
} else {
Expand All @@ -683,7 +683,7 @@ impl<'tcx> FlowedMoveData<'tcx> {
match self.move_data.existing_move_path(loan_path) {
Some(i) => i,
None => {
// if there were any assignments, it'd have an index
// If there were any assignments, it'd have an index.
return true;
}
}
Expand All @@ -704,27 +704,27 @@ impl<'tcx> FlowedMoveData<'tcx> {
impl BitwiseOperator for MoveDataFlowOperator {
#[inline]
fn join(&self, succ: usize, pred: usize) -> usize {
succ | pred // moves from both preds are in scope
succ | pred // Moves from both predicates are in scope.
}
}

impl DataFlowOperator for MoveDataFlowOperator {
#[inline]
fn initial_value(&self) -> bool {
false // no loans in scope by default
false // No loans in scope by default.
}
}

impl BitwiseOperator for AssignDataFlowOperator {
#[inline]
fn join(&self, succ: usize, pred: usize) -> usize {
succ | pred // moves from both preds are in scope
succ | pred // Moves from both predicates are in scope.
}
}

impl DataFlowOperator for AssignDataFlowOperator {
#[inline]
fn initial_value(&self) -> bool {
false // no assignments in scope by default
false // No assignments in scope by default.
}
}
27 changes: 13 additions & 14 deletions src/librustc_codegen_llvm/attributes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pub use syntax::attr::{self, InlineAttr, OptimizeAttr};
use crate::context::CodegenCx;
use crate::value::Value;

/// Mark LLVM function to use provided inline heuristic.
/// Marks an LLVM function to use the provided inline heuristic.
#[inline]
pub fn inline(cx: &CodegenCx<'ll, '_>, val: &'ll Value, inline: InlineAttr) {
use self::InlineAttr::*;
Expand All @@ -44,19 +44,19 @@ pub fn inline(cx: &CodegenCx<'ll, '_>, val: &'ll Value, inline: InlineAttr) {
};
}

/// Tell LLVM to emit or not emit the information necessary to unwind the stack for the function.
/// Tells LLVM to emit or not emit the information necessary to unwind the stack for the function.
#[inline]
pub fn emit_uwtable(val: &'ll Value, emit: bool) {
Attribute::UWTable.toggle_llfn(Function, val, emit);
}

/// Tell LLVM whether the function can or cannot unwind.
/// Tells LLVM whether the function can or cannot unwind.
#[inline]
fn unwind(val: &'ll Value, can_unwind: bool) {
Attribute::NoUnwind.toggle_llfn(Function, val, !can_unwind);
}

/// Tell LLVM if this function should be 'naked', i.e., skip the epilogue and prologue.
/// Tells LLVM if this function should be 'naked', i.e., skip the epilogue and prologue.
#[inline]
pub fn naked(val: &'ll Value, is_naked: bool) {
Attribute::Naked.toggle_llfn(Function, val, is_naked);
Expand All @@ -70,15 +70,15 @@ pub fn set_frame_pointer_elimination(cx: &CodegenCx<'ll, '_>, llfn: &'ll Value)
}
}

/// Tell LLVM what instrument function to insert.
/// Tells LLVM what instrument function to insert.
#[inline]
pub fn set_instrument_function(cx: &CodegenCx<'ll, '_>, llfn: &'ll Value) {
if cx.sess().instrument_mcount() {
// Similar to `clang -pg` behavior. Handled by the
// `post-inline-ee-instrument` LLVM pass.

// The function name varies on platforms.
// See test/CodeGen/mcount.c in clang.
// See `test/CodeGen/mcount.c` in Clang.
let mcount_name = CString::new(
cx.sess().target.target.options.target_mcount.as_str().as_bytes()).unwrap();

Expand All @@ -90,7 +90,7 @@ pub fn set_instrument_function(cx: &CodegenCx<'ll, '_>, llfn: &'ll Value) {

pub fn set_probestack(cx: &CodegenCx<'ll, '_>, llfn: &'ll Value) {
// Only use stack probes if the target specification indicates that we
// should be using stack probes
// should be using stack probes.
if !cx.sess().target.target.options.stack_probes {
return
}
Expand Down Expand Up @@ -167,7 +167,7 @@ pub fn apply_target_cpu_attr(cx: &CodegenCx<'ll, '_>, llfn: &'ll Value) {
/// Sets the `NonLazyBind` LLVM attribute on a given function,
/// assuming the codegen options allow skipping the PLT.
pub fn non_lazy_bind(sess: &Session, llfn: &'ll Value) {
// Don't generate calls through PLT if it's not necessary
// Don't generate calls through PLT if it's not necessary.
if !sess.needs_plt() {
Attribute::NonLazyBind.apply_llfn(Function, llfn);
}
Expand All @@ -194,8 +194,7 @@ pub(crate) fn default_optimisation_attrs(sess: &Session, llfn: &'ll Value) {
}
}


/// Composite function which sets LLVM attributes for function depending on its AST (`#[attribute]`)
/// Composite function that sets LLVM attributes for function depending on its AST (`#[attribute]`)
/// attributes.
pub fn from_fn_attrs(
cx: &CodegenCx<'ll, 'tcx>,
Expand Down Expand Up @@ -268,10 +267,10 @@ pub fn from_fn_attrs(
// optimize based on this!
false
} else if codegen_fn_attrs.flags.contains(CodegenFnAttrFlags::UNWIND) {
// If a specific #[unwind] attribute is present, use that
// If a specific `#[unwind]` attribute is present, use that.
true
} else if codegen_fn_attrs.flags.contains(CodegenFnAttrFlags::RUSTC_ALLOCATOR_NOUNWIND) {
// Special attribute for allocator functions, which can't unwind
// Special attribute for allocator functions, which can't unwind.
false
} else if let Some(id) = id {
let sig = cx.tcx.normalize_erasing_late_bound_regions(ty::ParamEnv::reveal_all(), &sig);
Expand All @@ -286,11 +285,11 @@ pub fn from_fn_attrs(
false
} else {
// Anything else defined in Rust is assumed that it can possibly
// unwind
// unwind.
true
}
} else {
// assume this can possibly unwind, avoiding the application of a
// Assume this can possibly unwind, avoiding the application of a
// `nounwind` attribute below.
true
});
Expand Down
Loading