1
Fork 0

Rollup merge of #122813 - nnethercote:nicer-quals, r=compiler-errors

Qualifier tweaking

Adding and removing qualifiers in some cases that make things nicer. Details in individual commits.

r? `@compiler-errors`
This commit is contained in:
Matthias Krüger 2024-04-17 05:44:52 +02:00 committed by GitHub
commit 45940fe6d8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
62 changed files with 346 additions and 399 deletions

View file

@ -9,7 +9,7 @@ use rustc_data_structures::sorted_map::SortedIndexMultiMap;
use rustc_errors::ErrorGuaranteed;
use rustc_hir::def::DefKind;
use rustc_hir::def_id::{DefId, LocalDefId};
use rustc_hir::{self as hir, BindingAnnotation, ByRef, Node};
use rustc_hir::{self as hir, BindingAnnotation, ByRef, HirId, Node};
use rustc_index::bit_set::GrowableBitSet;
use rustc_index::{Idx, IndexSlice, IndexVec};
use rustc_infer::infer::{InferCtxt, TyCtxtInferExt};
@ -158,7 +158,7 @@ struct Builder<'a, 'tcx> {
cfg: CFG<'tcx>,
def_id: LocalDefId,
hir_id: hir::HirId,
hir_id: HirId,
parent_module: DefId,
check_overflow: bool,
fn_span: Span,
@ -222,7 +222,7 @@ struct Builder<'a, 'tcx> {
coverage_branch_info: Option<coverageinfo::BranchInfoBuilder>,
}
type CaptureMap<'tcx> = SortedIndexMultiMap<usize, hir::HirId, Capture<'tcx>>;
type CaptureMap<'tcx> = SortedIndexMultiMap<usize, HirId, Capture<'tcx>>;
#[derive(Debug)]
struct Capture<'tcx> {
@ -721,7 +721,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
thir: &'a Thir<'tcx>,
infcx: InferCtxt<'tcx>,
def: LocalDefId,
hir_id: hir::HirId,
hir_id: HirId,
span: Span,
arg_count: usize,
return_ty: Ty<'tcx>,
@ -981,7 +981,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
fn set_correct_source_scope_for_arg(
&mut self,
arg_hir_id: hir::HirId,
arg_hir_id: HirId,
original_source_scope: SourceScope,
pattern_span: Span,
) {

View file

@ -1,10 +1,8 @@
use std::borrow::Cow;
use crate::build::ExprCategory;
use crate::errors::*;
use rustc_errors::DiagArgValue;
use rustc_hir::{self as hir, BindingAnnotation, ByRef, Mutability};
use rustc_hir::{self as hir, BindingAnnotation, ByRef, HirId, Mutability};
use rustc_middle::mir::BorrowKind;
use rustc_middle::thir::visit::Visitor;
use rustc_middle::thir::*;
@ -16,6 +14,7 @@ use rustc_span::def_id::{DefId, LocalDefId};
use rustc_span::symbol::Symbol;
use rustc_span::{sym, Span};
use std::borrow::Cow;
use std::mem;
use std::ops::Bound;
@ -24,7 +23,7 @@ struct UnsafetyVisitor<'a, 'tcx> {
thir: &'a Thir<'tcx>,
/// The `HirId` of the current scope, which would be the `HirId`
/// of the current HIR node, modulo adjustments. Used for lint levels.
hir_context: hir::HirId,
hir_context: HirId,
/// The current "safety context". This notably tracks whether we are in an
/// `unsafe` block, and whether it has been used.
safety_context: SafetyContext,
@ -123,7 +122,7 @@ impl<'tcx> UnsafetyVisitor<'_, 'tcx> {
fn warn_unused_unsafe(
&mut self,
hir_id: hir::HirId,
hir_id: HirId,
block_span: Span,
enclosing_unsafe: Option<UnusedUnsafeEnclosing>,
) {
@ -537,22 +536,17 @@ enum SafetyContext {
Safe,
BuiltinUnsafeBlock,
UnsafeFn,
UnsafeBlock {
span: Span,
hir_id: hir::HirId,
used: bool,
nested_used_blocks: Vec<NestedUsedBlock>,
},
UnsafeBlock { span: Span, hir_id: HirId, used: bool, nested_used_blocks: Vec<NestedUsedBlock> },
}
#[derive(Clone, Copy)]
struct NestedUsedBlock {
hir_id: hir::HirId,
hir_id: HirId,
span: Span,
}
struct UnusedUnsafeWarning {
hir_id: hir::HirId,
hir_id: HirId,
block_span: Span,
enclosing_unsafe: Option<UnusedUnsafeEnclosing>,
}
@ -585,7 +579,7 @@ impl UnsafeOpKind {
pub fn emit_unsafe_op_in_unsafe_fn_lint(
&self,
tcx: TyCtxt<'_>,
hir_id: hir::HirId,
hir_id: HirId,
span: Span,
suggest_unsafe_block: bool,
) {
@ -726,7 +720,7 @@ impl UnsafeOpKind {
&self,
tcx: TyCtxt<'_>,
span: Span,
hir_context: hir::HirId,
hir_context: HirId,
unsafe_op_in_unsafe_fn_allowed: bool,
) {
let note_non_inherited = tcx.hir().parent_iter(hir_context).find(|(id, node)| {