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

Rollup of 7 pull requests #126734

Closed
wants to merge 20 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
4c5e954
Add `rust_analyzer` as a predefined tool
Veykril May 18, 2024
ff9efea
Resolve Clippy `f16` and `f128` `unimplemented!`/`FIXME`s
tgross35 Jun 18, 2024
477e9e8
Update float tests to include `f16` and `f128`
tgross35 Jun 18, 2024
35c65a8
Make Option::as_[mut_]slice const
GKFX Jun 19, 2024
09006d6
Convert some module-level `//` and `///` comments to `//!`.
nnethercote Jun 19, 2024
665821c
Add blank lines after module-level `//!` comments.
nnethercote Jun 19, 2024
b104fbe
Add blank lines after module-level `//` comments.
nnethercote Jun 19, 2024
9981d61
Remove useless `tidy-alphabetical` markers.
nnethercote Jun 19, 2024
b5a5647
Move an `EMIT_MIR` comment.
nnethercote Jun 19, 2024
19b7192
Fix assertion failure for some `Expect` diagnostics.
nnethercote Jun 20, 2024
388aea4
More status-quo tests for the `#[coverage(..)]` attribute
Zalathar Jun 19, 2024
ebb3aa0
Also test that yes/no must be bare words
Zalathar Jun 19, 2024
53f10b9
Add opaque type test
oli-obk Jun 20, 2024
1795b29
Rollup merge of #125241 - Veykril:tool-rust-analyzer, r=davidtwco
matthiaskrgr Jun 20, 2024
147adde
Rollup merge of #126636 - tgross35:clippy-f16-f128-fixme, r=flip1995
matthiaskrgr Jun 20, 2024
f5ba4d5
Rollup merge of #126659 - Zalathar:test-coverage-attr, r=cjgillot
matthiaskrgr Jun 20, 2024
84ed3cf
Rollup merge of #126711 - GKFX:const-option-as-slice, r=oli-obk
matthiaskrgr Jun 20, 2024
b9015fe
Rollup merge of #126717 - nnethercote:rustfmt-use-pre-cleanups, r=jie…
matthiaskrgr Jun 20, 2024
db85e4d
Rollup merge of #126719 - nnethercote:fix-126521, r=oli-obk
matthiaskrgr Jun 20, 2024
b381c3c
Rollup merge of #126730 - oli-obk:opaque_type_diff_next_solver, r=lcnr
matthiaskrgr Jun 20, 2024
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
1 change: 1 addition & 0 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -709,6 +709,7 @@ dependencies = [
"clippy_config",
"itertools 0.12.1",
"rustc-semver",
"rustc_apfloat",
]

[[package]]
Expand Down
5 changes: 3 additions & 2 deletions compiler/rustc_builtin_macros/src/test.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! The expansion from a test function to the appropriate test struct for libtest
//! Ideally, this code would be in libtest but for efficiency and error messages it lives here.

use crate::errors;
/// The expansion from a test function to the appropriate test struct for libtest
/// Ideally, this code would be in libtest but for efficiency and error messages it lives here.
use crate::util::{check_builtin_macro_attribute, warn_on_duplicate_attribute};
use rustc_ast::ptr::P;
use rustc_ast::{self as ast, attr, GenericParamKind};
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_codegen_gcc/tests/lang_tests_common.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//! The common code for `tests/lang_tests_*.rs`

use std::{
env::{self, current_dir},
path::{Path, PathBuf},
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_codegen_ssa/src/mir/locals.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! Locals are in a private module as updating `LocalRef::Operand` has to
//! be careful wrt to subtyping. To deal with this we only allow updates by using
//! `FunctionCx::overwrite_local` which handles it automatically.

use crate::mir::{FunctionCx, LocalRef};
use crate::traits::BuilderMethods;
use rustc_index::IndexVec;
Expand Down
5 changes: 3 additions & 2 deletions compiler/rustc_data_structures/src/base_n.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/// Converts unsigned integers into a string representation with some base.
/// Bases up to and including 36 can be used for case-insensitive things.
//! Converts unsigned integers into a string representation with some base.
//! Bases up to and including 36 can be used for case-insensitive things.

use std::ascii;
use std::fmt;

Expand Down
28 changes: 19 additions & 9 deletions compiler/rustc_errors/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1437,6 +1437,24 @@ impl DiagCtxtInner {

// Return value is only `Some` if the level is `Error` or `DelayedBug`.
fn emit_diagnostic(&mut self, mut diagnostic: DiagInner) -> Option<ErrorGuaranteed> {
match diagnostic.level {
Expect(expect_id) | ForceWarning(Some(expect_id)) => {
// The `LintExpectationId` can be stable or unstable depending on when it was
// created. Diagnostics created before the definition of `HirId`s are unstable and
// can not yet be stored. Instead, they are buffered until the `LintExpectationId`
// is replaced by a stable one by the `LintLevelsBuilder`.
if let LintExpectationId::Unstable { .. } = expect_id {
// We don't call TRACK_DIAGNOSTIC because we wait for the
// unstable ID to be updated, whereupon the diagnostic will be
// passed into this method again.
self.unstable_expect_diagnostics.push(diagnostic);
return None;
}
// Continue through to the `Expect`/`ForceWarning` case below.
}
_ => {}
}

if diagnostic.has_future_breakage() {
// Future breakages aren't emitted if they're `Level::Allow`,
// but they still need to be constructed and stashed below,
Expand Down Expand Up @@ -1512,16 +1530,8 @@ impl DiagCtxtInner {
return None;
}
Expect(expect_id) | ForceWarning(Some(expect_id)) => {
// Diagnostics created before the definition of `HirId`s are
// unstable and can not yet be stored. Instead, they are
// buffered until the `LintExpectationId` is replaced by a
// stable one by the `LintLevelsBuilder`.
if let LintExpectationId::Unstable { .. } = expect_id {
// We don't call TRACK_DIAGNOSTIC because we wait for the
// unstable ID to be updated, whereupon the diagnostic will
// be passed into this method again.
self.unstable_expect_diagnostics.push(diagnostic);
return None;
unreachable!(); // this case was handled at the top of this function
}
self.fulfilled_expectations.insert(expect_id.normalize());
if let Expect(_) = diagnostic.level {
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_errors/src/markdown/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! A simple markdown parser that can write formatted text to the terminal
//!
//! Entrypoint is `MdStream::parse_str(...)`

use std::io;

use termcolor::{Buffer, BufferWriter, ColorChoice};
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_expand/src/mbe/macro_check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@
//! Kleene operators under which a meta-variable is repeating is the concatenation of the stacks
//! stored when entering a macro definition starting from the state in which the meta-variable is
//! bound.

use crate::errors;
use crate::mbe::{KleeneToken, TokenTree};

Expand Down
2 changes: 0 additions & 2 deletions compiler/rustc_fs_util/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
// tidy-alphabetical-start
use std::ffi::CString;
use std::fs;
use std::io;
use std::path::{absolute, Path, PathBuf};
// tidy-alphabetical-end

// Unfortunately, on windows, it looks like msvcrt.dll is silently translating
// verbatim paths under the hood to non-verbatim paths! This manifests itself as
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_hir_analysis/src/check/dropck.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// FIXME(@lcnr): Move this module out of `rustc_hir_analysis`.
//
// We don't do any drop checking during hir typeck.

use rustc_data_structures::fx::FxHashSet;
use rustc_errors::{codes::*, struct_span_code_err, ErrorGuaranteed};
use rustc_infer::infer::outlives::env::OutlivesEnvironment;
Expand Down
3 changes: 2 additions & 1 deletion compiler/rustc_hir_typeck/src/autoderef.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//! Some helper functions for `AutoDeref`
//! Some helper functions for `AutoDeref`.

use super::method::MethodCallee;
use super::{FnCtxt, PlaceOp};

Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_hir_typeck/src/errors.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//! Errors emitted by `rustc_hir_typeck`.

use std::borrow::Cow;

use crate::fluent_generated as fluent;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//! A utility module to inspect currently ambiguous obligations in the current context.

use crate::FnCtxt;
use rustc_infer::traits::{self, ObligationCause};
use rustc_middle::traits::solve::Goal;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//! Error Reporting for Anonymous Region Lifetime Errors
//! where one region is named and the other is anonymous.

use crate::infer::error_reporting::nice_region_error::NiceRegionError;
use crate::{
errors::ExplicitLifetimeRequired,
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_infer/src/infer/freshen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
//! solving a set of constraints. In contrast, the type inferencer assigns a value to each type
//! variable only once, and it does so as soon as it can, so it is reasonable to ask what the type
//! inferencer knows "so far".

use super::InferCtxt;
use rustc_data_structures::fx::FxHashMap;
use rustc_middle::bug;
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_infer/src/infer/outlives/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//! Various code related to computing outlives relations.

use self::env::OutlivesEnvironment;
use super::region_constraints::RegionConstraintData;
use super::{InferCtxt, RegionResolutionError, SubregionOrigin};
Expand Down
2 changes: 0 additions & 2 deletions compiler/rustc_lint_defs/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// tidy-alphabetical-start
pub use self::Level::*;
use rustc_ast::node_id::NodeId;
use rustc_ast::{AttrId, Attribute};
Expand All @@ -15,7 +14,6 @@ use rustc_span::edition::Edition;
use rustc_span::symbol::MacroRulesNormalizedIdent;
use rustc_span::{sym, symbol::Ident, Span, Symbol};
use rustc_target::spec::abi::Abi;
// tidy-alphabetical-end

use serde::{Deserialize, Serialize};

Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_middle/src/middle/privacy.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! A pass that checks to make sure private fields and methods aren't used
//! outside their scopes. This pass will also generate a set of exported items
//! which are available for use externally when compiled as a library.

use crate::ty::{TyCtxt, Visibility};
use rustc_data_structures::fx::{FxIndexMap, IndexEntry};
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
Expand Down
3 changes: 2 additions & 1 deletion compiler/rustc_middle/src/mir/statement.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/// Functionality for statements, operands, places, and things that appear in them.
//! Functionality for statements, operands, places, and things that appear in them.

use super::{interpret::GlobalAlloc, *};

///////////////////////////////////////////////////////////////////////////
Expand Down
3 changes: 2 additions & 1 deletion compiler/rustc_middle/src/mir/terminator.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/// Functionality for terminators and helper types that appear in terminators.
//! Functionality for terminators and helper types that appear in terminators.

use rustc_hir::LangItem;
use smallvec::{smallvec, SmallVec};

Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_middle/src/ty/abstract_const.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//! A subset of a mir body used for const evaluability checking.

use crate::ty::{
self, Const, EarlyBinder, Ty, TyCtxt, TypeFoldable, TypeFolder, TypeSuperFoldable,
TypeVisitableExt,
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_mir_transform/src/ctfe_limit.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//! A pass that inserts the `ConstEvalCounter` instruction into any blocks that have a back edge
//! (thus indicating there is a loop in the CFG), or whose terminator is a function call.

use crate::MirPass;

use rustc_data_structures::graph::dominators::Dominators;
Expand Down
3 changes: 2 additions & 1 deletion compiler/rustc_mir_transform/src/inline.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//! Inlining pass for MIR functions
//! Inlining pass for MIR functions.

use crate::deref_separator::deref_finder;
use rustc_attr::InlineAttr;
use rustc_hir::def::DefKind;
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_mir_transform/src/lint.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! This pass statically detects code which has undefined behaviour or is likely to be erroneous.
//! It can be used to locate problems in MIR building or optimizations. It assumes that all code
//! can be executed, so it has false positives.

use rustc_data_structures::fx::FxHashSet;
use rustc_index::bit_set::BitSet;
use rustc_middle::mir::visit::{PlaceContext, Visitor};
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_parse/src/parser/expr.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// ignore-tidy-filelength

use super::diagnostics::SnapshotParser;
use super::pat::{CommaRecoveryMode, Expected, RecoverColon, RecoverComma};
use super::ty::{AllowPlus, RecoverQPath, RecoverReturnSign};
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_pattern_analysis/src/pat.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//! As explained in [`crate::usefulness`], values and patterns are made from constructors applied to
//! fields. This file defines types that represent patterns in this way.

use std::fmt;

use smallvec::{smallvec, SmallVec};
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_pattern_analysis/tests/complexity.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//! Test the pattern complexity limit.

use common::*;
use rustc_pattern_analysis::{pat::DeconstructedPat, usefulness::PlaceValidity, MatchArm};

Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_pattern_analysis/tests/exhaustiveness.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//! Test exhaustiveness checking.

use common::*;
use rustc_pattern_analysis::{
pat::{DeconstructedPat, WitnessPat},
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_pattern_analysis/tests/intersection.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//! Test the computation of arm intersections.

use common::*;
use rustc_pattern_analysis::{pat::DeconstructedPat, usefulness::PlaceValidity, MatchArm};

Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_resolve/src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,9 @@ pub(crate) fn registered_tools(tcx: TyCtxt<'_>, (): ()) -> RegisteredTools {
}
}
}
// We implicitly add `rustfmt`, `clippy`, `diagnostic` to known tools,
// but it's not an error to register them explicitly.
let predefined_tools = [sym::clippy, sym::rustfmt, sym::diagnostic, sym::miri];
// We implicitly add `rustfmt`, `clippy`, `diagnostic`, `miri` and `rust_analyzer` to known
// tools, but it's not an error to register them explicitly.
let predefined_tools = [sym::clippy, sym::rustfmt, sym::diagnostic, sym::miri, sym::rust_analyzer];
registered_tools.extend(predefined_tools.iter().cloned().map(Ident::with_dummy_span));
registered_tools
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
//!
//! For more information about LLVM CFI and cross-language LLVM CFI support for the Rust compiler,
//! see design document in the tracking issue #89653.

use rustc_data_structures::base_n::ToBaseN;
use rustc_data_structures::base_n::ALPHANUMERIC_ONLY;
use rustc_data_structures::base_n::CASE_INSENSITIVE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
//!
//! For more information about LLVM CFI and cross-language LLVM CFI support for the Rust compiler,
//! see design document in the tracking issue #89653.

use rustc_data_structures::fx::FxHashMap;
use rustc_middle::bug;
use rustc_middle::ty::{self, Instance, Ty, TyCtxt, TypeFoldable};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
//!
//! For more information about LLVM CFI and cross-language LLVM CFI support for the Rust compiler,
//! see design document in the tracking issue #89653.

use rustc_hir as hir;
use rustc_hir::LangItem;
use rustc_middle::bug;
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_sanitizers/src/cfi/typeid/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
//!
//! For more information about LLVM CFI and cross-language LLVM CFI support for the Rust compiler,
//! see design document in the tracking issue #89653.

use bitflags::bitflags;
use rustc_middle::ty::{Instance, Ty, TyCtxt};
use rustc_target::abi::call::FnAbi;
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_sanitizers/src/kcfi/typeid/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
//!
//! For more information about LLVM KCFI and cross-language LLVM KCFI support for the Rust compiler,
//! see the tracking issue #123479.

use rustc_middle::ty::{Instance, InstanceKind, ReifyReason, Ty, TyCtxt};
use rustc_target::abi::call::FnAbi;
use std::hash::Hasher;
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_session/src/output.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//! Related to out filenames of compilation (e.g. binaries).

use crate::config::{self, CrateType, Input, OutFileName, OutputFilenames, OutputType};
use crate::errors::{
self, CrateNameDoesNotMatch, CrateNameEmpty, CrateNameInvalid, FileIsNotWriteable,
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_smir/src/rustc_smir/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
//! We first retrieve and monomorphize the rustc body representation, i.e., we generate a
//! monomorphic body using internal representation.
//! After that, we convert the internal representation into a stable one.

use crate::rustc_smir::{Stable, Tables};
use rustc_hir::def::DefKind;
use rustc_middle::mir;
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_smir/src/rustc_smir/convert/error.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! Handle the conversion of different internal errors into a stable version.
//!
//! Currently we encode everything as [stable_mir::Error], which is represented as a string.

use crate::rustc_smir::{Stable, Tables};
use rustc_middle::mir::interpret::AllocError;
use rustc_middle::ty::layout::LayoutError;
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_span/src/symbol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1557,6 +1557,7 @@ symbols! {
rust_2018_preview,
rust_2021,
rust_2024,
rust_analyzer,
rust_begin_unwind,
rust_cold_cc,
rust_eh_catch_typeinfo,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/// A target tuple for OpenWrt MIPS64 targets
///
//! A target tuple for OpenWrt MIPS64 targets.

use crate::abi::Endian;
use crate::spec::{base, Target, TargetOptions};

Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_trait_selection/src/traits/normalize.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//! Deeply normalize types using the old trait solver.

use super::error_reporting::OverflowCause;
use super::error_reporting::TypeErrCtxtExt;
use super::SelectionContext;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
//!
//! [rustc dev guide]:
//! https://rustc-dev-guide.rust-lang.org/traits/resolution.html#confirmation

use rustc_ast::Mutability;
use rustc_data_structures::stack::ensure_sufficient_stack;
use rustc_hir::lang_items::LangItem;
Expand Down
1 change: 1 addition & 0 deletions compiler/stable_mir/src/mir/alloc.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//! This module provides methods to retrieve allocation information, such as static variables.

use crate::mir::mono::{Instance, StaticDef};
use crate::target::{Endian, MachineInfo};
use crate::ty::{Allocation, Binder, ExistentialTraitRef, IndexedVal, Ty};
Expand Down
7 changes: 4 additions & 3 deletions library/alloc/src/boxed/thin.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Based on
// https://github.com/matthieu-m/rfc2580/blob/b58d1d3cba0d4b5e859d3617ea2d0943aaa31329/examples/thin.rs
// by matthieu-m
//! Based on
//! <https://github.com/matthieu-m/rfc2580/blob/b58d1d3cba0d4b5e859d3617ea2d0943aaa31329/examples/thin.rs>
//! by matthieu-m

use crate::alloc::{self, Layout, LayoutError};
use core::error::Error;
use core::fmt::{self, Debug, Display, Formatter};
Expand Down
1 change: 1 addition & 0 deletions library/alloc/src/vec/in_place_collect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@
//! }
//! vec.truncate(write_idx);
//! ```

use crate::alloc::{handle_alloc_error, Global};
use core::alloc::Allocator;
use core::alloc::Layout;
Expand Down
Loading
Loading