From 8a850cd12b51507c8a7455c973e54eb14c51696e Mon Sep 17 00:00:00 2001 From: Utkarsh Gupta Date: Wed, 24 Jan 2024 11:10:07 +0000 Subject: [PATCH 01/16] std/time: avoid divisions in Duration::new --- library/core/src/time.rs | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/library/core/src/time.rs b/library/core/src/time.rs index b677776443fe0..e4f2994296607 100644 --- a/library/core/src/time.rs +++ b/library/core/src/time.rs @@ -197,13 +197,18 @@ impl Duration { #[must_use] #[rustc_const_stable(feature = "duration_consts_2", since = "1.58.0")] pub const fn new(secs: u64, nanos: u32) -> Duration { - let secs = match secs.checked_add((nanos / NANOS_PER_SEC) as u64) { - Some(secs) => secs, - None => panic!("overflow in Duration::new"), - }; - let nanos = nanos % NANOS_PER_SEC; - // SAFETY: nanos % NANOS_PER_SEC < NANOS_PER_SEC, therefore nanos is within the valid range - Duration { secs, nanos: unsafe { Nanoseconds(nanos) } } + if nanos < NANOS_PER_SEC { + // SAFETY: nanos < NANOS_PER_SEC, therefore nanos is within the valid range + Duration { secs, nanos: unsafe { Nanoseconds(nanos) } } + } else { + let secs = match secs.checked_add((nanos / NANOS_PER_SEC) as u64) { + Some(secs) => secs, + None => panic!("overflow in Duration::new"), + }; + let nanos = nanos % NANOS_PER_SEC; + // SAFETY: nanos % NANOS_PER_SEC < NANOS_PER_SEC, therefore nanos is within the valid range + Duration { secs, nanos: unsafe { Nanoseconds(nanos) } } + } } /// Creates a new `Duration` from the specified number of whole seconds. From 0ac1195ee0f8cd6d87e654a2312b899883272ec2 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Tue, 6 Feb 2024 09:51:39 +1100 Subject: [PATCH 02/16] Invert diagnostic lints. That is, change `diagnostic_outside_of_impl` and `untranslatable_diagnostic` from `allow` to `deny`, because more than half of the compiler has be converted to use translated diagnostics. This commit removes more `deny` attributes than it adds `allow` attributes, which proves that this change is warranted. --- compiler/rustc_arena/src/lib.rs | 2 -- compiler/rustc_ast/src/lib.rs | 2 -- compiler/rustc_ast_lowering/src/lib.rs | 2 -- compiler/rustc_ast_passes/src/lib.rs | 2 -- compiler/rustc_ast_pretty/src/lib.rs | 2 -- compiler/rustc_attr/src/lib.rs | 2 -- compiler/rustc_borrowck/src/borrow_set.rs | 2 -- compiler/rustc_borrowck/src/borrowck_errors.rs | 3 +++ compiler/rustc_borrowck/src/constraints/mod.rs | 3 --- compiler/rustc_borrowck/src/consumers.rs | 2 -- compiler/rustc_borrowck/src/dataflow.rs | 2 -- compiler/rustc_borrowck/src/def_use.rs | 2 -- .../rustc_borrowck/src/diagnostics/bound_region_errors.rs | 3 --- .../rustc_borrowck/src/diagnostics/conflict_errors.rs | 3 +++ compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs | 3 +++ .../rustc_borrowck/src/diagnostics/find_all_local_uses.rs | 3 --- compiler/rustc_borrowck/src/diagnostics/find_use.rs | 3 --- compiler/rustc_borrowck/src/diagnostics/move_errors.rs | 3 +++ .../rustc_borrowck/src/diagnostics/mutability_errors.rs | 3 +++ .../rustc_borrowck/src/diagnostics/outlives_suggestion.rs | 3 +++ compiler/rustc_borrowck/src/diagnostics/region_errors.rs | 2 -- compiler/rustc_borrowck/src/diagnostics/region_name.rs | 3 +++ compiler/rustc_borrowck/src/diagnostics/var_name.rs | 3 --- compiler/rustc_borrowck/src/facts.rs | 2 -- compiler/rustc_borrowck/src/location.rs | 2 -- compiler/rustc_borrowck/src/member_constraints.rs | 2 -- compiler/rustc_borrowck/src/nll.rs | 2 -- compiler/rustc_borrowck/src/path_utils.rs | 2 -- compiler/rustc_borrowck/src/place_ext.rs | 2 -- compiler/rustc_borrowck/src/places_conflict.rs | 2 -- .../rustc_borrowck/src/polonius/loan_invalidations.rs | 2 -- compiler/rustc_borrowck/src/polonius/loan_kills.rs | 2 -- compiler/rustc_borrowck/src/prefixes.rs | 2 -- compiler/rustc_borrowck/src/region_infer/dump_mir.rs | 2 -- compiler/rustc_borrowck/src/region_infer/graphviz.rs | 2 -- compiler/rustc_borrowck/src/region_infer/opaque_types.rs | 2 ++ compiler/rustc_borrowck/src/region_infer/reverse_sccs.rs | 2 -- compiler/rustc_borrowck/src/region_infer/values.rs | 2 -- compiler/rustc_borrowck/src/renumber.rs | 2 -- compiler/rustc_borrowck/src/type_check/mod.rs | 2 -- compiler/rustc_borrowck/src/universal_regions.rs | 3 +++ compiler/rustc_borrowck/src/used_muts.rs | 2 -- compiler/rustc_builtin_macros/src/lib.rs | 2 ++ compiler/rustc_codegen_cranelift/src/lib.rs | 2 ++ compiler/rustc_codegen_gcc/src/lib.rs | 2 -- compiler/rustc_codegen_llvm/src/lib.rs | 2 -- compiler/rustc_codegen_ssa/src/lib.rs | 2 ++ compiler/rustc_const_eval/src/lib.rs | 2 +- compiler/rustc_data_structures/src/lib.rs | 2 -- compiler/rustc_driver_impl/src/lib.rs | 2 -- compiler/rustc_error_codes/src/lib.rs | 2 -- compiler/rustc_error_messages/src/lib.rs | 2 -- compiler/rustc_errors/src/lib.rs | 2 ++ compiler/rustc_expand/src/base.rs | 2 -- compiler/rustc_expand/src/lib.rs | 2 +- compiler/rustc_feature/src/lib.rs | 2 -- compiler/rustc_fluent_macro/src/lib.rs | 2 -- compiler/rustc_fs_util/src/lib.rs | 2 -- compiler/rustc_graphviz/src/lib.rs | 2 -- compiler/rustc_hir/src/lib.rs | 2 -- compiler/rustc_hir_analysis/src/lib.rs | 2 ++ compiler/rustc_hir_pretty/src/lib.rs | 2 -- compiler/rustc_hir_typeck/src/lib.rs | 2 ++ compiler/rustc_incremental/src/lib.rs | 2 -- compiler/rustc_index/src/lib.rs | 2 -- compiler/rustc_infer/src/lib.rs | 2 ++ compiler/rustc_interface/src/lib.rs | 2 -- compiler/rustc_lexer/src/lib.rs | 3 +-- compiler/rustc_lint/src/internal.rs | 4 ++-- compiler/rustc_lint/src/lib.rs | 2 -- compiler/rustc_lint/src/lints.rs | 3 ++- compiler/rustc_lint_defs/src/lib.rs | 2 -- compiler/rustc_llvm/src/lib.rs | 2 -- compiler/rustc_log/src/lib.rs | 3 --- compiler/rustc_macros/src/lib.rs | 2 -- compiler/rustc_metadata/src/lib.rs | 2 -- compiler/rustc_middle/src/lib.rs | 4 +++- compiler/rustc_mir_build/src/lib.rs | 3 +++ compiler/rustc_mir_dataflow/src/lib.rs | 2 -- compiler/rustc_mir_transform/src/lib.rs | 2 -- compiler/rustc_monomorphize/src/lib.rs | 2 -- compiler/rustc_parse/src/lib.rs | 4 +++- compiler/rustc_parse_format/src/lib.rs | 2 -- compiler/rustc_passes/src/lib.rs | 2 -- compiler/rustc_pattern_analysis/src/lib.rs | 3 +++ compiler/rustc_privacy/src/lib.rs | 2 -- compiler/rustc_query_impl/src/lib.rs | 2 -- compiler/rustc_query_system/src/lib.rs | 2 -- compiler/rustc_resolve/src/lib.rs | 2 ++ compiler/rustc_serialize/src/lib.rs | 2 -- compiler/rustc_session/src/lib.rs | 2 -- compiler/rustc_span/src/lib.rs | 2 -- compiler/rustc_symbol_mangling/src/lib.rs | 2 -- compiler/rustc_target/src/lib.rs | 2 -- compiler/rustc_trait_selection/src/lib.rs | 2 ++ compiler/rustc_traits/src/lib.rs | 2 -- compiler/rustc_transmute/src/lib.rs | 2 -- compiler/rustc_ty_utils/src/lib.rs | 2 -- compiler/rustc_ty_utils/src/representability.rs | 2 -- compiler/rustc_type_ir/src/lib.rs | 2 -- src/librustdoc/lib.rs | 2 ++ src/tools/clippy/clippy_config/src/lib.rs | 4 +++- src/tools/clippy/clippy_lints/src/lib.rs | 7 ++++++- src/tools/clippy/clippy_utils/src/lib.rs | 8 +++++++- src/tools/clippy/src/driver.rs | 2 ++ src/tools/miri/src/bin/miri.rs | 4 +++- src/tools/miri/src/lib.rs | 4 +++- 107 files changed, 89 insertions(+), 166 deletions(-) diff --git a/compiler/rustc_arena/src/lib.rs b/compiler/rustc_arena/src/lib.rs index 90ddeec4bc7a4..5cb79d9eea53b 100644 --- a/compiler/rustc_arena/src/lib.rs +++ b/compiler/rustc_arena/src/lib.rs @@ -22,8 +22,6 @@ #![cfg_attr(test, feature(test))] #![feature(strict_provenance)] #![deny(unsafe_op_in_unsafe_fn)] -#![deny(rustc::untranslatable_diagnostic)] -#![deny(rustc::diagnostic_outside_of_impl)] #![allow(internal_features)] #![allow(clippy::mut_from_ref)] // Arena allocators are one of the places where this pattern is fine. diff --git a/compiler/rustc_ast/src/lib.rs b/compiler/rustc_ast/src/lib.rs index 76d838308b461..356e9fef439ed 100644 --- a/compiler/rustc_ast/src/lib.rs +++ b/compiler/rustc_ast/src/lib.rs @@ -18,8 +18,6 @@ #![feature(min_specialization)] #![feature(negative_impls)] #![feature(stmt_expr_attributes)] -#![deny(rustc::untranslatable_diagnostic)] -#![deny(rustc::diagnostic_outside_of_impl)] #[macro_use] extern crate rustc_macros; diff --git a/compiler/rustc_ast_lowering/src/lib.rs b/compiler/rustc_ast_lowering/src/lib.rs index f26b1331ef388..0c3696074d936 100644 --- a/compiler/rustc_ast_lowering/src/lib.rs +++ b/compiler/rustc_ast_lowering/src/lib.rs @@ -35,8 +35,6 @@ #![doc(rust_logo)] #![feature(box_patterns)] #![feature(let_chains)] -#![deny(rustc::untranslatable_diagnostic)] -#![deny(rustc::diagnostic_outside_of_impl)] #[macro_use] extern crate tracing; diff --git a/compiler/rustc_ast_passes/src/lib.rs b/compiler/rustc_ast_passes/src/lib.rs index fa6cdd55c3dcb..74d0fff2734fc 100644 --- a/compiler/rustc_ast_passes/src/lib.rs +++ b/compiler/rustc_ast_passes/src/lib.rs @@ -11,8 +11,6 @@ #![feature(if_let_guard)] #![feature(iter_is_partitioned)] #![feature(let_chains)] -#![deny(rustc::untranslatable_diagnostic)] -#![deny(rustc::diagnostic_outside_of_impl)] pub mod ast_validation; mod errors; diff --git a/compiler/rustc_ast_pretty/src/lib.rs b/compiler/rustc_ast_pretty/src/lib.rs index 61617beb86b5a..b9e217a21e39f 100644 --- a/compiler/rustc_ast_pretty/src/lib.rs +++ b/compiler/rustc_ast_pretty/src/lib.rs @@ -1,8 +1,6 @@ #![allow(internal_features)] #![feature(rustdoc_internals)] #![doc(rust_logo)] -#![deny(rustc::untranslatable_diagnostic)] -#![deny(rustc::diagnostic_outside_of_impl)] #![feature(box_patterns)] mod helpers; diff --git a/compiler/rustc_attr/src/lib.rs b/compiler/rustc_attr/src/lib.rs index 3c5bcecddeaa4..dd87a5c4dc384 100644 --- a/compiler/rustc_attr/src/lib.rs +++ b/compiler/rustc_attr/src/lib.rs @@ -8,8 +8,6 @@ #![feature(rustdoc_internals)] #![doc(rust_logo)] #![feature(let_chains)] -#![deny(rustc::untranslatable_diagnostic)] -#![deny(rustc::diagnostic_outside_of_impl)] #[macro_use] extern crate rustc_macros; diff --git a/compiler/rustc_borrowck/src/borrow_set.rs b/compiler/rustc_borrowck/src/borrow_set.rs index 948af03953718..6a683d129ded1 100644 --- a/compiler/rustc_borrowck/src/borrow_set.rs +++ b/compiler/rustc_borrowck/src/borrow_set.rs @@ -1,5 +1,3 @@ -#![deny(rustc::untranslatable_diagnostic)] -#![deny(rustc::diagnostic_outside_of_impl)] use crate::path_utils::allow_two_phase_borrow; use crate::place_ext::PlaceExt; use crate::BorrowIndex; diff --git a/compiler/rustc_borrowck/src/borrowck_errors.rs b/compiler/rustc_borrowck/src/borrowck_errors.rs index 6cbcda37f50b8..429bcb74a8efc 100644 --- a/compiler/rustc_borrowck/src/borrowck_errors.rs +++ b/compiler/rustc_borrowck/src/borrowck_errors.rs @@ -1,3 +1,6 @@ +#![allow(rustc::diagnostic_outside_of_impl)] +#![allow(rustc::untranslatable_diagnostic)] + use rustc_errors::{codes::*, struct_span_code_err, DiagCtxt, DiagnosticBuilder}; use rustc_middle::ty::{self, Ty, TyCtxt}; use rustc_span::Span; diff --git a/compiler/rustc_borrowck/src/constraints/mod.rs b/compiler/rustc_borrowck/src/constraints/mod.rs index 041ac75ec016e..ff11e4db12133 100644 --- a/compiler/rustc_borrowck/src/constraints/mod.rs +++ b/compiler/rustc_borrowck/src/constraints/mod.rs @@ -1,6 +1,3 @@ -#![deny(rustc::untranslatable_diagnostic)] -#![deny(rustc::diagnostic_outside_of_impl)] - use rustc_data_structures::graph::scc::Sccs; use rustc_index::{IndexSlice, IndexVec}; use rustc_middle::mir::ConstraintCategory; diff --git a/compiler/rustc_borrowck/src/consumers.rs b/compiler/rustc_borrowck/src/consumers.rs index becfa535a59cc..a58fe2b744701 100644 --- a/compiler/rustc_borrowck/src/consumers.rs +++ b/compiler/rustc_borrowck/src/consumers.rs @@ -1,5 +1,3 @@ -#![deny(rustc::untranslatable_diagnostic)] -#![deny(rustc::diagnostic_outside_of_impl)] //! This file provides API for compiler consumers. use rustc_hir::def_id::LocalDefId; diff --git a/compiler/rustc_borrowck/src/dataflow.rs b/compiler/rustc_borrowck/src/dataflow.rs index 1bd891bdd685c..bc5bd7879563a 100644 --- a/compiler/rustc_borrowck/src/dataflow.rs +++ b/compiler/rustc_borrowck/src/dataflow.rs @@ -1,5 +1,3 @@ -#![deny(rustc::untranslatable_diagnostic)] -#![deny(rustc::diagnostic_outside_of_impl)] use rustc_data_structures::fx::FxIndexMap; use rustc_data_structures::graph::WithSuccessors; use rustc_index::bit_set::BitSet; diff --git a/compiler/rustc_borrowck/src/def_use.rs b/compiler/rustc_borrowck/src/def_use.rs index d0cf339e7ba41..6fd80d005d9e3 100644 --- a/compiler/rustc_borrowck/src/def_use.rs +++ b/compiler/rustc_borrowck/src/def_use.rs @@ -1,5 +1,3 @@ -#![deny(rustc::untranslatable_diagnostic)] -#![deny(rustc::diagnostic_outside_of_impl)] use rustc_middle::mir::visit::{ MutatingUseContext, NonMutatingUseContext, NonUseContext, PlaceContext, }; diff --git a/compiler/rustc_borrowck/src/diagnostics/bound_region_errors.rs b/compiler/rustc_borrowck/src/diagnostics/bound_region_errors.rs index bb5335febbf5e..a540fcee871c7 100644 --- a/compiler/rustc_borrowck/src/diagnostics/bound_region_errors.rs +++ b/compiler/rustc_borrowck/src/diagnostics/bound_region_errors.rs @@ -1,6 +1,3 @@ -#![deny(rustc::untranslatable_diagnostic)] -#![deny(rustc::diagnostic_outside_of_impl)] - use rustc_errors::DiagnosticBuilder; use rustc_infer::infer::canonical::Canonical; use rustc_infer::infer::error_reporting::nice_region_error::NiceRegionError; diff --git a/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs b/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs index b0b7cc076bab5..226a7ddba6cc5 100644 --- a/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs +++ b/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs @@ -1,5 +1,8 @@ // ignore-tidy-filelength +#![allow(rustc::diagnostic_outside_of_impl)] +#![allow(rustc::untranslatable_diagnostic)] + use either::Either; use rustc_data_structures::captures::Captures; use rustc_data_structures::fx::FxIndexSet; diff --git a/compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs b/compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs index 4f66468a865f8..9627dc5368066 100644 --- a/compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs +++ b/compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs @@ -1,5 +1,8 @@ //! Print diagnostics to explain why values are borrowed. +#![allow(rustc::diagnostic_outside_of_impl)] +#![allow(rustc::untranslatable_diagnostic)] + use rustc_errors::{Applicability, Diagnostic}; use rustc_hir as hir; use rustc_hir::intravisit::Visitor; diff --git a/compiler/rustc_borrowck/src/diagnostics/find_all_local_uses.rs b/compiler/rustc_borrowck/src/diagnostics/find_all_local_uses.rs index 2c4d953f011fc..ff4f2bb9614f1 100644 --- a/compiler/rustc_borrowck/src/diagnostics/find_all_local_uses.rs +++ b/compiler/rustc_borrowck/src/diagnostics/find_all_local_uses.rs @@ -1,6 +1,3 @@ -#![deny(rustc::untranslatable_diagnostic)] -#![deny(rustc::diagnostic_outside_of_impl)] - use std::collections::BTreeSet; use rustc_middle::mir::visit::{PlaceContext, Visitor}; diff --git a/compiler/rustc_borrowck/src/diagnostics/find_use.rs b/compiler/rustc_borrowck/src/diagnostics/find_use.rs index 2495613fea1d2..94b17e0a2f99c 100644 --- a/compiler/rustc_borrowck/src/diagnostics/find_use.rs +++ b/compiler/rustc_borrowck/src/diagnostics/find_use.rs @@ -1,6 +1,3 @@ -#![deny(rustc::untranslatable_diagnostic)] -#![deny(rustc::diagnostic_outside_of_impl)] - use std::collections::VecDeque; use std::rc::Rc; diff --git a/compiler/rustc_borrowck/src/diagnostics/move_errors.rs b/compiler/rustc_borrowck/src/diagnostics/move_errors.rs index 0a0bb75a2a3a6..126a50c91b494 100644 --- a/compiler/rustc_borrowck/src/diagnostics/move_errors.rs +++ b/compiler/rustc_borrowck/src/diagnostics/move_errors.rs @@ -1,3 +1,6 @@ +#![allow(rustc::diagnostic_outside_of_impl)] +#![allow(rustc::untranslatable_diagnostic)] + use rustc_errors::{Applicability, Diagnostic, DiagnosticBuilder}; use rustc_middle::mir::*; use rustc_middle::ty::{self, Ty}; diff --git a/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs b/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs index 3fddf67f55b97..4200bdf453db2 100644 --- a/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs +++ b/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs @@ -1,3 +1,6 @@ +#![allow(rustc::diagnostic_outside_of_impl)] +#![allow(rustc::untranslatable_diagnostic)] + use hir::ExprKind; use rustc_errors::{Applicability, Diagnostic, DiagnosticBuilder}; use rustc_hir as hir; diff --git a/compiler/rustc_borrowck/src/diagnostics/outlives_suggestion.rs b/compiler/rustc_borrowck/src/diagnostics/outlives_suggestion.rs index bac1d9dd57f6b..93e28a5f3f3e2 100644 --- a/compiler/rustc_borrowck/src/diagnostics/outlives_suggestion.rs +++ b/compiler/rustc_borrowck/src/diagnostics/outlives_suggestion.rs @@ -1,6 +1,9 @@ //! Contains utilities for generating suggestions for borrowck errors related to unsatisfied //! outlives constraints. +#![allow(rustc::diagnostic_outside_of_impl)] +#![allow(rustc::untranslatable_diagnostic)] + use rustc_data_structures::fx::FxIndexSet; use rustc_errors::Diagnostic; use rustc_middle::ty::RegionVid; diff --git a/compiler/rustc_borrowck/src/diagnostics/region_errors.rs b/compiler/rustc_borrowck/src/diagnostics/region_errors.rs index 8c8ca1ead400b..3a16d37b1b1b9 100644 --- a/compiler/rustc_borrowck/src/diagnostics/region_errors.rs +++ b/compiler/rustc_borrowck/src/diagnostics/region_errors.rs @@ -1,5 +1,3 @@ -#![deny(rustc::untranslatable_diagnostic)] -#![deny(rustc::diagnostic_outside_of_impl)] //! Error reporting machinery for lifetime errors. use rustc_data_structures::fx::FxIndexSet; diff --git a/compiler/rustc_borrowck/src/diagnostics/region_name.rs b/compiler/rustc_borrowck/src/diagnostics/region_name.rs index 15e1066e983a9..8d5a6731f9b44 100644 --- a/compiler/rustc_borrowck/src/diagnostics/region_name.rs +++ b/compiler/rustc_borrowck/src/diagnostics/region_name.rs @@ -1,3 +1,6 @@ +#![allow(rustc::diagnostic_outside_of_impl)] +#![allow(rustc::untranslatable_diagnostic)] + use std::fmt::{self, Display}; use std::iter; diff --git a/compiler/rustc_borrowck/src/diagnostics/var_name.rs b/compiler/rustc_borrowck/src/diagnostics/var_name.rs index 28e07f2a81edd..0479cd8af35e2 100644 --- a/compiler/rustc_borrowck/src/diagnostics/var_name.rs +++ b/compiler/rustc_borrowck/src/diagnostics/var_name.rs @@ -1,6 +1,3 @@ -#![deny(rustc::untranslatable_diagnostic)] -#![deny(rustc::diagnostic_outside_of_impl)] - use crate::region_infer::RegionInferenceContext; use rustc_index::IndexSlice; use rustc_middle::mir::{Body, Local}; diff --git a/compiler/rustc_borrowck/src/facts.rs b/compiler/rustc_borrowck/src/facts.rs index c54e7070478ca..68dc9a6764bfc 100644 --- a/compiler/rustc_borrowck/src/facts.rs +++ b/compiler/rustc_borrowck/src/facts.rs @@ -1,5 +1,3 @@ -#![deny(rustc::untranslatable_diagnostic)] -#![deny(rustc::diagnostic_outside_of_impl)] use crate::location::{LocationIndex, LocationTable}; use crate::BorrowIndex; use polonius_engine::AllFacts as PoloniusFacts; diff --git a/compiler/rustc_borrowck/src/location.rs b/compiler/rustc_borrowck/src/location.rs index 6f09393169f3d..63e59217e5d7d 100644 --- a/compiler/rustc_borrowck/src/location.rs +++ b/compiler/rustc_borrowck/src/location.rs @@ -1,5 +1,3 @@ -#![deny(rustc::untranslatable_diagnostic)] -#![deny(rustc::diagnostic_outside_of_impl)] use rustc_index::IndexVec; use rustc_middle::mir::{BasicBlock, Body, Location}; diff --git a/compiler/rustc_borrowck/src/member_constraints.rs b/compiler/rustc_borrowck/src/member_constraints.rs index 842e90080582f..5129b32d492dd 100644 --- a/compiler/rustc_borrowck/src/member_constraints.rs +++ b/compiler/rustc_borrowck/src/member_constraints.rs @@ -1,5 +1,3 @@ -#![deny(rustc::untranslatable_diagnostic)] -#![deny(rustc::diagnostic_outside_of_impl)] use rustc_data_structures::captures::Captures; use rustc_data_structures::fx::FxIndexMap; use rustc_index::{IndexSlice, IndexVec}; diff --git a/compiler/rustc_borrowck/src/nll.rs b/compiler/rustc_borrowck/src/nll.rs index 7ace013975e1b..67237c3adcf20 100644 --- a/compiler/rustc_borrowck/src/nll.rs +++ b/compiler/rustc_borrowck/src/nll.rs @@ -1,5 +1,3 @@ -#![deny(rustc::untranslatable_diagnostic)] -#![deny(rustc::diagnostic_outside_of_impl)] //! The entry point of the NLL borrow checker. use polonius_engine::{Algorithm, Output}; diff --git a/compiler/rustc_borrowck/src/path_utils.rs b/compiler/rustc_borrowck/src/path_utils.rs index 2d997dfadf004..d2c1c384e52a8 100644 --- a/compiler/rustc_borrowck/src/path_utils.rs +++ b/compiler/rustc_borrowck/src/path_utils.rs @@ -1,5 +1,3 @@ -#![deny(rustc::untranslatable_diagnostic)] -#![deny(rustc::diagnostic_outside_of_impl)] use crate::borrow_set::{BorrowData, BorrowSet, TwoPhaseActivation}; use crate::places_conflict; use crate::AccessDepth; diff --git a/compiler/rustc_borrowck/src/place_ext.rs b/compiler/rustc_borrowck/src/place_ext.rs index 3d7e8c6ebf330..b59ab7fafa576 100644 --- a/compiler/rustc_borrowck/src/place_ext.rs +++ b/compiler/rustc_borrowck/src/place_ext.rs @@ -1,5 +1,3 @@ -#![deny(rustc::untranslatable_diagnostic)] -#![deny(rustc::diagnostic_outside_of_impl)] use crate::borrow_set::LocalsStateAtExit; use rustc_hir as hir; use rustc_middle::mir::ProjectionElem; diff --git a/compiler/rustc_borrowck/src/places_conflict.rs b/compiler/rustc_borrowck/src/places_conflict.rs index 777ebf0d438dc..7e8dba43b715e 100644 --- a/compiler/rustc_borrowck/src/places_conflict.rs +++ b/compiler/rustc_borrowck/src/places_conflict.rs @@ -50,8 +50,6 @@ //! and either equal or disjoint. //! - If we did run out of access, the borrow can access a part of it. -#![deny(rustc::untranslatable_diagnostic)] -#![deny(rustc::diagnostic_outside_of_impl)] use crate::ArtificialField; use crate::Overlap; use crate::{AccessDepth, Deep, Shallow}; diff --git a/compiler/rustc_borrowck/src/polonius/loan_invalidations.rs b/compiler/rustc_borrowck/src/polonius/loan_invalidations.rs index 5c9056272cc0d..93aae1a7f9762 100644 --- a/compiler/rustc_borrowck/src/polonius/loan_invalidations.rs +++ b/compiler/rustc_borrowck/src/polonius/loan_invalidations.rs @@ -1,5 +1,3 @@ -#![deny(rustc::untranslatable_diagnostic)] -#![deny(rustc::diagnostic_outside_of_impl)] use rustc_data_structures::graph::dominators::Dominators; use rustc_middle::mir::visit::Visitor; use rustc_middle::mir::{self, BasicBlock, Body, Location, NonDivergingIntrinsic, Place, Rvalue}; diff --git a/compiler/rustc_borrowck/src/polonius/loan_kills.rs b/compiler/rustc_borrowck/src/polonius/loan_kills.rs index 5df943837025e..53adad5561e60 100644 --- a/compiler/rustc_borrowck/src/polonius/loan_kills.rs +++ b/compiler/rustc_borrowck/src/polonius/loan_kills.rs @@ -1,5 +1,3 @@ -#![deny(rustc::untranslatable_diagnostic)] -#![deny(rustc::diagnostic_outside_of_impl)] use rustc_middle::mir::visit::Visitor; use rustc_middle::mir::{ Body, Local, Location, Place, PlaceRef, ProjectionElem, Rvalue, Statement, StatementKind, diff --git a/compiler/rustc_borrowck/src/prefixes.rs b/compiler/rustc_borrowck/src/prefixes.rs index e9c9709bd1f1a..8bb3dc88b3467 100644 --- a/compiler/rustc_borrowck/src/prefixes.rs +++ b/compiler/rustc_borrowck/src/prefixes.rs @@ -1,5 +1,3 @@ -#![deny(rustc::untranslatable_diagnostic)] -#![deny(rustc::diagnostic_outside_of_impl)] //! From the NLL RFC: "The deep [aka 'supporting'] prefixes for an //! place are formed by stripping away fields and derefs, except that //! we stop when we reach the deref of a shared reference. [...] " diff --git a/compiler/rustc_borrowck/src/region_infer/dump_mir.rs b/compiler/rustc_borrowck/src/region_infer/dump_mir.rs index cfbb2766c3397..53541b33c41d1 100644 --- a/compiler/rustc_borrowck/src/region_infer/dump_mir.rs +++ b/compiler/rustc_borrowck/src/region_infer/dump_mir.rs @@ -1,5 +1,3 @@ -#![deny(rustc::untranslatable_diagnostic)] -#![deny(rustc::diagnostic_outside_of_impl)] //! As part of generating the regions, if you enable `-Zdump-mir=nll`, //! we will generate an annotated copy of the MIR that includes the //! state of region inference. This code handles emitting the region diff --git a/compiler/rustc_borrowck/src/region_infer/graphviz.rs b/compiler/rustc_borrowck/src/region_infer/graphviz.rs index 408c8390e763c..c103ba3c40709 100644 --- a/compiler/rustc_borrowck/src/region_infer/graphviz.rs +++ b/compiler/rustc_borrowck/src/region_infer/graphviz.rs @@ -1,5 +1,3 @@ -#![deny(rustc::untranslatable_diagnostic)] -#![deny(rustc::diagnostic_outside_of_impl)] //! This module provides linkage between RegionInferenceContext and //! `rustc_graphviz` traits, specialized to attaching borrowck analysis //! data to rendered labels. diff --git a/compiler/rustc_borrowck/src/region_infer/opaque_types.rs b/compiler/rustc_borrowck/src/region_infer/opaque_types.rs index 462b5c8da42c7..636c174e002d2 100644 --- a/compiler/rustc_borrowck/src/region_infer/opaque_types.rs +++ b/compiler/rustc_borrowck/src/region_infer/opaque_types.rs @@ -418,6 +418,8 @@ fn check_opaque_type_parameter_valid( .into_iter() .map(|i| tcx.def_span(opaque_generics.param_at(i, tcx).def_id)) .collect(); + #[allow(rustc::diagnostic_outside_of_impl)] + #[allow(rustc::untranslatable_diagnostic)] return Err(tcx .dcx() .struct_span_err(span, "non-defining opaque type use in defining scope") diff --git a/compiler/rustc_borrowck/src/region_infer/reverse_sccs.rs b/compiler/rustc_borrowck/src/region_infer/reverse_sccs.rs index fe56bd54a3f17..eeb944702a7f9 100644 --- a/compiler/rustc_borrowck/src/region_infer/reverse_sccs.rs +++ b/compiler/rustc_borrowck/src/region_infer/reverse_sccs.rs @@ -1,5 +1,3 @@ -#![deny(rustc::untranslatable_diagnostic)] -#![deny(rustc::diagnostic_outside_of_impl)] use crate::constraints::ConstraintSccIndex; use crate::RegionInferenceContext; use itertools::Itertools; diff --git a/compiler/rustc_borrowck/src/region_infer/values.rs b/compiler/rustc_borrowck/src/region_infer/values.rs index e147f62011db9..b1caaa6388186 100644 --- a/compiler/rustc_borrowck/src/region_infer/values.rs +++ b/compiler/rustc_borrowck/src/region_infer/values.rs @@ -1,5 +1,3 @@ -#![deny(rustc::untranslatable_diagnostic)] -#![deny(rustc::diagnostic_outside_of_impl)] use rustc_data_structures::fx::FxHashSet; use rustc_data_structures::fx::FxIndexSet; use rustc_index::bit_set::SparseBitMatrix; diff --git a/compiler/rustc_borrowck/src/renumber.rs b/compiler/rustc_borrowck/src/renumber.rs index a31d39e14cd28..dca8df3280028 100644 --- a/compiler/rustc_borrowck/src/renumber.rs +++ b/compiler/rustc_borrowck/src/renumber.rs @@ -1,5 +1,3 @@ -#![deny(rustc::untranslatable_diagnostic)] -#![deny(rustc::diagnostic_outside_of_impl)] use crate::BorrowckInferCtxt; use rustc_index::IndexSlice; use rustc_infer::infer::NllRegionVariableOrigin; diff --git a/compiler/rustc_borrowck/src/type_check/mod.rs b/compiler/rustc_borrowck/src/type_check/mod.rs index 59c4d9a6c78ca..63b0dea3e2924 100644 --- a/compiler/rustc_borrowck/src/type_check/mod.rs +++ b/compiler/rustc_borrowck/src/type_check/mod.rs @@ -1,5 +1,3 @@ -#![deny(rustc::untranslatable_diagnostic)] -#![deny(rustc::diagnostic_outside_of_impl)] //! This pass type-checks the MIR to ensure it is not broken. use std::rc::Rc; diff --git a/compiler/rustc_borrowck/src/universal_regions.rs b/compiler/rustc_borrowck/src/universal_regions.rs index ae8a135f09059..7ffa98f5806a8 100644 --- a/compiler/rustc_borrowck/src/universal_regions.rs +++ b/compiler/rustc_borrowck/src/universal_regions.rs @@ -12,6 +12,9 @@ //! The code in this file doesn't *do anything* with those results; it //! just returns them for other code to use. +#![allow(rustc::diagnostic_outside_of_impl)] +#![allow(rustc::untranslatable_diagnostic)] + use rustc_data_structures::fx::FxHashMap; use rustc_errors::Diagnostic; use rustc_hir::def_id::{DefId, LocalDefId}; diff --git a/compiler/rustc_borrowck/src/used_muts.rs b/compiler/rustc_borrowck/src/used_muts.rs index 6ac8e1ba7156a..81757a62e5bc5 100644 --- a/compiler/rustc_borrowck/src/used_muts.rs +++ b/compiler/rustc_borrowck/src/used_muts.rs @@ -1,5 +1,3 @@ -#![deny(rustc::untranslatable_diagnostic)] -#![deny(rustc::diagnostic_outside_of_impl)] use rustc_data_structures::fx::FxIndexSet; use rustc_middle::mir::visit::{PlaceContext, Visitor}; use rustc_middle::mir::{ diff --git a/compiler/rustc_builtin_macros/src/lib.rs b/compiler/rustc_builtin_macros/src/lib.rs index 4d7957ef4ddb0..d30ccab239437 100644 --- a/compiler/rustc_builtin_macros/src/lib.rs +++ b/compiler/rustc_builtin_macros/src/lib.rs @@ -2,6 +2,8 @@ //! injecting code into the crate before it is lowered to HIR. #![allow(internal_features)] +#![allow(rustc::diagnostic_outside_of_impl)] +#![allow(rustc::untranslatable_diagnostic)] #![feature(rustdoc_internals)] #![doc(rust_logo)] #![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")] diff --git a/compiler/rustc_codegen_cranelift/src/lib.rs b/compiler/rustc_codegen_cranelift/src/lib.rs index 416f87fcc87b3..7c432e9c59051 100644 --- a/compiler/rustc_codegen_cranelift/src/lib.rs +++ b/compiler/rustc_codegen_cranelift/src/lib.rs @@ -3,6 +3,8 @@ #![cfg_attr(doc, doc(rust_logo))] #![feature(rustc_private)] // Note: please avoid adding other feature gates where possible +#![allow(rustc::diagnostic_outside_of_impl)] +#![allow(rustc::untranslatable_diagnostic)] #![warn(rust_2018_idioms)] #![warn(unused_lifetimes)] #![warn(unreachable_pub)] diff --git a/compiler/rustc_codegen_gcc/src/lib.rs b/compiler/rustc_codegen_gcc/src/lib.rs index f8f054db65ede..863b6333bcc29 100644 --- a/compiler/rustc_codegen_gcc/src/lib.rs +++ b/compiler/rustc_codegen_gcc/src/lib.rs @@ -27,8 +27,6 @@ #![recursion_limit="256"] #![warn(rust_2018_idioms)] #![warn(unused_lifetimes)] -#![deny(rustc::untranslatable_diagnostic)] -#![deny(rustc::diagnostic_outside_of_impl)] extern crate rustc_apfloat; extern crate rustc_ast; diff --git a/compiler/rustc_codegen_llvm/src/lib.rs b/compiler/rustc_codegen_llvm/src/lib.rs index f4f29078190a1..de96bf477adb7 100644 --- a/compiler/rustc_codegen_llvm/src/lib.rs +++ b/compiler/rustc_codegen_llvm/src/lib.rs @@ -15,8 +15,6 @@ #![feature(let_chains)] #![feature(min_specialization)] #![feature(impl_trait_in_assoc_type)] -#![deny(rustc::untranslatable_diagnostic)] -#![deny(rustc::diagnostic_outside_of_impl)] #[macro_use] extern crate rustc_macros; diff --git a/compiler/rustc_codegen_ssa/src/lib.rs b/compiler/rustc_codegen_ssa/src/lib.rs index fc833a3863e40..1afc597a7ef01 100644 --- a/compiler/rustc_codegen_ssa/src/lib.rs +++ b/compiler/rustc_codegen_ssa/src/lib.rs @@ -2,6 +2,8 @@ #![doc(rust_logo)] #![feature(rustdoc_internals)] #![allow(internal_features)] +#![allow(rustc::diagnostic_outside_of_impl)] +#![allow(rustc::untranslatable_diagnostic)] #![feature(associated_type_bounds)] #![feature(box_patterns)] #![feature(if_let_guard)] diff --git a/compiler/rustc_const_eval/src/lib.rs b/compiler/rustc_const_eval/src/lib.rs index 946a49982aa1a..839cfd8d85acf 100644 --- a/compiler/rustc_const_eval/src/lib.rs +++ b/compiler/rustc_const_eval/src/lib.rs @@ -5,9 +5,9 @@ Rust MIR: a lowered representation of Rust. */ #![allow(internal_features)] +#![allow(rustc::diagnostic_outside_of_impl)] #![feature(rustdoc_internals)] #![doc(rust_logo)] -#![deny(rustc::untranslatable_diagnostic)] #![feature(assert_matches)] #![feature(box_patterns)] #![feature(decl_macro)] diff --git a/compiler/rustc_data_structures/src/lib.rs b/compiler/rustc_data_structures/src/lib.rs index 563d8501890ce..ef1183e979fdd 100644 --- a/compiler/rustc_data_structures/src/lib.rs +++ b/compiler/rustc_data_structures/src/lib.rs @@ -11,8 +11,6 @@ #![allow(rustc::default_hash_types)] #![allow(rustc::potential_query_instability)] #![cfg_attr(not(parallel_compiler), feature(cell_leak))] -#![deny(rustc::diagnostic_outside_of_impl)] -#![deny(rustc::untranslatable_diagnostic)] #![deny(unsafe_op_in_unsafe_fn)] #![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")] #![doc(rust_logo)] diff --git a/compiler/rustc_driver_impl/src/lib.rs b/compiler/rustc_driver_impl/src/lib.rs index 5903c43ae98af..2d40f15dca3a3 100644 --- a/compiler/rustc_driver_impl/src/lib.rs +++ b/compiler/rustc_driver_impl/src/lib.rs @@ -12,8 +12,6 @@ #![feature(let_chains)] #![feature(panic_update_hook)] #![feature(result_flattening)] -#![deny(rustc::untranslatable_diagnostic)] -#![deny(rustc::diagnostic_outside_of_impl)] #[macro_use] extern crate tracing; diff --git a/compiler/rustc_error_codes/src/lib.rs b/compiler/rustc_error_codes/src/lib.rs index 5b2766618fccb..da688e385aa09 100644 --- a/compiler/rustc_error_codes/src/lib.rs +++ b/compiler/rustc_error_codes/src/lib.rs @@ -5,8 +5,6 @@ #![feature(rustdoc_internals)] #![doc(rust_logo)] #![deny(rustdoc::invalid_codeblock_attributes)] -#![deny(rustc::untranslatable_diagnostic)] -#![deny(rustc::diagnostic_outside_of_impl)] // This higher-order macro defines the error codes that are in use. It is used // in the `rustc_errors` crate. Removed error codes are listed in the comment diff --git a/compiler/rustc_error_messages/src/lib.rs b/compiler/rustc_error_messages/src/lib.rs index 8fd7c5764797e..e9627007e032f 100644 --- a/compiler/rustc_error_messages/src/lib.rs +++ b/compiler/rustc_error_messages/src/lib.rs @@ -3,8 +3,6 @@ #![feature(lazy_cell)] #![feature(rustc_attrs)] #![feature(type_alias_impl_trait)] -#![deny(rustc::untranslatable_diagnostic)] -#![deny(rustc::diagnostic_outside_of_impl)] #![allow(internal_features)] #[macro_use] diff --git a/compiler/rustc_errors/src/lib.rs b/compiler/rustc_errors/src/lib.rs index b2bd4d8eb956e..ccdad326c6320 100644 --- a/compiler/rustc_errors/src/lib.rs +++ b/compiler/rustc_errors/src/lib.rs @@ -5,6 +5,8 @@ // tidy-alphabetical-start #![allow(incomplete_features)] #![allow(internal_features)] +#![allow(rustc::diagnostic_outside_of_impl)] +#![allow(rustc::untranslatable_diagnostic)] #![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")] #![doc(rust_logo)] #![feature(array_windows)] diff --git a/compiler/rustc_expand/src/base.rs b/compiler/rustc_expand/src/base.rs index 657e19277a7ed..cfeb31fc4c813 100644 --- a/compiler/rustc_expand/src/base.rs +++ b/compiler/rustc_expand/src/base.rs @@ -1,5 +1,3 @@ -#![deny(rustc::untranslatable_diagnostic)] - use crate::base::ast::NestedMetaItem; use crate::errors; use crate::expand::{self, AstFragment, Invocation}; diff --git a/compiler/rustc_expand/src/lib.rs b/compiler/rustc_expand/src/lib.rs index 2cf6a8df7c5ff..4da86d77dc88f 100644 --- a/compiler/rustc_expand/src/lib.rs +++ b/compiler/rustc_expand/src/lib.rs @@ -10,7 +10,7 @@ #![feature(proc_macro_internals)] #![feature(proc_macro_span)] #![feature(try_blocks)] -#![deny(rustc::untranslatable_diagnostic)] +#![allow(rustc::diagnostic_outside_of_impl)] #![allow(internal_features)] #[macro_use] diff --git a/compiler/rustc_feature/src/lib.rs b/compiler/rustc_feature/src/lib.rs index cd1d9b13daa15..f1c8f2e2dde5c 100644 --- a/compiler/rustc_feature/src/lib.rs +++ b/compiler/rustc_feature/src/lib.rs @@ -15,8 +15,6 @@ #![feature(rustdoc_internals)] #![doc(rust_logo)] #![feature(lazy_cell)] -#![deny(rustc::untranslatable_diagnostic)] -#![deny(rustc::diagnostic_outside_of_impl)] mod accepted; mod builtin_attrs; diff --git a/compiler/rustc_fluent_macro/src/lib.rs b/compiler/rustc_fluent_macro/src/lib.rs index fc65d1eb8c4ce..e3784409af8fd 100644 --- a/compiler/rustc_fluent_macro/src/lib.rs +++ b/compiler/rustc_fluent_macro/src/lib.rs @@ -4,8 +4,6 @@ #![feature(rustdoc_internals)] #![feature(proc_macro_diagnostic)] #![feature(proc_macro_span)] -#![deny(rustc::untranslatable_diagnostic)] -#![deny(rustc::diagnostic_outside_of_impl)] #![allow(rustc::default_hash_types)] use proc_macro::TokenStream; diff --git a/compiler/rustc_fs_util/src/lib.rs b/compiler/rustc_fs_util/src/lib.rs index 81d6333814544..3359fef8c1c46 100644 --- a/compiler/rustc_fs_util/src/lib.rs +++ b/compiler/rustc_fs_util/src/lib.rs @@ -1,6 +1,4 @@ #![feature(absolute_path)] -#![deny(rustc::untranslatable_diagnostic)] -#![deny(rustc::diagnostic_outside_of_impl)] use std::ffi::CString; use std::fs; diff --git a/compiler/rustc_graphviz/src/lib.rs b/compiler/rustc_graphviz/src/lib.rs index eba3215d93153..43bee5c4be029 100644 --- a/compiler/rustc_graphviz/src/lib.rs +++ b/compiler/rustc_graphviz/src/lib.rs @@ -276,8 +276,6 @@ #![feature(rustdoc_internals)] #![doc(rust_logo)] #![allow(internal_features)] -#![deny(rustc::untranslatable_diagnostic)] -#![deny(rustc::diagnostic_outside_of_impl)] use LabelText::*; diff --git a/compiler/rustc_hir/src/lib.rs b/compiler/rustc_hir/src/lib.rs index 6c64d802e68f1..aff946ac58081 100644 --- a/compiler/rustc_hir/src/lib.rs +++ b/compiler/rustc_hir/src/lib.rs @@ -9,8 +9,6 @@ #![feature(never_type)] #![feature(rustc_attrs)] #![feature(variant_count)] -#![deny(rustc::untranslatable_diagnostic)] -#![deny(rustc::diagnostic_outside_of_impl)] #![allow(internal_features)] #[macro_use] diff --git a/compiler/rustc_hir_analysis/src/lib.rs b/compiler/rustc_hir_analysis/src/lib.rs index 454cb97ac148b..9904d8dc5faad 100644 --- a/compiler/rustc_hir_analysis/src/lib.rs +++ b/compiler/rustc_hir_analysis/src/lib.rs @@ -55,7 +55,9 @@ This API is completely unstable and subject to change. */ +#![allow(rustc::diagnostic_outside_of_impl)] #![allow(rustc::potential_query_instability)] +#![allow(rustc::untranslatable_diagnostic)] #![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")] #![doc(rust_logo)] #![feature(rustdoc_internals)] diff --git a/compiler/rustc_hir_pretty/src/lib.rs b/compiler/rustc_hir_pretty/src/lib.rs index 9d0c5cb0f32b0..b7709deeb4ad4 100644 --- a/compiler/rustc_hir_pretty/src/lib.rs +++ b/compiler/rustc_hir_pretty/src/lib.rs @@ -2,8 +2,6 @@ //! the definitions in this file have equivalents in `rustc_ast_pretty`. #![recursion_limit = "256"] -#![deny(rustc::untranslatable_diagnostic)] -#![deny(rustc::diagnostic_outside_of_impl)] use rustc_ast as ast; use rustc_ast::util::parser::{self, AssocOp, Fixity}; diff --git a/compiler/rustc_hir_typeck/src/lib.rs b/compiler/rustc_hir_typeck/src/lib.rs index deb3ad2edc740..3054a70e6d460 100644 --- a/compiler/rustc_hir_typeck/src/lib.rs +++ b/compiler/rustc_hir_typeck/src/lib.rs @@ -1,3 +1,5 @@ +#![allow(rustc::diagnostic_outside_of_impl)] +#![allow(rustc::untranslatable_diagnostic)] #![feature(if_let_guard)] #![feature(let_chains)] #![feature(try_blocks)] diff --git a/compiler/rustc_incremental/src/lib.rs b/compiler/rustc_incremental/src/lib.rs index 82f02b7d47aac..0729986f32fdf 100644 --- a/compiler/rustc_incremental/src/lib.rs +++ b/compiler/rustc_incremental/src/lib.rs @@ -5,8 +5,6 @@ #![doc(rust_logo)] #![feature(rustdoc_internals)] #![allow(internal_features)] -#![deny(rustc::untranslatable_diagnostic)] -#![deny(rustc::diagnostic_outside_of_impl)] #[macro_use] extern crate rustc_middle; diff --git a/compiler/rustc_index/src/lib.rs b/compiler/rustc_index/src/lib.rs index 854841206b89b..6fcb3a024ab6f 100644 --- a/compiler/rustc_index/src/lib.rs +++ b/compiler/rustc_index/src/lib.rs @@ -1,5 +1,3 @@ -#![deny(rustc::untranslatable_diagnostic)] -#![deny(rustc::diagnostic_outside_of_impl)] #![cfg_attr( feature = "nightly", feature(extend_one, min_specialization, new_uninit, step_trait, test) diff --git a/compiler/rustc_infer/src/lib.rs b/compiler/rustc_infer/src/lib.rs index e2dd4b49e1a4b..622cdf0c7b895 100644 --- a/compiler/rustc_infer/src/lib.rs +++ b/compiler/rustc_infer/src/lib.rs @@ -16,6 +16,8 @@ #![doc(rust_logo)] #![feature(rustdoc_internals)] #![allow(internal_features)] +#![allow(rustc::diagnostic_outside_of_impl)] +#![allow(rustc::untranslatable_diagnostic)] #![feature(associated_type_bounds)] #![feature(box_patterns)] #![feature(extend_one)] diff --git a/compiler/rustc_interface/src/lib.rs b/compiler/rustc_interface/src/lib.rs index 69414a1379515..7d69e49b209f5 100644 --- a/compiler/rustc_interface/src/lib.rs +++ b/compiler/rustc_interface/src/lib.rs @@ -4,8 +4,6 @@ #![feature(let_chains)] #![feature(thread_spawn_unchecked)] #![feature(try_blocks)] -#![deny(rustc::untranslatable_diagnostic)] -#![deny(rustc::diagnostic_outside_of_impl)] #[macro_use] extern crate tracing; diff --git a/compiler/rustc_lexer/src/lib.rs b/compiler/rustc_lexer/src/lib.rs index f6c9289b529c7..ca84e930c2439 100644 --- a/compiler/rustc_lexer/src/lib.rs +++ b/compiler/rustc_lexer/src/lib.rs @@ -18,8 +18,7 @@ //! lexeme types. //! //! [`rustc_parse::lexer`]: ../rustc_parse/lexer/index.html -#![deny(rustc::untranslatable_diagnostic)] -#![deny(rustc::diagnostic_outside_of_impl)] + // We want to be able to build this crate with a stable compiler, // so no `#![feature]` attributes should be added. #![deny(unstable_features)] diff --git a/compiler/rustc_lint/src/internal.rs b/compiler/rustc_lint/src/internal.rs index eb2490a47d09d..516df14c8943a 100644 --- a/compiler/rustc_lint/src/internal.rs +++ b/compiler/rustc_lint/src/internal.rs @@ -345,7 +345,7 @@ declare_tool_lint! { /// /// More details on translatable diagnostics can be found [here](https://rustc-dev-guide.rust-lang.org/diagnostics/translation.html). pub rustc::UNTRANSLATABLE_DIAGNOSTIC, - Allow, + Deny, "prevent creation of diagnostics which cannot be translated", report_in_external_macro: true } @@ -357,7 +357,7 @@ declare_tool_lint! { /// /// More details on diagnostics implementations can be found [here](https://rustc-dev-guide.rust-lang.org/diagnostics/diagnostic-structs.html). pub rustc::DIAGNOSTIC_OUTSIDE_OF_IMPL, - Allow, + Deny, "prevent creation of diagnostics outside of `IntoDiagnostic`/`AddToDiagnostic` impls", report_in_external_macro: true } diff --git a/compiler/rustc_lint/src/lib.rs b/compiler/rustc_lint/src/lib.rs index 1d9ce10bcaf38..9a7a5c0c6df00 100644 --- a/compiler/rustc_lint/src/lib.rs +++ b/compiler/rustc_lint/src/lib.rs @@ -37,8 +37,6 @@ #![cfg_attr(not(bootstrap), feature(trait_upcasting))] #![feature(min_specialization)] #![feature(rustc_attrs)] -#![deny(rustc::untranslatable_diagnostic)] -#![deny(rustc::diagnostic_outside_of_impl)] #![allow(internal_features)] #[macro_use] diff --git a/compiler/rustc_lint/src/lints.rs b/compiler/rustc_lint/src/lints.rs index f916deb4a46d1..c0d76b4e27eeb 100644 --- a/compiler/rustc_lint/src/lints.rs +++ b/compiler/rustc_lint/src/lints.rs @@ -1,5 +1,6 @@ -#![allow(rustc::untranslatable_diagnostic)] #![allow(rustc::diagnostic_outside_of_impl)] +#![allow(rustc::untranslatable_diagnostic)] + use std::num::NonZeroU32; use crate::errors::RequestedLevel; diff --git a/compiler/rustc_lint_defs/src/lib.rs b/compiler/rustc_lint_defs/src/lib.rs index eed35326c4501..8b7e82d2113f8 100644 --- a/compiler/rustc_lint_defs/src/lib.rs +++ b/compiler/rustc_lint_defs/src/lib.rs @@ -1,6 +1,4 @@ #![feature(min_specialization)] -#![deny(rustc::untranslatable_diagnostic)] -#![deny(rustc::diagnostic_outside_of_impl)] #[macro_use] extern crate rustc_macros; diff --git a/compiler/rustc_llvm/src/lib.rs b/compiler/rustc_llvm/src/lib.rs index ca0aec71052d0..6a570c97c8888 100644 --- a/compiler/rustc_llvm/src/lib.rs +++ b/compiler/rustc_llvm/src/lib.rs @@ -1,5 +1,3 @@ -#![deny(rustc::untranslatable_diagnostic)] -#![deny(rustc::diagnostic_outside_of_impl)] #![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")] #![doc(rust_logo)] #![feature(rustdoc_internals)] diff --git a/compiler/rustc_log/src/lib.rs b/compiler/rustc_log/src/lib.rs index e3464cb8a2df6..1a78f9f0f86e5 100644 --- a/compiler/rustc_log/src/lib.rs +++ b/compiler/rustc_log/src/lib.rs @@ -38,9 +38,6 @@ //! debugging, you can make changes inside those crates and quickly run main.rs //! to read the debug logs. -#![deny(rustc::untranslatable_diagnostic)] -#![deny(rustc::diagnostic_outside_of_impl)] - use std::env::{self, VarError}; use std::fmt::{self, Display}; use std::io::{self, IsTerminal}; diff --git a/compiler/rustc_macros/src/lib.rs b/compiler/rustc_macros/src/lib.rs index 9e85a59b5b92b..af65c908ee66b 100644 --- a/compiler/rustc_macros/src/lib.rs +++ b/compiler/rustc_macros/src/lib.rs @@ -6,8 +6,6 @@ #![feature(proc_macro_span)] #![feature(proc_macro_tracked_env)] #![allow(rustc::default_hash_types)] -#![deny(rustc::untranslatable_diagnostic)] -#![deny(rustc::diagnostic_outside_of_impl)] #![allow(internal_features)] use synstructure::decl_derive; diff --git a/compiler/rustc_metadata/src/lib.rs b/compiler/rustc_metadata/src/lib.rs index 471425e80174f..2e7130f356579 100644 --- a/compiler/rustc_metadata/src/lib.rs +++ b/compiler/rustc_metadata/src/lib.rs @@ -15,8 +15,6 @@ #![feature(try_blocks)] #![feature(never_type)] #![allow(rustc::potential_query_instability)] -#![deny(rustc::untranslatable_diagnostic)] -#![deny(rustc::diagnostic_outside_of_impl)] extern crate proc_macro; diff --git a/compiler/rustc_middle/src/lib.rs b/compiler/rustc_middle/src/lib.rs index ddfb2ece39f10..515b6703b1e36 100644 --- a/compiler/rustc_middle/src/lib.rs +++ b/compiler/rustc_middle/src/lib.rs @@ -57,8 +57,10 @@ #![feature(const_option)] #![feature(ptr_alignment_type)] #![feature(macro_metavar_expr)] -#![allow(rustc::potential_query_instability)] #![allow(internal_features)] +#![allow(rustc::potential_query_instability)] +#![allow(rustc::diagnostic_outside_of_impl)] +#![allow(rustc::untranslatable_diagnostic)] #[macro_use] extern crate bitflags; diff --git a/compiler/rustc_mir_build/src/lib.rs b/compiler/rustc_mir_build/src/lib.rs index a3d88b1269686..43e44b47e3f96 100644 --- a/compiler/rustc_mir_build/src/lib.rs +++ b/compiler/rustc_mir_build/src/lib.rs @@ -1,6 +1,9 @@ //! Construction of MIR from HIR. //! //! This crate also contains the match exhaustiveness and usefulness checking. + +#![allow(rustc::diagnostic_outside_of_impl)] +#![allow(rustc::untranslatable_diagnostic)] #![feature(assert_matches)] #![feature(associated_type_bounds)] #![feature(box_patterns)] diff --git a/compiler/rustc_mir_dataflow/src/lib.rs b/compiler/rustc_mir_dataflow/src/lib.rs index 23111cc319956..a4b58e5bfc128 100644 --- a/compiler/rustc_mir_dataflow/src/lib.rs +++ b/compiler/rustc_mir_dataflow/src/lib.rs @@ -4,8 +4,6 @@ #![feature(let_chains)] #![feature(min_specialization)] #![feature(try_blocks)] -#![deny(rustc::untranslatable_diagnostic)] -#![deny(rustc::diagnostic_outside_of_impl)] #[macro_use] extern crate tracing; diff --git a/compiler/rustc_mir_transform/src/lib.rs b/compiler/rustc_mir_transform/src/lib.rs index 69f93fa3a0e21..fe828f535e00d 100644 --- a/compiler/rustc_mir_transform/src/lib.rs +++ b/compiler/rustc_mir_transform/src/lib.rs @@ -1,5 +1,3 @@ -#![deny(rustc::untranslatable_diagnostic)] -#![deny(rustc::diagnostic_outside_of_impl)] #![feature(assert_matches)] #![feature(box_patterns)] #![feature(const_type_name)] diff --git a/compiler/rustc_monomorphize/src/lib.rs b/compiler/rustc_monomorphize/src/lib.rs index b0cfa3568cad7..7f36ae91f1a03 100644 --- a/compiler/rustc_monomorphize/src/lib.rs +++ b/compiler/rustc_monomorphize/src/lib.rs @@ -1,8 +1,6 @@ #![feature(array_windows)] #![feature(is_sorted)] #![allow(rustc::potential_query_instability)] -#![deny(rustc::untranslatable_diagnostic)] -#![deny(rustc::diagnostic_outside_of_impl)] #[macro_use] extern crate tracing; diff --git a/compiler/rustc_parse/src/lib.rs b/compiler/rustc_parse/src/lib.rs index d5fa11086872f..5bd8bb72bd665 100644 --- a/compiler/rustc_parse/src/lib.rs +++ b/compiler/rustc_parse/src/lib.rs @@ -1,11 +1,13 @@ //! The main parser interface. +#![allow(internal_features)] +#![allow(rustc::diagnostic_outside_of_impl)] +#![allow(rustc::untranslatable_diagnostic)] #![feature(array_windows)] #![feature(box_patterns)] #![feature(if_let_guard)] #![feature(iter_intersperse)] #![feature(let_chains)] -#![allow(internal_features)] #[macro_use] extern crate tracing; diff --git a/compiler/rustc_parse_format/src/lib.rs b/compiler/rustc_parse_format/src/lib.rs index d76ee161da6fd..0b65f400825ae 100644 --- a/compiler/rustc_parse_format/src/lib.rs +++ b/compiler/rustc_parse_format/src/lib.rs @@ -9,8 +9,6 @@ html_playground_url = "https://play.rust-lang.org/", test(attr(deny(warnings))) )] -#![deny(rustc::untranslatable_diagnostic)] -#![deny(rustc::diagnostic_outside_of_impl)] // We want to be able to build this crate with a stable compiler, // so no `#![feature]` attributes should be added. #![deny(unstable_features)] diff --git a/compiler/rustc_passes/src/lib.rs b/compiler/rustc_passes/src/lib.rs index 862b76b1f6048..064af5aec35aa 100644 --- a/compiler/rustc_passes/src/lib.rs +++ b/compiler/rustc_passes/src/lib.rs @@ -12,8 +12,6 @@ #![feature(map_try_insert)] #![feature(min_specialization)] #![feature(try_blocks)] -#![deny(rustc::untranslatable_diagnostic)] -#![deny(rustc::diagnostic_outside_of_impl)] #[macro_use] extern crate rustc_middle; diff --git a/compiler/rustc_pattern_analysis/src/lib.rs b/compiler/rustc_pattern_analysis/src/lib.rs index 3d0eb117d174f..fe347231e121c 100644 --- a/compiler/rustc_pattern_analysis/src/lib.rs +++ b/compiler/rustc_pattern_analysis/src/lib.rs @@ -1,5 +1,8 @@ //! Analysis of patterns, notably match exhaustiveness checking. +#![allow(rustc::untranslatable_diagnostic)] +#![allow(rustc::diagnostic_outside_of_impl)] + pub mod constructor; #[cfg(feature = "rustc")] pub mod errors; diff --git a/compiler/rustc_privacy/src/lib.rs b/compiler/rustc_privacy/src/lib.rs index a64b06e70d6bc..a284d145a4ddb 100644 --- a/compiler/rustc_privacy/src/lib.rs +++ b/compiler/rustc_privacy/src/lib.rs @@ -5,8 +5,6 @@ #![feature(associated_type_defaults)] #![feature(try_blocks)] #![feature(let_chains)] -#![deny(rustc::untranslatable_diagnostic)] -#![deny(rustc::diagnostic_outside_of_impl)] #[macro_use] extern crate tracing; diff --git a/compiler/rustc_query_impl/src/lib.rs b/compiler/rustc_query_impl/src/lib.rs index 818a67a7debf6..0fe5b9c664a35 100644 --- a/compiler/rustc_query_impl/src/lib.rs +++ b/compiler/rustc_query_impl/src/lib.rs @@ -6,8 +6,6 @@ #![feature(min_specialization)] #![feature(rustc_attrs)] #![allow(rustc::potential_query_instability, unused_parens)] -#![deny(rustc::untranslatable_diagnostic)] -#![deny(rustc::diagnostic_outside_of_impl)] #![allow(internal_features)] #[macro_use] diff --git a/compiler/rustc_query_system/src/lib.rs b/compiler/rustc_query_system/src/lib.rs index 9b66b9a48d905..416f556f57d28 100644 --- a/compiler/rustc_query_system/src/lib.rs +++ b/compiler/rustc_query_system/src/lib.rs @@ -4,8 +4,6 @@ #![feature(min_specialization)] #![feature(let_chains)] #![allow(rustc::potential_query_instability, internal_features)] -#![deny(rustc::untranslatable_diagnostic)] -#![deny(rustc::diagnostic_outside_of_impl)] #[macro_use] extern crate tracing; diff --git a/compiler/rustc_resolve/src/lib.rs b/compiler/rustc_resolve/src/lib.rs index 9d09d060b59b8..5fb9117f0c857 100644 --- a/compiler/rustc_resolve/src/lib.rs +++ b/compiler/rustc_resolve/src/lib.rs @@ -17,7 +17,9 @@ #![feature(let_chains)] #![feature(rustc_attrs)] #![allow(rustdoc::private_intra_doc_links)] +#![allow(rustc::diagnostic_outside_of_impl)] #![allow(rustc::potential_query_instability)] +#![allow(rustc::untranslatable_diagnostic)] #![allow(internal_features)] #[macro_use] diff --git a/compiler/rustc_serialize/src/lib.rs b/compiler/rustc_serialize/src/lib.rs index 9c34aa9395764..95833f532f4d8 100644 --- a/compiler/rustc_serialize/src/lib.rs +++ b/compiler/rustc_serialize/src/lib.rs @@ -17,8 +17,6 @@ #![feature(ptr_sub_ptr)] #![cfg_attr(test, feature(test))] #![allow(rustc::internal)] -#![deny(rustc::untranslatable_diagnostic)] -#![deny(rustc::diagnostic_outside_of_impl)] pub use self::serialize::{Decodable, Decoder, Encodable, Encoder}; diff --git a/compiler/rustc_session/src/lib.rs b/compiler/rustc_session/src/lib.rs index 0d6328fbb071c..58e1394c09071 100644 --- a/compiler/rustc_session/src/lib.rs +++ b/compiler/rustc_session/src/lib.rs @@ -4,8 +4,6 @@ #![feature(rustc_attrs)] #![feature(map_many_mut)] #![feature(iter_intersperse)] -#![deny(rustc::untranslatable_diagnostic)] -#![deny(rustc::diagnostic_outside_of_impl)] #![allow(internal_features)] #[macro_use] diff --git a/compiler/rustc_span/src/lib.rs b/compiler/rustc_span/src/lib.rs index ea6766ea583be..5f2d4ae2b8c2f 100644 --- a/compiler/rustc_span/src/lib.rs +++ b/compiler/rustc_span/src/lib.rs @@ -17,8 +17,6 @@ // tidy-alphabetical-start #![allow(internal_features)] -#![deny(rustc::diagnostic_outside_of_impl)] -#![deny(rustc::untranslatable_diagnostic)] #![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")] #![doc(rust_logo)] #![feature(array_windows)] diff --git a/compiler/rustc_symbol_mangling/src/lib.rs b/compiler/rustc_symbol_mangling/src/lib.rs index 362aaca63642e..02bb1fde75c1b 100644 --- a/compiler/rustc_symbol_mangling/src/lib.rs +++ b/compiler/rustc_symbol_mangling/src/lib.rs @@ -91,8 +91,6 @@ #![doc(rust_logo)] #![feature(rustdoc_internals)] #![allow(internal_features)] -#![deny(rustc::untranslatable_diagnostic)] -#![deny(rustc::diagnostic_outside_of_impl)] #[macro_use] extern crate rustc_middle; diff --git a/compiler/rustc_target/src/lib.rs b/compiler/rustc_target/src/lib.rs index bffb3681f1309..b19c5b6f28f08 100644 --- a/compiler/rustc_target/src/lib.rs +++ b/compiler/rustc_target/src/lib.rs @@ -17,8 +17,6 @@ #![feature(min_specialization)] #![feature(rustc_attrs)] #![feature(step_trait)] -#![deny(rustc::untranslatable_diagnostic)] -#![deny(rustc::diagnostic_outside_of_impl)] #![allow(internal_features)] use std::path::{Path, PathBuf}; diff --git a/compiler/rustc_trait_selection/src/lib.rs b/compiler/rustc_trait_selection/src/lib.rs index 5ec45212bc791..053ecfc681ceb 100644 --- a/compiler/rustc_trait_selection/src/lib.rs +++ b/compiler/rustc_trait_selection/src/lib.rs @@ -14,6 +14,8 @@ #![doc(rust_logo)] #![feature(rustdoc_internals)] #![allow(internal_features)] +#![allow(rustc::diagnostic_outside_of_impl)] +#![allow(rustc::untranslatable_diagnostic)] #![feature(associated_type_bounds)] #![feature(box_patterns)] #![feature(control_flow_enum)] diff --git a/compiler/rustc_traits/src/lib.rs b/compiler/rustc_traits/src/lib.rs index c7916ec60bba2..e73bbf6048ece 100644 --- a/compiler/rustc_traits/src/lib.rs +++ b/compiler/rustc_traits/src/lib.rs @@ -1,7 +1,5 @@ //! Queries that are independent from the main solver code. -#![deny(rustc::untranslatable_diagnostic)] -#![deny(rustc::diagnostic_outside_of_impl)] #![recursion_limit = "256"] #[macro_use] diff --git a/compiler/rustc_transmute/src/lib.rs b/compiler/rustc_transmute/src/lib.rs index c80389a3a4d52..ac4f67d1b5565 100644 --- a/compiler/rustc_transmute/src/lib.rs +++ b/compiler/rustc_transmute/src/lib.rs @@ -1,8 +1,6 @@ #![feature(alloc_layout_extra)] #![feature(never_type)] #![allow(dead_code, unused_variables)] -#![deny(rustc::untranslatable_diagnostic)] -#![deny(rustc::diagnostic_outside_of_impl)] #[macro_use] extern crate tracing; diff --git a/compiler/rustc_ty_utils/src/lib.rs b/compiler/rustc_ty_utils/src/lib.rs index 51acb99d29b58..411099e3d5af8 100644 --- a/compiler/rustc_ty_utils/src/lib.rs +++ b/compiler/rustc_ty_utils/src/lib.rs @@ -15,8 +15,6 @@ #![feature(iterator_try_collect)] #![feature(let_chains)] #![feature(never_type)] -#![deny(rustc::untranslatable_diagnostic)] -#![deny(rustc::diagnostic_outside_of_impl)] #[macro_use] extern crate rustc_middle; diff --git a/compiler/rustc_ty_utils/src/representability.rs b/compiler/rustc_ty_utils/src/representability.rs index 3aaa2e73bb805..70f1f099688b8 100644 --- a/compiler/rustc_ty_utils/src/representability.rs +++ b/compiler/rustc_ty_utils/src/representability.rs @@ -1,5 +1,3 @@ -#![allow(rustc::untranslatable_diagnostic, rustc::diagnostic_outside_of_impl)] - use rustc_hir::def::DefKind; use rustc_index::bit_set::BitSet; use rustc_middle::query::Providers; diff --git a/compiler/rustc_type_ir/src/lib.rs b/compiler/rustc_type_ir/src/lib.rs index 83efbfb855f91..f498c5531fcff 100644 --- a/compiler/rustc_type_ir/src/lib.rs +++ b/compiler/rustc_type_ir/src/lib.rs @@ -2,8 +2,6 @@ feature = "nightly", feature(associated_type_defaults, min_specialization, never_type, rustc_attrs) )] -#![deny(rustc::untranslatable_diagnostic)] -#![deny(rustc::diagnostic_outside_of_impl)] #![allow(rustc::usage_of_ty_tykind)] #![cfg_attr(feature = "nightly", allow(internal_features))] diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs index 8c10f14116a0c..849127616ef62 100644 --- a/src/librustdoc/lib.rs +++ b/src/librustdoc/lib.rs @@ -18,7 +18,9 @@ #![recursion_limit = "256"] #![warn(rustc::internal)] #![allow(clippy::collapsible_if, clippy::collapsible_else_if)] +#![allow(rustc::diagnostic_outside_of_impl)] #![allow(rustc::potential_query_instability)] +#![allow(rustc::untranslatable_diagnostic)] extern crate thin_vec; #[macro_use] diff --git a/src/tools/clippy/clippy_config/src/lib.rs b/src/tools/clippy/clippy_config/src/lib.rs index 533e375a3104c..5449feed090a9 100644 --- a/src/tools/clippy/clippy_config/src/lib.rs +++ b/src/tools/clippy/clippy_config/src/lib.rs @@ -4,7 +4,9 @@ #![allow( clippy::must_use_candidate, clippy::missing_panics_doc, - rustc::untranslatable_diagnostic_trivial + rustc::diagnostic_outside_of_impl, + rustc::untranslatable_diagnostic, + rustc::untranslatable_diagnostic_trivial, )] extern crate rustc_ast; diff --git a/src/tools/clippy/clippy_lints/src/lib.rs b/src/tools/clippy/clippy_lints/src/lib.rs index feb4d188f3978..f6608b229539a 100644 --- a/src/tools/clippy/clippy_lints/src/lib.rs +++ b/src/tools/clippy/clippy_lints/src/lib.rs @@ -10,7 +10,12 @@ #![feature(stmt_expr_attributes)] #![recursion_limit = "512"] #![cfg_attr(feature = "deny-warnings", deny(warnings))] -#![allow(clippy::missing_docs_in_private_items, clippy::must_use_candidate)] +#![allow( + clippy::missing_docs_in_private_items, + clippy::must_use_candidate, + rustc::diagnostic_outside_of_impl, + rustc::untranslatable_diagnostic, +)] #![warn(trivial_casts, trivial_numeric_casts)] // warn on lints, that are included in `rust-lang/rust`s bootstrap #![warn(rust_2018_idioms, unused_lifetimes)] diff --git a/src/tools/clippy/clippy_utils/src/lib.rs b/src/tools/clippy/clippy_utils/src/lib.rs index 4e499ff4cc612..36034861df5b9 100644 --- a/src/tools/clippy/clippy_utils/src/lib.rs +++ b/src/tools/clippy/clippy_utils/src/lib.rs @@ -8,7 +8,13 @@ #![feature(assert_matches)] #![recursion_limit = "512"] #![cfg_attr(feature = "deny-warnings", deny(warnings))] -#![allow(clippy::missing_errors_doc, clippy::missing_panics_doc, clippy::must_use_candidate)] +#![allow( + clippy::missing_errors_doc, + clippy::missing_panics_doc, + clippy::must_use_candidate, + rustc::diagnostic_outside_of_impl, + rustc::untranslatable_diagnostic, +)] // warn on the same lints as `clippy_lints` #![warn(trivial_casts, trivial_numeric_casts)] // warn on lints, that are included in `rust-lang/rust`s bootstrap diff --git a/src/tools/clippy/src/driver.rs b/src/tools/clippy/src/driver.rs index b944a299256c2..1b159f5937a28 100644 --- a/src/tools/clippy/src/driver.rs +++ b/src/tools/clippy/src/driver.rs @@ -1,3 +1,5 @@ +#![allow(rustc::diagnostic_outside_of_impl)] +#![allow(rustc::untranslatable_diagnostic)] #![feature(rustc_private)] #![feature(let_chains)] #![feature(lazy_cell)] diff --git a/src/tools/miri/src/bin/miri.rs b/src/tools/miri/src/bin/miri.rs index e8e10f64ad295..de7a4b79d26ff 100644 --- a/src/tools/miri/src/bin/miri.rs +++ b/src/tools/miri/src/bin/miri.rs @@ -2,7 +2,9 @@ #![allow( clippy::manual_range_contains, clippy::useless_format, - clippy::field_reassign_with_default + clippy::field_reassign_with_default, + rustc::diagnostic_outside_of_impl, + rustc::untranslatable_diagnostic, )] extern crate rustc_data_structures; diff --git a/src/tools/miri/src/lib.rs b/src/tools/miri/src/lib.rs index 057b883a3bf9e..94fb746484c6e 100644 --- a/src/tools/miri/src/lib.rs +++ b/src/tools/miri/src/lib.rs @@ -33,8 +33,10 @@ clippy::bool_to_int_with_if, clippy::box_default, clippy::needless_question_mark, + rustc::diagnostic_outside_of_impl, // We are not implementing queries here so it's fine - rustc::potential_query_instability + rustc::potential_query_instability, + rustc::untranslatable_diagnostic, )] #![warn( rust_2018_idioms, From ad3d04c55ec4cbd924b3f7e3a890483b6eb1604d Mon Sep 17 00:00:00 2001 From: Amanda Stjerna Date: Tue, 6 Feb 2024 13:07:51 +0100 Subject: [PATCH 03/16] A drive-by rewrite of give_region_a_name() This rewrite makes the cache-updating nature of the function slightly clearer, using the Entry API into the hash table for region names to capture the update-insert nature of the method. May be marginally more efficient since it only runtime-borrows the map once, but in this context the performance impact is almost certainly completely negligible. --- .../src/diagnostics/region_name.rs | 38 ++++++++++--------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/compiler/rustc_borrowck/src/diagnostics/region_name.rs b/compiler/rustc_borrowck/src/diagnostics/region_name.rs index 15e1066e983a9..c9de36e9064e2 100644 --- a/compiler/rustc_borrowck/src/diagnostics/region_name.rs +++ b/compiler/rustc_borrowck/src/diagnostics/region_name.rs @@ -1,6 +1,7 @@ use std::fmt::{self, Display}; use std::iter; +use rustc_data_structures::fx::IndexEntry; use rustc_errors::Diagnostic; use rustc_hir as hir; use rustc_hir::def::{DefKind, Res}; @@ -247,25 +248,28 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> { assert!(self.regioncx.universal_regions().is_universal_region(fr)); - if let Some(value) = self.region_names.try_borrow_mut().unwrap().get(&fr) { - return Some(value.clone()); - } + match self.region_names.borrow_mut().entry(fr) { + IndexEntry::Occupied(precomputed_name) => Some(precomputed_name.get().clone()), + IndexEntry::Vacant(slot) => { + let new_name = self + .give_name_from_error_region(fr) + .or_else(|| self.give_name_if_anonymous_region_appears_in_arguments(fr)) + .or_else(|| self.give_name_if_anonymous_region_appears_in_upvars(fr)) + .or_else(|| self.give_name_if_anonymous_region_appears_in_output(fr)) + .or_else(|| self.give_name_if_anonymous_region_appears_in_yield_ty(fr)) + .or_else(|| self.give_name_if_anonymous_region_appears_in_impl_signature(fr)) + .or_else(|| { + self.give_name_if_anonymous_region_appears_in_arg_position_impl_trait(fr) + }); + + if let Some(new_name) = &new_name { + slot.insert(new_name.clone()); + } + debug!("give_region_a_name: gave name {:?}", new_name); - let value = self - .give_name_from_error_region(fr) - .or_else(|| self.give_name_if_anonymous_region_appears_in_arguments(fr)) - .or_else(|| self.give_name_if_anonymous_region_appears_in_upvars(fr)) - .or_else(|| self.give_name_if_anonymous_region_appears_in_output(fr)) - .or_else(|| self.give_name_if_anonymous_region_appears_in_yield_ty(fr)) - .or_else(|| self.give_name_if_anonymous_region_appears_in_impl_signature(fr)) - .or_else(|| self.give_name_if_anonymous_region_appears_in_arg_position_impl_trait(fr)); - - if let Some(value) = &value { - self.region_names.try_borrow_mut().unwrap().insert(fr, value.clone()); + new_name + } } - - debug!("give_region_a_name: gave name {:?}", value); - value } /// Checks for the case where `fr` maps to something that the From 0f323b24b22cdda444749238649518bad68c0c15 Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Wed, 7 Feb 2024 14:00:21 +0000 Subject: [PATCH 04/16] Associated types in traits don't necessarily have a type that we can visit This prevents ICEs from happening in the future when this code path is actually used --- compiler/rustc_ty_utils/src/sig_types.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/compiler/rustc_ty_utils/src/sig_types.rs b/compiler/rustc_ty_utils/src/sig_types.rs index b155a4ac87b9f..b0389052cccb8 100644 --- a/compiler/rustc_ty_utils/src/sig_types.rs +++ b/compiler/rustc_ty_utils/src/sig_types.rs @@ -42,11 +42,10 @@ pub(crate) fn walk_types<'tcx, V: SpannedTypeVisitor<'tcx>>( DefKind::TyAlias {..} | DefKind::AssocTy | // Walk over the type of the item DefKind::Static(_) | DefKind::Const | DefKind::AssocConst | DefKind::AnonConst => { - let span = match tcx.hir_node_by_def_id(item).ty() { - Some(ty) => ty.span, - _ => tcx.def_span(item), - }; - visitor.visit(span, tcx.type_of(item).instantiate_identity()); + if let Some(ty) = tcx.hir_node_by_def_id(item).ty() { + // Associated types in traits don't necessarily have a type that we can visit + visitor.visit(ty.span, tcx.type_of(item).instantiate_identity())?; + } for (pred, span) in tcx.predicates_of(item).instantiate_identity(tcx) { visitor.visit(span, pred)?; } From 0b97d18f71a0756d5390e717269170ed2ba2755b Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Wed, 7 Feb 2024 14:00:49 +0000 Subject: [PATCH 05/16] extern types don't have any types to visit --- compiler/rustc_ty_utils/src/sig_types.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/rustc_ty_utils/src/sig_types.rs b/compiler/rustc_ty_utils/src/sig_types.rs index b0389052cccb8..7435c78beb7cc 100644 --- a/compiler/rustc_ty_utils/src/sig_types.rs +++ b/compiler/rustc_ty_utils/src/sig_types.rs @@ -88,7 +88,6 @@ pub(crate) fn walk_types<'tcx, V: SpannedTypeVisitor<'tcx>>( } } | DefKind::Variant - | DefKind::ForeignTy | DefKind::TyParam | DefKind::ConstParam | DefKind::Ctor(_, _) @@ -102,6 +101,7 @@ pub(crate) fn walk_types<'tcx, V: SpannedTypeVisitor<'tcx>>( // These don't have any types. | DefKind::ExternCrate | DefKind::ForeignMod + | DefKind::ForeignTy | DefKind::Macro(_) | DefKind::GlobalAsm | DefKind::Mod From b998b515e9b6a8568d18a7155f75a408860a19a3 Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Wed, 7 Feb 2024 14:05:34 +0000 Subject: [PATCH 06/16] Actually walk fields of Adt definitions --- compiler/rustc_ty_utils/src/sig_types.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_ty_utils/src/sig_types.rs b/compiler/rustc_ty_utils/src/sig_types.rs index 7435c78beb7cc..c32aaa89f495e 100644 --- a/compiler/rustc_ty_utils/src/sig_types.rs +++ b/compiler/rustc_ty_utils/src/sig_types.rs @@ -4,7 +4,7 @@ use std::ops::ControlFlow; use rustc_hir::{def::DefKind, def_id::LocalDefId}; -use rustc_middle::ty::TyCtxt; +use rustc_middle::ty::{self, TyCtxt}; use rustc_span::Span; use rustc_type_ir::visit::TypeVisitable; @@ -58,7 +58,16 @@ pub(crate) fn walk_types<'tcx, V: SpannedTypeVisitor<'tcx>>( // Look at field types DefKind::Struct | DefKind::Union | DefKind::Enum => { let span = tcx.def_ident_span(item).unwrap(); - visitor.visit(span, tcx.type_of(item).instantiate_identity()); + let ty = tcx.type_of(item).instantiate_identity(); + visitor.visit(span, ty); + let ty::Adt(def, args) = ty.kind() else { + span_bug!(span, "invalid type for {kind:?}: {:#?}", ty.kind()) + }; + for field in def.all_fields() { + let span = tcx.def_ident_span(field.did).unwrap(); + let ty = field.ty(tcx, args); + visitor.visit(span, ty); + } for (pred, span) in tcx.predicates_of(item).instantiate_identity(tcx) { visitor.visit(span, pred)?; } From 4389a1cc42a1822d9b2398095dac6d9d92753667 Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Tue, 18 Jul 2023 07:22:46 +0000 Subject: [PATCH 07/16] Stop using `hir_ty_to_ty` in rustc_privacy --- Cargo.lock | 1 + compiler/rustc_privacy/Cargo.toml | 1 + compiler/rustc_privacy/src/lib.rs | 103 ++++++----- compiler/rustc_ty_utils/src/lib.rs | 2 +- compiler/rustc_ty_utils/src/sig_types.rs | 4 +- tests/ui/dyn-keyword/dyn-2018-edition-lint.rs | 8 - .../dyn-keyword/dyn-2018-edition-lint.stderr | 60 +------ ...esh-lifetime-from-bare-trait-obj-114664.rs | 4 - ...lifetime-from-bare-trait-obj-114664.stderr | 30 +--- .../allowed-group-warn-by-default-lint.rs | 4 - .../allowed-group-warn-by-default-lint.stderr | 30 +--- tests/ui/lint/force-warn/cap-lints-allow.rs | 4 - .../ui/lint/force-warn/cap-lints-allow.stderr | 30 +--- ...-group-allowed-cli-warn-by-default-lint.rs | 4 - ...up-allowed-cli-warn-by-default-lint.stderr | 30 +--- .../lint-group-allowed-lint-group.rs | 4 - .../lint-group-allowed-lint-group.stderr | 30 +--- ...lint-group-allowed-warn-by-default-lint.rs | 4 - ...-group-allowed-warn-by-default-lint.stderr | 30 +--- tests/ui/lint/lint-stability-deprecated.rs | 3 - .../ui/lint/lint-stability-deprecated.stderr | 170 ++++++++---------- .../assoc_type_bounds_sized_unnecessary.rs | 2 - ...assoc_type_bounds_sized_unnecessary.stderr | 20 +-- .../associated-item-privacy-trait.stderr | 22 +-- ...ssociated-item-privacy-type-binding.stderr | 8 +- .../privacy/private-type-in-interface.stderr | 8 +- tests/ui/privacy/struct-field-type.rs | 10 ++ tests/ui/privacy/struct-field-type.stderr | 21 +++ tests/ui/suggestions/issue-61963.rs | 10 -- tests/ui/suggestions/issue-61963.stderr | 74 +------- ...riority-lint-ambiguous_associated_items.rs | 3 - ...ity-lint-ambiguous_associated_items.stderr | 22 +-- 32 files changed, 191 insertions(+), 565 deletions(-) create mode 100644 tests/ui/privacy/struct-field-type.rs create mode 100644 tests/ui/privacy/struct-field-type.stderr diff --git a/Cargo.lock b/Cargo.lock index 29c8c7ef00404..300cc02330f97 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4374,6 +4374,7 @@ dependencies = [ "rustc_middle", "rustc_session", "rustc_span", + "rustc_ty_utils", "tracing", ] diff --git a/compiler/rustc_privacy/Cargo.toml b/compiler/rustc_privacy/Cargo.toml index 90803c20d4312..e7a32771f350d 100644 --- a/compiler/rustc_privacy/Cargo.toml +++ b/compiler/rustc_privacy/Cargo.toml @@ -16,5 +16,6 @@ rustc_macros = { path = "../rustc_macros" } rustc_middle = { path = "../rustc_middle" } rustc_session = { path = "../rustc_session" } rustc_span = { path = "../rustc_span" } +rustc_ty_utils = { path = "../rustc_ty_utils" } tracing = "0.1" # tidy-alphabetical-end diff --git a/compiler/rustc_privacy/src/lib.rs b/compiler/rustc_privacy/src/lib.rs index a37d8822480af..eaec09cfbc234 100644 --- a/compiler/rustc_privacy/src/lib.rs +++ b/compiler/rustc_privacy/src/lib.rs @@ -21,7 +21,7 @@ use rustc_hir as hir; use rustc_hir::def::{DefKind, Res}; use rustc_hir::def_id::{DefId, LocalDefId, LocalModDefId, CRATE_DEF_ID}; use rustc_hir::intravisit::{self, Visitor}; -use rustc_hir::{AssocItemKind, ForeignItemKind, ItemId, PatKind}; +use rustc_hir::{AssocItemKind, ForeignItemKind, ItemId, ItemKind, PatKind}; use rustc_middle::middle::privacy::{EffectiveVisibilities, EffectiveVisibility, Level}; use rustc_middle::query::Providers; use rustc_middle::ty::GenericArgs; @@ -173,6 +173,10 @@ where { type BreakTy = V::BreakTy; + fn visit_predicate(&mut self, p: ty::Predicate<'tcx>) -> ControlFlow { + self.visit_clause(p.as_clause().unwrap()) + } + fn visit_ty(&mut self, ty: Ty<'tcx>) -> ControlFlow { let tcx = self.def_id_visitor.tcx(); // GenericArgs are not visited here because they are visited below @@ -1076,6 +1080,14 @@ impl<'tcx> TypePrivacyVisitor<'tcx> { } } +impl<'tcx> rustc_ty_utils::sig_types::SpannedTypeVisitor<'tcx> for TypePrivacyVisitor<'tcx> { + type BreakTy = (); + fn visit(&mut self, span: Span, value: impl TypeVisitable>) -> ControlFlow<()> { + self.span = span; + value.visit_with(&mut self.skeleton()) + } +} + impl<'tcx> Visitor<'tcx> for TypePrivacyVisitor<'tcx> { fn visit_nested_body(&mut self, body_id: hir::BodyId) { let old_maybe_typeck_results = @@ -1086,18 +1098,15 @@ impl<'tcx> Visitor<'tcx> for TypePrivacyVisitor<'tcx> { fn visit_ty(&mut self, hir_ty: &'tcx hir::Ty<'tcx>) { self.span = hir_ty.span; - if let Some(typeck_results) = self.maybe_typeck_results { - // Types in bodies. - if self.visit(typeck_results.node_type(hir_ty.hir_id)).is_break() { - return; - } - } else { - // Types in signatures. - // FIXME: This is very ineffective. Ideally each HIR type should be converted - // into a semantic type only once and the result should be cached somehow. - if self.visit(rustc_hir_analysis::hir_ty_to_ty(self.tcx, hir_ty)).is_break() { - return; - } + if self + .visit( + self.maybe_typeck_results + .unwrap_or_else(|| span_bug!(hir_ty.span, "`hir::Ty` outside of a body")) + .node_type(hir_ty.hir_id), + ) + .is_break() + { + return; } intravisit::walk_ty(self, hir_ty); @@ -1105,52 +1114,23 @@ impl<'tcx> Visitor<'tcx> for TypePrivacyVisitor<'tcx> { fn visit_infer(&mut self, inf: &'tcx hir::InferArg) { self.span = inf.span; - if let Some(typeck_results) = self.maybe_typeck_results { - if let Some(ty) = typeck_results.node_type_opt(inf.hir_id) { - if self.visit(ty).is_break() { - return; - } - } else { - // FIXME: check types of const infers here. + if let Some(ty) = self + .maybe_typeck_results + .unwrap_or_else(|| span_bug!(inf.span, "`hir::InferArg` outside of a body")) + .node_type_opt(inf.hir_id) + { + if self.visit(ty).is_break() { + return; } } else { - span_bug!(self.span, "`hir::InferArg` outside of a body"); + // FIXME: check types of const infers here. } intravisit::walk_inf(self, inf); } fn visit_trait_ref(&mut self, trait_ref: &'tcx hir::TraitRef<'tcx>) { self.span = trait_ref.path.span; - if self.maybe_typeck_results.is_some() { - // Privacy of traits in bodies is checked as a part of trait object types. - } else { - let bounds = rustc_hir_analysis::hir_trait_to_predicates( - self.tcx, - trait_ref, - // NOTE: This isn't really right, but the actual type doesn't matter here. It's - // just required by `ty::TraitRef`. - self.tcx.types.never, - ); - - for (clause, _) in bounds.clauses() { - match clause.kind().skip_binder() { - ty::ClauseKind::Trait(trait_predicate) => { - if self.visit_trait(trait_predicate.trait_ref).is_break() { - return; - } - } - ty::ClauseKind::Projection(proj_predicate) => { - let term = self.visit(proj_predicate.term); - if term.is_break() - || self.visit_projection_ty(proj_predicate.projection_ty).is_break() - { - return; - } - } - _ => {} - } - } - } + // Privacy of traits in bodies is checked as a part of trait object types. intravisit::walk_trait_ref(self, trait_ref); } @@ -1727,7 +1707,26 @@ fn check_mod_privacy(tcx: TyCtxt<'_>, module_def_id: LocalModDefId) { // inferred types of expressions and patterns. let span = tcx.def_span(module_def_id); let mut visitor = TypePrivacyVisitor { tcx, module_def_id, maybe_typeck_results: None, span }; - tcx.hir().visit_item_likes_in_module(module_def_id, &mut visitor); + + let module = tcx.hir_module_items(module_def_id); + for def_id in module.definitions() { + rustc_ty_utils::sig_types::walk_types(tcx, def_id, &mut visitor); + + if let Some(body_id) = tcx.hir().maybe_body_owned_by(def_id) { + visitor.visit_nested_body(body_id); + } + } + + for id in module.items() { + if let ItemKind::Impl(i) = tcx.hir().item(id).kind { + if let Some(item) = i.of_trait { + let trait_ref = tcx.impl_trait_ref(id.owner_id.def_id).unwrap(); + let trait_ref = trait_ref.instantiate_identity(); + visitor.span = item.path.span; + visitor.visit_def_id(trait_ref.def_id, "trait", &trait_ref.print_only_trait_path()); + } + } + } } fn effective_visibilities(tcx: TyCtxt<'_>, (): ()) -> &EffectiveVisibilities { diff --git a/compiler/rustc_ty_utils/src/lib.rs b/compiler/rustc_ty_utils/src/lib.rs index 51acb99d29b58..4eb2b9cfe54e8 100644 --- a/compiler/rustc_ty_utils/src/lib.rs +++ b/compiler/rustc_ty_utils/src/lib.rs @@ -37,7 +37,7 @@ mod layout_sanity_check; mod needs_drop; mod opaque_types; mod representability; -mod sig_types; +pub mod sig_types; mod structural_match; mod ty; diff --git a/compiler/rustc_ty_utils/src/sig_types.rs b/compiler/rustc_ty_utils/src/sig_types.rs index c32aaa89f495e..38cc558380cd8 100644 --- a/compiler/rustc_ty_utils/src/sig_types.rs +++ b/compiler/rustc_ty_utils/src/sig_types.rs @@ -8,7 +8,7 @@ use rustc_middle::ty::{self, TyCtxt}; use rustc_span::Span; use rustc_type_ir::visit::TypeVisitable; -pub(crate) trait SpannedTypeVisitor<'tcx> { +pub trait SpannedTypeVisitor<'tcx> { type BreakTy = !; fn visit( &mut self, @@ -17,7 +17,7 @@ pub(crate) trait SpannedTypeVisitor<'tcx> { ) -> ControlFlow; } -pub(crate) fn walk_types<'tcx, V: SpannedTypeVisitor<'tcx>>( +pub fn walk_types<'tcx, V: SpannedTypeVisitor<'tcx>>( tcx: TyCtxt<'tcx>, item: LocalDefId, visitor: &mut V, diff --git a/tests/ui/dyn-keyword/dyn-2018-edition-lint.rs b/tests/ui/dyn-keyword/dyn-2018-edition-lint.rs index a074b5fa5f7aa..23ca36b71e00f 100644 --- a/tests/ui/dyn-keyword/dyn-2018-edition-lint.rs +++ b/tests/ui/dyn-keyword/dyn-2018-edition-lint.rs @@ -6,14 +6,6 @@ fn function(x: &SomeTrait, y: Box) { //~| WARN this is accepted in the current edition //~| ERROR trait objects without an explicit `dyn` are deprecated //~| WARN this is accepted in the current edition - //~| ERROR trait objects without an explicit `dyn` are deprecated - //~| WARN this is accepted in the current edition - //~| ERROR trait objects without an explicit `dyn` are deprecated - //~| WARN this is accepted in the current edition - //~| ERROR trait objects without an explicit `dyn` are deprecated - //~| WARN this is accepted in the current edition - //~| ERROR trait objects without an explicit `dyn` are deprecated - //~| WARN this is accepted in the current edition let _x: &SomeTrait = todo!(); //~^ ERROR trait objects without an explicit `dyn` are deprecated //~| WARN this is accepted in the current edition diff --git a/tests/ui/dyn-keyword/dyn-2018-edition-lint.stderr b/tests/ui/dyn-keyword/dyn-2018-edition-lint.stderr index 931786672145b..65d44604dc9fc 100644 --- a/tests/ui/dyn-keyword/dyn-2018-edition-lint.stderr +++ b/tests/ui/dyn-keyword/dyn-2018-edition-lint.stderr @@ -30,7 +30,7 @@ LL | fn function(x: &SomeTrait, y: Box) { | +++ error: trait objects without an explicit `dyn` are deprecated - --> $DIR/dyn-2018-edition-lint.rs:17:14 + --> $DIR/dyn-2018-edition-lint.rs:9:14 | LL | let _x: &SomeTrait = todo!(); | ^^^^^^^^^ @@ -42,61 +42,5 @@ help: use `dyn` LL | let _x: &dyn SomeTrait = todo!(); | +++ -error: trait objects without an explicit `dyn` are deprecated - --> $DIR/dyn-2018-edition-lint.rs:4:17 - | -LL | fn function(x: &SomeTrait, y: Box) { - | ^^^^^^^^^ - | - = warning: this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2021! - = note: for more information, see - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -help: use `dyn` - | -LL | fn function(x: &dyn SomeTrait, y: Box) { - | +++ - -error: trait objects without an explicit `dyn` are deprecated - --> $DIR/dyn-2018-edition-lint.rs:4:17 - | -LL | fn function(x: &SomeTrait, y: Box) { - | ^^^^^^^^^ - | - = warning: this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2021! - = note: for more information, see - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -help: use `dyn` - | -LL | fn function(x: &dyn SomeTrait, y: Box) { - | +++ - -error: trait objects without an explicit `dyn` are deprecated - --> $DIR/dyn-2018-edition-lint.rs:4:35 - | -LL | fn function(x: &SomeTrait, y: Box) { - | ^^^^^^^^^ - | - = warning: this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2021! - = note: for more information, see - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -help: use `dyn` - | -LL | fn function(x: &SomeTrait, y: Box) { - | +++ - -error: trait objects without an explicit `dyn` are deprecated - --> $DIR/dyn-2018-edition-lint.rs:4:35 - | -LL | fn function(x: &SomeTrait, y: Box) { - | ^^^^^^^^^ - | - = warning: this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2021! - = note: for more information, see - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -help: use `dyn` - | -LL | fn function(x: &SomeTrait, y: Box) { - | +++ - -error: aborting due to 7 previous errors +error: aborting due to 3 previous errors diff --git a/tests/ui/impl-trait/fresh-lifetime-from-bare-trait-obj-114664.rs b/tests/ui/impl-trait/fresh-lifetime-from-bare-trait-obj-114664.rs index 57d688492515b..e1aba8eda1bff 100644 --- a/tests/ui/impl-trait/fresh-lifetime-from-bare-trait-obj-114664.rs +++ b/tests/ui/impl-trait/fresh-lifetime-from-bare-trait-obj-114664.rs @@ -4,10 +4,6 @@ fn ice() -> impl AsRef { //~^ WARN trait objects without an explicit `dyn` are deprecated - //~| WARN trait objects without an explicit `dyn` are deprecated - //~| WARN trait objects without an explicit `dyn` are deprecated - //~| WARN this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! - //~| WARN this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! //~| WARN this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! Foo } diff --git a/tests/ui/impl-trait/fresh-lifetime-from-bare-trait-obj-114664.stderr b/tests/ui/impl-trait/fresh-lifetime-from-bare-trait-obj-114664.stderr index d3c2d5d5b9f8c..84aaedf183815 100644 --- a/tests/ui/impl-trait/fresh-lifetime-from-bare-trait-obj-114664.stderr +++ b/tests/ui/impl-trait/fresh-lifetime-from-bare-trait-obj-114664.stderr @@ -12,33 +12,5 @@ help: use `dyn` LL | fn ice() -> impl AsRef { | +++ -warning: trait objects without an explicit `dyn` are deprecated - --> $DIR/fresh-lifetime-from-bare-trait-obj-114664.rs:5:24 - | -LL | fn ice() -> impl AsRef { - | ^^^^^^^ - | - = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! - = note: for more information, see - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -help: use `dyn` - | -LL | fn ice() -> impl AsRef { - | +++ - -warning: trait objects without an explicit `dyn` are deprecated - --> $DIR/fresh-lifetime-from-bare-trait-obj-114664.rs:5:24 - | -LL | fn ice() -> impl AsRef { - | ^^^^^^^ - | - = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! - = note: for more information, see - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -help: use `dyn` - | -LL | fn ice() -> impl AsRef { - | +++ - -warning: 3 warnings emitted +warning: 1 warning emitted diff --git a/tests/ui/lint/force-warn/allowed-group-warn-by-default-lint.rs b/tests/ui/lint/force-warn/allowed-group-warn-by-default-lint.rs index 631a8cb2f08cc..9b1edba41aafe 100644 --- a/tests/ui/lint/force-warn/allowed-group-warn-by-default-lint.rs +++ b/tests/ui/lint/force-warn/allowed-group-warn-by-default-lint.rs @@ -10,9 +10,5 @@ pub trait SomeTrait {} pub fn function(_x: Box) {} //~^ WARN trait objects without an explicit `dyn` are deprecated //~| WARN this is accepted in the current edition -//~| WARN trait objects without an explicit `dyn` are deprecated -//~| WARN this is accepted in the current edition -//~| WARN trait objects without an explicit `dyn` are deprecated -//~| WARN this is accepted in the current edition fn main() {} diff --git a/tests/ui/lint/force-warn/allowed-group-warn-by-default-lint.stderr b/tests/ui/lint/force-warn/allowed-group-warn-by-default-lint.stderr index ecdc625015e4e..e9b7b248e612f 100644 --- a/tests/ui/lint/force-warn/allowed-group-warn-by-default-lint.stderr +++ b/tests/ui/lint/force-warn/allowed-group-warn-by-default-lint.stderr @@ -12,33 +12,5 @@ help: use `dyn` LL | pub fn function(_x: Box) {} | +++ -warning: trait objects without an explicit `dyn` are deprecated - --> $DIR/allowed-group-warn-by-default-lint.rs:10:25 - | -LL | pub fn function(_x: Box) {} - | ^^^^^^^^^ - | - = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! - = note: for more information, see - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -help: use `dyn` - | -LL | pub fn function(_x: Box) {} - | +++ - -warning: trait objects without an explicit `dyn` are deprecated - --> $DIR/allowed-group-warn-by-default-lint.rs:10:25 - | -LL | pub fn function(_x: Box) {} - | ^^^^^^^^^ - | - = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! - = note: for more information, see - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -help: use `dyn` - | -LL | pub fn function(_x: Box) {} - | +++ - -warning: 3 warnings emitted +warning: 1 warning emitted diff --git a/tests/ui/lint/force-warn/cap-lints-allow.rs b/tests/ui/lint/force-warn/cap-lints-allow.rs index fdba7f4105e73..9609ea994312f 100644 --- a/tests/ui/lint/force-warn/cap-lints-allow.rs +++ b/tests/ui/lint/force-warn/cap-lints-allow.rs @@ -8,9 +8,5 @@ pub trait SomeTrait {} pub fn function(_x: Box) {} //~^ WARN trait objects without an explicit `dyn` are deprecated //~| WARN this is accepted in the current edition -//~| WARN trait objects without an explicit `dyn` are deprecated -//~| WARN this is accepted in the current edition -//~| WARN trait objects without an explicit `dyn` are deprecated -//~| WARN this is accepted in the current edition fn main() {} diff --git a/tests/ui/lint/force-warn/cap-lints-allow.stderr b/tests/ui/lint/force-warn/cap-lints-allow.stderr index 5f5f2ff52b6d0..e569b2f9f1ae9 100644 --- a/tests/ui/lint/force-warn/cap-lints-allow.stderr +++ b/tests/ui/lint/force-warn/cap-lints-allow.stderr @@ -12,33 +12,5 @@ help: use `dyn` LL | pub fn function(_x: Box) {} | +++ -warning: trait objects without an explicit `dyn` are deprecated - --> $DIR/cap-lints-allow.rs:8:25 - | -LL | pub fn function(_x: Box) {} - | ^^^^^^^^^ - | - = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! - = note: for more information, see - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -help: use `dyn` - | -LL | pub fn function(_x: Box) {} - | +++ - -warning: trait objects without an explicit `dyn` are deprecated - --> $DIR/cap-lints-allow.rs:8:25 - | -LL | pub fn function(_x: Box) {} - | ^^^^^^^^^ - | - = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! - = note: for more information, see - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -help: use `dyn` - | -LL | pub fn function(_x: Box) {} - | +++ - -warning: 3 warnings emitted +warning: 1 warning emitted diff --git a/tests/ui/lint/force-warn/lint-group-allowed-cli-warn-by-default-lint.rs b/tests/ui/lint/force-warn/lint-group-allowed-cli-warn-by-default-lint.rs index 7ad7462ddc550..9736027452a8d 100644 --- a/tests/ui/lint/force-warn/lint-group-allowed-cli-warn-by-default-lint.rs +++ b/tests/ui/lint/force-warn/lint-group-allowed-cli-warn-by-default-lint.rs @@ -8,9 +8,5 @@ pub trait SomeTrait {} pub fn function(_x: Box) {} //~^ WARN trait objects without an explicit `dyn` are deprecated //~| WARN this is accepted in the current edition -//~| WARN trait objects without an explicit `dyn` are deprecated -//~| WARN this is accepted in the current edition -//~| WARN trait objects without an explicit `dyn` are deprecated -//~| WARN this is accepted in the current edition fn main() {} diff --git a/tests/ui/lint/force-warn/lint-group-allowed-cli-warn-by-default-lint.stderr b/tests/ui/lint/force-warn/lint-group-allowed-cli-warn-by-default-lint.stderr index 3a0b1201b0cd8..c971e4d0d4d21 100644 --- a/tests/ui/lint/force-warn/lint-group-allowed-cli-warn-by-default-lint.stderr +++ b/tests/ui/lint/force-warn/lint-group-allowed-cli-warn-by-default-lint.stderr @@ -13,33 +13,5 @@ help: use `dyn` LL | pub fn function(_x: Box) {} | +++ -warning: trait objects without an explicit `dyn` are deprecated - --> $DIR/lint-group-allowed-cli-warn-by-default-lint.rs:8:25 - | -LL | pub fn function(_x: Box) {} - | ^^^^^^^^^ - | - = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! - = note: for more information, see - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -help: use `dyn` - | -LL | pub fn function(_x: Box) {} - | +++ - -warning: trait objects without an explicit `dyn` are deprecated - --> $DIR/lint-group-allowed-cli-warn-by-default-lint.rs:8:25 - | -LL | pub fn function(_x: Box) {} - | ^^^^^^^^^ - | - = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! - = note: for more information, see - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -help: use `dyn` - | -LL | pub fn function(_x: Box) {} - | +++ - -warning: 3 warnings emitted +warning: 1 warning emitted diff --git a/tests/ui/lint/force-warn/lint-group-allowed-lint-group.rs b/tests/ui/lint/force-warn/lint-group-allowed-lint-group.rs index ee5a18c38292b..99cad614c25cd 100644 --- a/tests/ui/lint/force-warn/lint-group-allowed-lint-group.rs +++ b/tests/ui/lint/force-warn/lint-group-allowed-lint-group.rs @@ -10,9 +10,5 @@ pub trait SomeTrait {} pub fn function(_x: Box) {} //~^ WARN trait objects without an explicit `dyn` are deprecated //~| WARN this is accepted in the current edition -//~| WARN trait objects without an explicit `dyn` are deprecated -//~| WARN this is accepted in the current edition -//~| WARN trait objects without an explicit `dyn` are deprecated -//~| WARN this is accepted in the current edition fn main() {} diff --git a/tests/ui/lint/force-warn/lint-group-allowed-lint-group.stderr b/tests/ui/lint/force-warn/lint-group-allowed-lint-group.stderr index 92555eda2a737..97b8694984dd7 100644 --- a/tests/ui/lint/force-warn/lint-group-allowed-lint-group.stderr +++ b/tests/ui/lint/force-warn/lint-group-allowed-lint-group.stderr @@ -13,33 +13,5 @@ help: use `dyn` LL | pub fn function(_x: Box) {} | +++ -warning: trait objects without an explicit `dyn` are deprecated - --> $DIR/lint-group-allowed-lint-group.rs:10:25 - | -LL | pub fn function(_x: Box) {} - | ^^^^^^^^^ - | - = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! - = note: for more information, see - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -help: use `dyn` - | -LL | pub fn function(_x: Box) {} - | +++ - -warning: trait objects without an explicit `dyn` are deprecated - --> $DIR/lint-group-allowed-lint-group.rs:10:25 - | -LL | pub fn function(_x: Box) {} - | ^^^^^^^^^ - | - = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! - = note: for more information, see - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -help: use `dyn` - | -LL | pub fn function(_x: Box) {} - | +++ - -warning: 3 warnings emitted +warning: 1 warning emitted diff --git a/tests/ui/lint/force-warn/lint-group-allowed-warn-by-default-lint.rs b/tests/ui/lint/force-warn/lint-group-allowed-warn-by-default-lint.rs index 248aece6fe77c..f0aacd773401f 100644 --- a/tests/ui/lint/force-warn/lint-group-allowed-warn-by-default-lint.rs +++ b/tests/ui/lint/force-warn/lint-group-allowed-warn-by-default-lint.rs @@ -10,9 +10,5 @@ pub trait SomeTrait {} pub fn function(_x: Box) {} //~^ WARN trait objects without an explicit `dyn` are deprecated //~| WARN this is accepted in the current edition -//~| WARN trait objects without an explicit `dyn` are deprecated -//~| WARN this is accepted in the current edition -//~| WARN trait objects without an explicit `dyn` are deprecated -//~| WARN this is accepted in the current edition fn main() {} diff --git a/tests/ui/lint/force-warn/lint-group-allowed-warn-by-default-lint.stderr b/tests/ui/lint/force-warn/lint-group-allowed-warn-by-default-lint.stderr index c14c7957a25f5..cd030cc1fcd18 100644 --- a/tests/ui/lint/force-warn/lint-group-allowed-warn-by-default-lint.stderr +++ b/tests/ui/lint/force-warn/lint-group-allowed-warn-by-default-lint.stderr @@ -13,33 +13,5 @@ help: use `dyn` LL | pub fn function(_x: Box) {} | +++ -warning: trait objects without an explicit `dyn` are deprecated - --> $DIR/lint-group-allowed-warn-by-default-lint.rs:10:25 - | -LL | pub fn function(_x: Box) {} - | ^^^^^^^^^ - | - = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! - = note: for more information, see - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -help: use `dyn` - | -LL | pub fn function(_x: Box) {} - | +++ - -warning: trait objects without an explicit `dyn` are deprecated - --> $DIR/lint-group-allowed-warn-by-default-lint.rs:10:25 - | -LL | pub fn function(_x: Box) {} - | ^^^^^^^^^ - | - = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! - = note: for more information, see - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -help: use `dyn` - | -LL | pub fn function(_x: Box) {} - | +++ - -warning: 3 warnings emitted +warning: 1 warning emitted diff --git a/tests/ui/lint/lint-stability-deprecated.rs b/tests/ui/lint/lint-stability-deprecated.rs index a56a37228e533..80bc85ff557fc 100644 --- a/tests/ui/lint/lint-stability-deprecated.rs +++ b/tests/ui/lint/lint-stability-deprecated.rs @@ -96,13 +96,10 @@ mod cross_crate { struct S1(T::TypeUnstable); struct S2(T::TypeDeprecated); //~^ WARN use of deprecated associated type `lint_stability::TraitWithAssociatedTypes::TypeDeprecated`: text - //~| WARN use of deprecated associated type `lint_stability::TraitWithAssociatedTypes::TypeDeprecated`: text type A = dyn TraitWithAssociatedTypes< TypeUnstable = u8, TypeDeprecated = u16, //~^ WARN use of deprecated associated type `lint_stability::TraitWithAssociatedTypes::TypeDeprecated` - //~| WARN use of deprecated associated type `lint_stability::TraitWithAssociatedTypes::TypeDeprecated` - //~| WARN use of deprecated associated type `lint_stability::TraitWithAssociatedTypes::TypeDeprecated` >; let _ = DeprecatedStruct { //~ WARN use of deprecated struct `lint_stability::DeprecatedStruct` diff --git a/tests/ui/lint/lint-stability-deprecated.stderr b/tests/ui/lint/lint-stability-deprecated.stderr index 609fc56a8ae5f..51205ff434062 100644 --- a/tests/ui/lint/lint-stability-deprecated.stderr +++ b/tests/ui/lint/lint-stability-deprecated.stderr @@ -77,241 +77,241 @@ LL | ... ::trait_deprecated_unstable_text(&foo); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: use of deprecated struct `lint_stability::DeprecatedStruct`: text - --> $DIR/lint-stability-deprecated.rs:108:17 + --> $DIR/lint-stability-deprecated.rs:105:17 | LL | let _ = DeprecatedStruct { | ^^^^^^^^^^^^^^^^ warning: use of deprecated struct `lint_stability::DeprecatedUnstableStruct`: text - --> $DIR/lint-stability-deprecated.rs:111:17 + --> $DIR/lint-stability-deprecated.rs:108:17 | LL | let _ = DeprecatedUnstableStruct { | ^^^^^^^^^^^^^^^^^^^^^^^^ warning: use of deprecated unit struct `lint_stability::DeprecatedUnitStruct`: text - --> $DIR/lint-stability-deprecated.rs:118:17 + --> $DIR/lint-stability-deprecated.rs:115:17 | LL | let _ = DeprecatedUnitStruct; | ^^^^^^^^^^^^^^^^^^^^ warning: use of deprecated unit struct `lint_stability::DeprecatedUnstableUnitStruct`: text - --> $DIR/lint-stability-deprecated.rs:119:17 + --> $DIR/lint-stability-deprecated.rs:116:17 | LL | let _ = DeprecatedUnstableUnitStruct; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: use of deprecated unit variant `lint_stability::Enum::DeprecatedVariant`: text - --> $DIR/lint-stability-deprecated.rs:123:23 + --> $DIR/lint-stability-deprecated.rs:120:23 | LL | let _ = Enum::DeprecatedVariant; | ^^^^^^^^^^^^^^^^^ warning: use of deprecated unit variant `lint_stability::Enum::DeprecatedUnstableVariant`: text - --> $DIR/lint-stability-deprecated.rs:124:23 + --> $DIR/lint-stability-deprecated.rs:121:23 | LL | let _ = Enum::DeprecatedUnstableVariant; | ^^^^^^^^^^^^^^^^^^^^^^^^^ warning: use of deprecated tuple struct `lint_stability::DeprecatedTupleStruct`: text - --> $DIR/lint-stability-deprecated.rs:128:17 + --> $DIR/lint-stability-deprecated.rs:125:17 | LL | let _ = DeprecatedTupleStruct (1); | ^^^^^^^^^^^^^^^^^^^^^ warning: use of deprecated tuple struct `lint_stability::DeprecatedUnstableTupleStruct`: text - --> $DIR/lint-stability-deprecated.rs:129:17 + --> $DIR/lint-stability-deprecated.rs:126:17 | LL | let _ = DeprecatedUnstableTupleStruct (1); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: use of deprecated function `lint_stability::deprecated_text`: text - --> $DIR/lint-stability-deprecated.rs:138:25 + --> $DIR/lint-stability-deprecated.rs:135:25 | LL | macro_test_arg!(deprecated_text()); | ^^^^^^^^^^^^^^^ warning: use of deprecated function `lint_stability::deprecated_unstable_text`: text - --> $DIR/lint-stability-deprecated.rs:139:25 + --> $DIR/lint-stability-deprecated.rs:136:25 | LL | macro_test_arg!(deprecated_unstable_text()); | ^^^^^^^^^^^^^^^^^^^^^^^^ warning: use of deprecated function `lint_stability::deprecated_text`: text - --> $DIR/lint-stability-deprecated.rs:140:41 + --> $DIR/lint-stability-deprecated.rs:137:41 | LL | macro_test_arg!(macro_test_arg!(deprecated_text())); | ^^^^^^^^^^^^^^^ warning: use of deprecated method `lint_stability::Trait::trait_deprecated`: text - --> $DIR/lint-stability-deprecated.rs:145:16 + --> $DIR/lint-stability-deprecated.rs:142:16 | LL | Trait::trait_deprecated(&foo); | ^^^^^^^^^^^^^^^^ warning: use of deprecated method `lint_stability::Trait::trait_deprecated`: text - --> $DIR/lint-stability-deprecated.rs:147:25 + --> $DIR/lint-stability-deprecated.rs:144:25 | LL | ::trait_deprecated(&foo); | ^^^^^^^^^^^^^^^^ warning: use of deprecated method `lint_stability::Trait::trait_deprecated_text`: text - --> $DIR/lint-stability-deprecated.rs:149:16 + --> $DIR/lint-stability-deprecated.rs:146:16 | LL | Trait::trait_deprecated_text(&foo); | ^^^^^^^^^^^^^^^^^^^^^ warning: use of deprecated method `lint_stability::Trait::trait_deprecated_text`: text - --> $DIR/lint-stability-deprecated.rs:151:25 + --> $DIR/lint-stability-deprecated.rs:148:25 | LL | ::trait_deprecated_text(&foo); | ^^^^^^^^^^^^^^^^^^^^^ warning: use of deprecated method `lint_stability::Trait::trait_deprecated_unstable`: text - --> $DIR/lint-stability-deprecated.rs:153:16 + --> $DIR/lint-stability-deprecated.rs:150:16 | LL | Trait::trait_deprecated_unstable(&foo); | ^^^^^^^^^^^^^^^^^^^^^^^^^ warning: use of deprecated method `lint_stability::Trait::trait_deprecated_unstable`: text - --> $DIR/lint-stability-deprecated.rs:155:25 + --> $DIR/lint-stability-deprecated.rs:152:25 | LL | ... ::trait_deprecated_unstable(&foo); | ^^^^^^^^^^^^^^^^^^^^^^^^^ warning: use of deprecated method `lint_stability::Trait::trait_deprecated_unstable_text`: text - --> $DIR/lint-stability-deprecated.rs:157:16 + --> $DIR/lint-stability-deprecated.rs:154:16 | LL | ... Trait::trait_deprecated_unstable_text(&foo); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: use of deprecated method `lint_stability::Trait::trait_deprecated_unstable_text`: text - --> $DIR/lint-stability-deprecated.rs:159:25 + --> $DIR/lint-stability-deprecated.rs:156:25 | LL | ... ::trait_deprecated_unstable_text(&foo); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: use of deprecated trait `lint_stability::DeprecatedTrait`: text - --> $DIR/lint-stability-deprecated.rs:187:10 + --> $DIR/lint-stability-deprecated.rs:184:10 | LL | impl DeprecatedTrait for S {} | ^^^^^^^^^^^^^^^ warning: use of deprecated trait `lint_stability::DeprecatedTrait`: text - --> $DIR/lint-stability-deprecated.rs:189:25 + --> $DIR/lint-stability-deprecated.rs:186:25 | LL | trait LocalTrait2 : DeprecatedTrait { } | ^^^^^^^^^^^^^^^ warning: use of deprecated function `inheritance::inherited_stability::unstable_mod::deprecated`: text - --> $DIR/lint-stability-deprecated.rs:208:23 + --> $DIR/lint-stability-deprecated.rs:205:23 | LL | unstable_mod::deprecated(); | ^^^^^^^^^^ warning: use of deprecated function `this_crate::deprecated`: text - --> $DIR/lint-stability-deprecated.rs:330:9 + --> $DIR/lint-stability-deprecated.rs:327:9 | LL | deprecated(); | ^^^^^^^^^^ warning: use of deprecated method `this_crate::Trait::trait_deprecated`: text - --> $DIR/lint-stability-deprecated.rs:335:16 + --> $DIR/lint-stability-deprecated.rs:332:16 | LL | Trait::trait_deprecated(&foo); | ^^^^^^^^^^^^^^^^ warning: use of deprecated method `this_crate::Trait::trait_deprecated`: text - --> $DIR/lint-stability-deprecated.rs:337:25 + --> $DIR/lint-stability-deprecated.rs:334:25 | LL | ::trait_deprecated(&foo); | ^^^^^^^^^^^^^^^^ warning: use of deprecated function `this_crate::deprecated_text`: text - --> $DIR/lint-stability-deprecated.rs:339:9 + --> $DIR/lint-stability-deprecated.rs:336:9 | LL | deprecated_text(); | ^^^^^^^^^^^^^^^ warning: use of deprecated method `this_crate::Trait::trait_deprecated_text`: text - --> $DIR/lint-stability-deprecated.rs:344:16 + --> $DIR/lint-stability-deprecated.rs:341:16 | LL | Trait::trait_deprecated_text(&foo); | ^^^^^^^^^^^^^^^^^^^^^ warning: use of deprecated method `this_crate::Trait::trait_deprecated_text`: text - --> $DIR/lint-stability-deprecated.rs:346:25 + --> $DIR/lint-stability-deprecated.rs:343:25 | LL | ::trait_deprecated_text(&foo); | ^^^^^^^^^^^^^^^^^^^^^ warning: use of deprecated struct `this_crate::DeprecatedStruct`: text - --> $DIR/lint-stability-deprecated.rs:384:17 + --> $DIR/lint-stability-deprecated.rs:381:17 | LL | let _ = DeprecatedStruct { | ^^^^^^^^^^^^^^^^ warning: use of deprecated unit struct `this_crate::DeprecatedUnitStruct`: text - --> $DIR/lint-stability-deprecated.rs:391:17 + --> $DIR/lint-stability-deprecated.rs:388:17 | LL | let _ = DeprecatedUnitStruct; | ^^^^^^^^^^^^^^^^^^^^ warning: use of deprecated unit variant `this_crate::Enum::DeprecatedVariant`: text - --> $DIR/lint-stability-deprecated.rs:395:23 + --> $DIR/lint-stability-deprecated.rs:392:23 | LL | let _ = Enum::DeprecatedVariant; | ^^^^^^^^^^^^^^^^^ warning: use of deprecated tuple struct `this_crate::DeprecatedTupleStruct`: text - --> $DIR/lint-stability-deprecated.rs:399:17 + --> $DIR/lint-stability-deprecated.rs:396:17 | LL | let _ = DeprecatedTupleStruct (1); | ^^^^^^^^^^^^^^^^^^^^^ warning: use of deprecated method `this_crate::Trait::trait_deprecated`: text - --> $DIR/lint-stability-deprecated.rs:406:16 + --> $DIR/lint-stability-deprecated.rs:403:16 | LL | Trait::trait_deprecated(&foo); | ^^^^^^^^^^^^^^^^ warning: use of deprecated method `this_crate::Trait::trait_deprecated`: text - --> $DIR/lint-stability-deprecated.rs:408:25 + --> $DIR/lint-stability-deprecated.rs:405:25 | LL | ::trait_deprecated(&foo); | ^^^^^^^^^^^^^^^^ warning: use of deprecated method `this_crate::Trait::trait_deprecated_text`: text - --> $DIR/lint-stability-deprecated.rs:410:16 + --> $DIR/lint-stability-deprecated.rs:407:16 | LL | Trait::trait_deprecated_text(&foo); | ^^^^^^^^^^^^^^^^^^^^^ warning: use of deprecated method `this_crate::Trait::trait_deprecated_text`: text - --> $DIR/lint-stability-deprecated.rs:412:25 + --> $DIR/lint-stability-deprecated.rs:409:25 | LL | ::trait_deprecated_text(&foo); | ^^^^^^^^^^^^^^^^^^^^^ warning: use of deprecated function `this_crate::test_fn_body::fn_in_body`: text - --> $DIR/lint-stability-deprecated.rs:439:9 + --> $DIR/lint-stability-deprecated.rs:436:9 | LL | fn_in_body(); | ^^^^^^^^^^ warning: use of deprecated trait `this_crate::DeprecatedTrait`: text - --> $DIR/lint-stability-deprecated.rs:459:10 + --> $DIR/lint-stability-deprecated.rs:456:10 | LL | impl DeprecatedTrait for S { } | ^^^^^^^^^^^^^^^ warning: use of deprecated trait `this_crate::DeprecatedTrait`: text - --> $DIR/lint-stability-deprecated.rs:461:24 + --> $DIR/lint-stability-deprecated.rs:458:24 | LL | trait LocalTrait : DeprecatedTrait { } | ^^^^^^^^^^^^^^^ warning: use of deprecated function `this_crate::MethodTester::test_method_body::fn_in_body`: text - --> $DIR/lint-stability-deprecated.rs:447:13 + --> $DIR/lint-stability-deprecated.rs:444:13 | LL | fn_in_body(); | ^^^^^^^^^^ @@ -323,7 +323,7 @@ LL | struct S2(T::TypeDeprecated); | ^^^^^^^^^^^^^^^^^ warning: use of deprecated associated type `lint_stability::TraitWithAssociatedTypes::TypeDeprecated`: text - --> $DIR/lint-stability-deprecated.rs:102:13 + --> $DIR/lint-stability-deprecated.rs:101:13 | LL | TypeDeprecated = u16, | ^^^^^^^^^^^^^^^^^^^^ @@ -449,214 +449,190 @@ LL | ... ::trait_deprecated_unstable_text(&foo); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: use of deprecated field `lint_stability::DeprecatedStruct::i`: text - --> $DIR/lint-stability-deprecated.rs:109:13 + --> $DIR/lint-stability-deprecated.rs:106:13 | LL | i: 0 | ^^^^ warning: use of deprecated field `lint_stability::DeprecatedUnstableStruct::i`: text - --> $DIR/lint-stability-deprecated.rs:113:13 + --> $DIR/lint-stability-deprecated.rs:110:13 | LL | i: 0 | ^^^^ warning: use of deprecated method `lint_stability::Trait::trait_deprecated`: text - --> $DIR/lint-stability-deprecated.rs:144:13 + --> $DIR/lint-stability-deprecated.rs:141:13 | LL | foo.trait_deprecated(); | ^^^^^^^^^^^^^^^^ warning: use of deprecated method `lint_stability::Trait::trait_deprecated`: text - --> $DIR/lint-stability-deprecated.rs:146:16 + --> $DIR/lint-stability-deprecated.rs:143:16 | LL | ::trait_deprecated(&foo); | ^^^^^^^^^^^^^^^^ warning: use of deprecated method `lint_stability::Trait::trait_deprecated_text`: text - --> $DIR/lint-stability-deprecated.rs:148:13 + --> $DIR/lint-stability-deprecated.rs:145:13 | LL | foo.trait_deprecated_text(); | ^^^^^^^^^^^^^^^^^^^^^ warning: use of deprecated method `lint_stability::Trait::trait_deprecated_text`: text - --> $DIR/lint-stability-deprecated.rs:150:16 + --> $DIR/lint-stability-deprecated.rs:147:16 | LL | ::trait_deprecated_text(&foo); | ^^^^^^^^^^^^^^^^^^^^^ warning: use of deprecated method `lint_stability::Trait::trait_deprecated_unstable`: text - --> $DIR/lint-stability-deprecated.rs:152:13 + --> $DIR/lint-stability-deprecated.rs:149:13 | LL | foo.trait_deprecated_unstable(); | ^^^^^^^^^^^^^^^^^^^^^^^^^ warning: use of deprecated method `lint_stability::Trait::trait_deprecated_unstable`: text - --> $DIR/lint-stability-deprecated.rs:154:16 + --> $DIR/lint-stability-deprecated.rs:151:16 | LL | ::trait_deprecated_unstable(&foo); | ^^^^^^^^^^^^^^^^^^^^^^^^^ warning: use of deprecated method `lint_stability::Trait::trait_deprecated_unstable_text`: text - --> $DIR/lint-stability-deprecated.rs:156:13 + --> $DIR/lint-stability-deprecated.rs:153:13 | LL | ... foo.trait_deprecated_unstable_text(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: use of deprecated method `lint_stability::Trait::trait_deprecated_unstable_text`: text - --> $DIR/lint-stability-deprecated.rs:158:16 + --> $DIR/lint-stability-deprecated.rs:155:16 | LL | ... ::trait_deprecated_unstable_text(&foo); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: use of deprecated method `lint_stability::Trait::trait_deprecated`: text - --> $DIR/lint-stability-deprecated.rs:175:13 + --> $DIR/lint-stability-deprecated.rs:172:13 | LL | foo.trait_deprecated(); | ^^^^^^^^^^^^^^^^ warning: use of deprecated method `lint_stability::Trait::trait_deprecated_text`: text - --> $DIR/lint-stability-deprecated.rs:176:13 + --> $DIR/lint-stability-deprecated.rs:173:13 | LL | foo.trait_deprecated_text(); | ^^^^^^^^^^^^^^^^^^^^^ warning: use of deprecated method `lint_stability::Trait::trait_deprecated_unstable`: text - --> $DIR/lint-stability-deprecated.rs:177:13 + --> $DIR/lint-stability-deprecated.rs:174:13 | LL | foo.trait_deprecated_unstable(); | ^^^^^^^^^^^^^^^^^^^^^^^^^ warning: use of deprecated method `lint_stability::Trait::trait_deprecated_unstable_text`: text - --> $DIR/lint-stability-deprecated.rs:178:13 + --> $DIR/lint-stability-deprecated.rs:175:13 | LL | ... foo.trait_deprecated_unstable_text(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: use of deprecated method `this_crate::MethodTester::method_deprecated`: text - --> $DIR/lint-stability-deprecated.rs:331:13 + --> $DIR/lint-stability-deprecated.rs:328:13 | LL | foo.method_deprecated(); | ^^^^^^^^^^^^^^^^^ warning: use of deprecated method `this_crate::MethodTester::method_deprecated`: text - --> $DIR/lint-stability-deprecated.rs:332:14 + --> $DIR/lint-stability-deprecated.rs:329:14 | LL | Foo::method_deprecated(&foo); | ^^^^^^^^^^^^^^^^^ warning: use of deprecated method `this_crate::MethodTester::method_deprecated`: text - --> $DIR/lint-stability-deprecated.rs:333:16 + --> $DIR/lint-stability-deprecated.rs:330:16 | LL | ::method_deprecated(&foo); | ^^^^^^^^^^^^^^^^^ warning: use of deprecated method `this_crate::Trait::trait_deprecated`: text - --> $DIR/lint-stability-deprecated.rs:334:13 + --> $DIR/lint-stability-deprecated.rs:331:13 | LL | foo.trait_deprecated(); | ^^^^^^^^^^^^^^^^ warning: use of deprecated method `this_crate::Trait::trait_deprecated`: text - --> $DIR/lint-stability-deprecated.rs:336:16 + --> $DIR/lint-stability-deprecated.rs:333:16 | LL | ::trait_deprecated(&foo); | ^^^^^^^^^^^^^^^^ warning: use of deprecated method `this_crate::MethodTester::method_deprecated_text`: text - --> $DIR/lint-stability-deprecated.rs:340:13 + --> $DIR/lint-stability-deprecated.rs:337:13 | LL | foo.method_deprecated_text(); | ^^^^^^^^^^^^^^^^^^^^^^ warning: use of deprecated method `this_crate::MethodTester::method_deprecated_text`: text - --> $DIR/lint-stability-deprecated.rs:341:14 + --> $DIR/lint-stability-deprecated.rs:338:14 | LL | Foo::method_deprecated_text(&foo); | ^^^^^^^^^^^^^^^^^^^^^^ warning: use of deprecated method `this_crate::MethodTester::method_deprecated_text`: text - --> $DIR/lint-stability-deprecated.rs:342:16 + --> $DIR/lint-stability-deprecated.rs:339:16 | LL | ::method_deprecated_text(&foo); | ^^^^^^^^^^^^^^^^^^^^^^ warning: use of deprecated method `this_crate::Trait::trait_deprecated_text`: text - --> $DIR/lint-stability-deprecated.rs:343:13 + --> $DIR/lint-stability-deprecated.rs:340:13 | LL | foo.trait_deprecated_text(); | ^^^^^^^^^^^^^^^^^^^^^ warning: use of deprecated method `this_crate::Trait::trait_deprecated_text`: text - --> $DIR/lint-stability-deprecated.rs:345:16 + --> $DIR/lint-stability-deprecated.rs:342:16 | LL | ::trait_deprecated_text(&foo); | ^^^^^^^^^^^^^^^^^^^^^ warning: use of deprecated field `this_crate::DeprecatedStruct::i`: text - --> $DIR/lint-stability-deprecated.rs:386:13 + --> $DIR/lint-stability-deprecated.rs:383:13 | LL | i: 0 | ^^^^ warning: use of deprecated method `this_crate::Trait::trait_deprecated`: text - --> $DIR/lint-stability-deprecated.rs:405:13 + --> $DIR/lint-stability-deprecated.rs:402:13 | LL | foo.trait_deprecated(); | ^^^^^^^^^^^^^^^^ warning: use of deprecated method `this_crate::Trait::trait_deprecated`: text - --> $DIR/lint-stability-deprecated.rs:407:16 + --> $DIR/lint-stability-deprecated.rs:404:16 | LL | ::trait_deprecated(&foo); | ^^^^^^^^^^^^^^^^ warning: use of deprecated method `this_crate::Trait::trait_deprecated_text`: text - --> $DIR/lint-stability-deprecated.rs:409:13 + --> $DIR/lint-stability-deprecated.rs:406:13 | LL | foo.trait_deprecated_text(); | ^^^^^^^^^^^^^^^^^^^^^ warning: use of deprecated method `this_crate::Trait::trait_deprecated_text`: text - --> $DIR/lint-stability-deprecated.rs:411:16 + --> $DIR/lint-stability-deprecated.rs:408:16 | LL | ::trait_deprecated_text(&foo); | ^^^^^^^^^^^^^^^^^^^^^ warning: use of deprecated method `this_crate::Trait::trait_deprecated`: text - --> $DIR/lint-stability-deprecated.rs:428:13 + --> $DIR/lint-stability-deprecated.rs:425:13 | LL | foo.trait_deprecated(); | ^^^^^^^^^^^^^^^^ warning: use of deprecated method `this_crate::Trait::trait_deprecated_text`: text - --> $DIR/lint-stability-deprecated.rs:429:13 + --> $DIR/lint-stability-deprecated.rs:426:13 | LL | foo.trait_deprecated_text(); | ^^^^^^^^^^^^^^^^^^^^^ -warning: use of deprecated associated type `lint_stability::TraitWithAssociatedTypes::TypeDeprecated`: text - --> $DIR/lint-stability-deprecated.rs:97:48 - | -LL | struct S2(T::TypeDeprecated); - | ^^^^^^^^^^^^^^^^^ - | - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -warning: use of deprecated associated type `lint_stability::TraitWithAssociatedTypes::TypeDeprecated`: text - --> $DIR/lint-stability-deprecated.rs:102:13 - | -LL | TypeDeprecated = u16, - | ^^^^^^^^^^^^^^^^^^^^ - | - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -warning: use of deprecated associated type `lint_stability::TraitWithAssociatedTypes::TypeDeprecated`: text - --> $DIR/lint-stability-deprecated.rs:102:13 - | -LL | TypeDeprecated = u16, - | ^^^^^^^^^^^^^^^^^^^^ - | - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -warning: 108 warnings emitted +warning: 105 warnings emitted diff --git a/tests/ui/object-safety/assoc_type_bounds_sized_unnecessary.rs b/tests/ui/object-safety/assoc_type_bounds_sized_unnecessary.rs index 800624e3124b6..34daa81e48ea5 100644 --- a/tests/ui/object-safety/assoc_type_bounds_sized_unnecessary.rs +++ b/tests/ui/object-safety/assoc_type_bounds_sized_unnecessary.rs @@ -8,8 +8,6 @@ trait Foo { fn foo(_: &dyn Foo) {} //~^ WARN: unnecessary associated type bound for not object safe associated type -//~| WARN: unnecessary associated type bound for not object safe associated type -//~| WARN: unnecessary associated type bound for not object safe associated type #[allow(unused_associated_type_bounds)] fn bar(_: &dyn Foo) {} diff --git a/tests/ui/object-safety/assoc_type_bounds_sized_unnecessary.stderr b/tests/ui/object-safety/assoc_type_bounds_sized_unnecessary.stderr index 659679e444095..f2bc8bd8400ce 100644 --- a/tests/ui/object-safety/assoc_type_bounds_sized_unnecessary.stderr +++ b/tests/ui/object-safety/assoc_type_bounds_sized_unnecessary.stderr @@ -7,23 +7,5 @@ LL | fn foo(_: &dyn Foo) {} = note: this associated type has a `where Self: Sized` bound. Thus, while the associated type can be specified, it cannot be used in any way, because trait objects are not `Sized`. = note: `#[warn(unused_associated_type_bounds)]` on by default -warning: unnecessary associated type bound for not object safe associated type - --> $DIR/assoc_type_bounds_sized_unnecessary.rs:9:20 - | -LL | fn foo(_: &dyn Foo) {} - | ^^^^^^^^ help: remove this bound - | - = note: this associated type has a `where Self: Sized` bound. Thus, while the associated type can be specified, it cannot be used in any way, because trait objects are not `Sized`. - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -warning: unnecessary associated type bound for not object safe associated type - --> $DIR/assoc_type_bounds_sized_unnecessary.rs:9:20 - | -LL | fn foo(_: &dyn Foo) {} - | ^^^^^^^^ help: remove this bound - | - = note: this associated type has a `where Self: Sized` bound. Thus, while the associated type can be specified, it cannot be used in any way, because trait objects are not `Sized`. - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -warning: 3 warnings emitted +warning: 1 warning emitted diff --git a/tests/ui/privacy/associated-item-privacy-trait.stderr b/tests/ui/privacy/associated-item-privacy-trait.stderr index 4e9dfa4a83519..f79c4cff72fa2 100644 --- a/tests/ui/privacy/associated-item-privacy-trait.stderr +++ b/tests/ui/privacy/associated-item-privacy-trait.stderr @@ -75,17 +75,6 @@ LL | priv_trait::mac!(); | = note: this error originates in the macro `priv_trait::mac` (in Nightly builds, run with -Z macro-backtrace for more info) -error: trait `PrivTr` is private - --> $DIR/associated-item-privacy-trait.rs:29:14 - | -LL | impl PrivTr for u8 {} - | ^^^^^^ private trait -... -LL | priv_trait::mac!(); - | ------------------ in this macro invocation - | - = note: this error originates in the macro `priv_trait::mac` (in Nightly builds, run with -Z macro-backtrace for more info) - error: type `priv_signature::Priv` is private --> $DIR/associated-item-privacy-trait.rs:46:21 | @@ -328,5 +317,16 @@ LL | priv_parent_substs::mac!(); | = note: this error originates in the macro `priv_parent_substs::mac` (in Nightly builds, run with -Z macro-backtrace for more info) +error: trait `PrivTr` is private + --> $DIR/associated-item-privacy-trait.rs:29:14 + | +LL | impl PrivTr for u8 {} + | ^^^^^^ private trait +... +LL | priv_trait::mac!(); + | ------------------ in this macro invocation + | + = note: this error originates in the macro `priv_trait::mac` (in Nightly builds, run with -Z macro-backtrace for more info) + error: aborting due to 30 previous errors diff --git a/tests/ui/privacy/associated-item-privacy-type-binding.stderr b/tests/ui/privacy/associated-item-privacy-type-binding.stderr index de9893816fade..52bfa3c2ab889 100644 --- a/tests/ui/privacy/associated-item-privacy-type-binding.stderr +++ b/tests/ui/privacy/associated-item-privacy-type-binding.stderr @@ -32,10 +32,10 @@ LL | priv_trait::mac1!(); = note: this error originates in the macro `priv_trait::mac1` (in Nightly builds, run with -Z macro-backtrace for more info) error: trait `PrivTr` is private - --> $DIR/associated-item-privacy-type-binding.rs:16:31 + --> $DIR/associated-item-privacy-type-binding.rs:16:37 | LL | trait InSignatureTr2: PubTr {} - | ^^^^^^^^^^^^^^^^^^^ private trait + | ^^^^^^^^^^^^ private trait ... LL | priv_trait::mac1!(); | ------------------- in this macro invocation @@ -164,10 +164,10 @@ LL | priv_parent_substs::mac!(); = note: this error originates in the macro `priv_parent_substs::mac` (in Nightly builds, run with -Z macro-backtrace for more info) error: type `Priv` is private - --> $DIR/associated-item-privacy-type-binding.rs:56:31 + --> $DIR/associated-item-privacy-type-binding.rs:56:37 | LL | trait InSignatureTr2: PubTr {} - | ^^^^^^^^^^^^^^^^^^^ private type + | ^^^^^^^^^^^^ private type ... LL | priv_parent_substs::mac!(); | -------------------------- in this macro invocation diff --git a/tests/ui/privacy/private-type-in-interface.stderr b/tests/ui/privacy/private-type-in-interface.stderr index a5e80d6962dba..091cae42dea3c 100644 --- a/tests/ui/privacy/private-type-in-interface.stderr +++ b/tests/ui/privacy/private-type-in-interface.stderr @@ -47,10 +47,10 @@ LL | fn g() -> impl Tr2 { 0 } | ^^^^^^^^^^^^^^^^^^ private type error: type `Priv` is private - --> $DIR/private-type-in-interface.rs:28:16 + --> $DIR/private-type-in-interface.rs:28:11 | LL | fn g() -> impl Tr2 { 0 } - | ^^^^^^^^^^^^^ private type + | ^^^^^^^^^^^^^^^^^^ private type error: type `ext::Priv` is private --> $DIR/private-type-in-interface.rs:30:15 @@ -59,10 +59,10 @@ LL | fn g_ext() -> impl Tr2 { 0 } | ^^^^^^^^^^^^^^^^^^^^ private type error: type `ext::Priv` is private - --> $DIR/private-type-in-interface.rs:30:20 + --> $DIR/private-type-in-interface.rs:30:15 | LL | fn g_ext() -> impl Tr2 { 0 } - | ^^^^^^^^^^^^^^^ private type + | ^^^^^^^^^^^^^^^^^^^^ private type error: aborting due to 11 previous errors diff --git a/tests/ui/privacy/struct-field-type.rs b/tests/ui/privacy/struct-field-type.rs new file mode 100644 index 0000000000000..6a4a19297e190 --- /dev/null +++ b/tests/ui/privacy/struct-field-type.rs @@ -0,0 +1,10 @@ +mod m { + struct Priv; + pub type Leak = Priv; //~ WARN: `Priv` is more private than the item `Leak` +} + +struct S { + field: m::Leak, //~ ERROR: `Priv` is private +} + +fn main() {} diff --git a/tests/ui/privacy/struct-field-type.stderr b/tests/ui/privacy/struct-field-type.stderr new file mode 100644 index 0000000000000..854ff6a98a46b --- /dev/null +++ b/tests/ui/privacy/struct-field-type.stderr @@ -0,0 +1,21 @@ +warning: type `Priv` is more private than the item `Leak` + --> $DIR/struct-field-type.rs:3:5 + | +LL | pub type Leak = Priv; + | ^^^^^^^^^^^^^ type alias `Leak` is reachable at visibility `pub(crate)` + | +note: but type `Priv` is only usable at visibility `pub(self)` + --> $DIR/struct-field-type.rs:2:5 + | +LL | struct Priv; + | ^^^^^^^^^^^ + = note: `#[warn(private_interfaces)]` on by default + +error: type `Priv` is private + --> $DIR/struct-field-type.rs:7:5 + | +LL | field: m::Leak, + | ^^^^^ private type + +error: aborting due to 1 previous error; 1 warning emitted + diff --git a/tests/ui/suggestions/issue-61963.rs b/tests/ui/suggestions/issue-61963.rs index a27c38452539c..d31ed01b1916b 100644 --- a/tests/ui/suggestions/issue-61963.rs +++ b/tests/ui/suggestions/issue-61963.rs @@ -18,20 +18,10 @@ pub struct Qux(T); pub struct Foo { //~^ ERROR trait objects without an explicit `dyn` are deprecated [bare_trait_objects] //~| WARN this is accepted in the current edition - //~| ERROR trait objects without an explicit `dyn` are deprecated [bare_trait_objects] - //~| WARN this is accepted in the current edition - //~| ERROR trait objects without an explicit `dyn` are deprecated [bare_trait_objects] - //~| WARN this is accepted in the current edition - //~| ERROR trait objects without an explicit `dyn` are deprecated [bare_trait_objects] - //~| WARN this is accepted in the current edition qux: Qux>, bar: Box, //~^ ERROR trait objects without an explicit `dyn` are deprecated [bare_trait_objects] //~| WARN this is accepted in the current edition - //~| ERROR trait objects without an explicit `dyn` are deprecated [bare_trait_objects] - //~| WARN this is accepted in the current edition - //~| ERROR trait objects without an explicit `dyn` are deprecated [bare_trait_objects] - //~| WARN this is accepted in the current edition } fn main() {} diff --git a/tests/ui/suggestions/issue-61963.stderr b/tests/ui/suggestions/issue-61963.stderr index ec62153b0a76f..754d02b1c021b 100644 --- a/tests/ui/suggestions/issue-61963.stderr +++ b/tests/ui/suggestions/issue-61963.stderr @@ -1,5 +1,5 @@ error: trait objects without an explicit `dyn` are deprecated - --> $DIR/issue-61963.rs:28:14 + --> $DIR/issue-61963.rs:22:14 | LL | bar: Box, | ^^^ @@ -29,75 +29,5 @@ help: use `dyn` LL | dyn pub struct Foo { | +++ -error: trait objects without an explicit `dyn` are deprecated - --> $DIR/issue-61963.rs:28:14 - | -LL | bar: Box, - | ^^^ - | - = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! - = note: for more information, see - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -help: use `dyn` - | -LL | bar: Box, - | +++ - -error: trait objects without an explicit `dyn` are deprecated - --> $DIR/issue-61963.rs:28:14 - | -LL | bar: Box, - | ^^^ - | - = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! - = note: for more information, see - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -help: use `dyn` - | -LL | bar: Box, - | +++ - -error: trait objects without an explicit `dyn` are deprecated - --> $DIR/issue-61963.rs:18:1 - | -LL | pub struct Foo { - | ^^^ - | - = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! - = note: for more information, see - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -help: use `dyn` - | -LL | dyn pub struct Foo { - | +++ - -error: trait objects without an explicit `dyn` are deprecated - --> $DIR/issue-61963.rs:18:1 - | -LL | pub struct Foo { - | ^^^ - | - = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! - = note: for more information, see - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -help: use `dyn` - | -LL | dyn pub struct Foo { - | +++ - -error: trait objects without an explicit `dyn` are deprecated - --> $DIR/issue-61963.rs:18:1 - | -LL | pub struct Foo { - | ^^^ - | - = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! - = note: for more information, see - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -help: use `dyn` - | -LL | dyn pub struct Foo { - | +++ - -error: aborting due to 7 previous errors +error: aborting due to 2 previous errors diff --git a/tests/ui/type-alias-enum-variants/enum-variant-priority-lint-ambiguous_associated_items.rs b/tests/ui/type-alias-enum-variants/enum-variant-priority-lint-ambiguous_associated_items.rs index acbf15dcb6c6a..5f3b711b31aa9 100644 --- a/tests/ui/type-alias-enum-variants/enum-variant-priority-lint-ambiguous_associated_items.rs +++ b/tests/ui/type-alias-enum-variants/enum-variant-priority-lint-ambiguous_associated_items.rs @@ -31,10 +31,7 @@ impl Tr for E { type V = u8; fn f() -> Self::V { 0 } //~^ ERROR ambiguous associated item - //~| ERROR ambiguous associated item //~| WARN this was previously accepted - //~| WARN this was previously accepted - //~| HELP use fully-qualified syntax //~| HELP use fully-qualified syntax } diff --git a/tests/ui/type-alias-enum-variants/enum-variant-priority-lint-ambiguous_associated_items.stderr b/tests/ui/type-alias-enum-variants/enum-variant-priority-lint-ambiguous_associated_items.stderr index 359bd09ecd02b..0f42fcbe04d0a 100644 --- a/tests/ui/type-alias-enum-variants/enum-variant-priority-lint-ambiguous_associated_items.stderr +++ b/tests/ui/type-alias-enum-variants/enum-variant-priority-lint-ambiguous_associated_items.stderr @@ -18,25 +18,5 @@ LL | type V; | ^^^^^^ = note: `#[deny(ambiguous_associated_items)]` on by default -error: ambiguous associated item - --> $DIR/enum-variant-priority-lint-ambiguous_associated_items.rs:32:15 - | -LL | fn f() -> Self::V { 0 } - | ^^^^^^^ help: use fully-qualified syntax: `::V` - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #57644 -note: `V` could refer to the variant defined here - --> $DIR/enum-variant-priority-lint-ambiguous_associated_items.rs:22:5 - | -LL | V - | ^ -note: `V` could also refer to the associated type defined here - --> $DIR/enum-variant-priority-lint-ambiguous_associated_items.rs:26:5 - | -LL | type V; - | ^^^^^^ - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -error: aborting due to 2 previous errors +error: aborting due to 1 previous error From 5c25de67d49014397d5c09bcac5f2770b9fda1be Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Wed, 7 Feb 2024 15:03:31 +0000 Subject: [PATCH 08/16] Remove now-useless method override --- compiler/rustc_privacy/src/lib.rs | 7 ------- 1 file changed, 7 deletions(-) diff --git a/compiler/rustc_privacy/src/lib.rs b/compiler/rustc_privacy/src/lib.rs index eaec09cfbc234..6ebbb240d8400 100644 --- a/compiler/rustc_privacy/src/lib.rs +++ b/compiler/rustc_privacy/src/lib.rs @@ -1128,13 +1128,6 @@ impl<'tcx> Visitor<'tcx> for TypePrivacyVisitor<'tcx> { intravisit::walk_inf(self, inf); } - fn visit_trait_ref(&mut self, trait_ref: &'tcx hir::TraitRef<'tcx>) { - self.span = trait_ref.path.span; - // Privacy of traits in bodies is checked as a part of trait object types. - - intravisit::walk_trait_ref(self, trait_ref); - } - // Check types of expressions fn visit_expr(&mut self, expr: &'tcx hir::Expr<'tcx>) { if self.check_expr_pat_type(expr.hir_id, expr.span) { From e867886c6ac20e7b7d8fb4aefcd02490ac7fc80b Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Wed, 7 Feb 2024 15:26:07 +0000 Subject: [PATCH 09/16] Remove dead code --- compiler/rustc_privacy/src/lib.rs | 3 --- 1 file changed, 3 deletions(-) diff --git a/compiler/rustc_privacy/src/lib.rs b/compiler/rustc_privacy/src/lib.rs index 6ebbb240d8400..6fdf4b506ea69 100644 --- a/compiler/rustc_privacy/src/lib.rs +++ b/compiler/rustc_privacy/src/lib.rs @@ -98,9 +98,6 @@ trait DefIdVisitor<'tcx> { fn visit_trait(&mut self, trait_ref: TraitRef<'tcx>) -> ControlFlow { self.skeleton().visit_trait(trait_ref) } - fn visit_projection_ty(&mut self, projection: ty::AliasTy<'tcx>) -> ControlFlow { - self.skeleton().visit_projection_ty(projection) - } fn visit_predicates( &mut self, predicates: ty::GenericPredicates<'tcx>, From 795be51dd931848b8cbf3dc84c526ca92634803c Mon Sep 17 00:00:00 2001 From: Amanda Stjerna Date: Wed, 7 Feb 2024 14:51:51 +0100 Subject: [PATCH 10/16] Make `RegionName` `Copy` by (transitively) interning the few string variants --- .../src/diagnostics/region_name.rs | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/compiler/rustc_borrowck/src/diagnostics/region_name.rs b/compiler/rustc_borrowck/src/diagnostics/region_name.rs index c9de36e9064e2..a31e6ce5f297f 100644 --- a/compiler/rustc_borrowck/src/diagnostics/region_name.rs +++ b/compiler/rustc_borrowck/src/diagnostics/region_name.rs @@ -15,7 +15,7 @@ use crate::{universal_regions::DefiningTy, MirBorrowckCtxt}; /// A name for a particular region used in emitting diagnostics. This name could be a generated /// name like `'1`, a name used by the user like `'a`, or a name like `'static`. -#[derive(Debug, Clone)] +#[derive(Debug, Clone, Copy)] pub(crate) struct RegionName { /// The name of the region (interned). pub(crate) name: Symbol, @@ -26,7 +26,7 @@ pub(crate) struct RegionName { /// Denotes the source of a region that is named by a `RegionName`. For example, a free region that /// was named by the user would get `NamedLateParamRegion` and `'static` lifetime would get `Static`. /// This helps to print the right kinds of diagnostics. -#[derive(Debug, Clone)] +#[derive(Debug, Clone, Copy)] pub(crate) enum RegionNameSource { /// A bound (not free) region that was instantiated at the def site (not an HRTB). NamedEarlyParamRegion(Span), @@ -43,7 +43,7 @@ pub(crate) enum RegionNameSource { /// The region corresponding to the return type of a closure. AnonRegionFromOutput(RegionNameHighlight, &'static str), /// The region from a type yielded by a coroutine. - AnonRegionFromYieldTy(Span, String), + AnonRegionFromYieldTy(Span, Symbol), /// An anonymous region from an async fn. AnonRegionFromAsyncFn(Span), /// An anonymous region from an impl self type or trait @@ -52,7 +52,7 @@ pub(crate) enum RegionNameSource { /// Describes what to highlight to explain to the user that we're giving an anonymous region a /// synthesized name, and how to highlight it. -#[derive(Debug, Clone)] +#[derive(Debug, Clone, Copy)] pub(crate) enum RegionNameHighlight { /// The anonymous region corresponds to a reference that was found by traversing the type in the HIR. MatchedHirTy(Span), @@ -60,11 +60,11 @@ pub(crate) enum RegionNameHighlight { MatchedAdtAndSegment(Span), /// The anonymous region corresponds to a region where the type annotation is completely missing /// from the code, e.g. in a closure arguments `|x| { ... }`, where `x` is a reference. - CannotMatchHirTy(Span, String), + CannotMatchHirTy(Span, Symbol), /// The anonymous region corresponds to a region where the type annotation is completely missing /// from the code, and *even if* we print out the full name of the type, the region name won't /// be included. This currently occurs for opaque types like `impl Future`. - Occluded(Span, String), + Occluded(Span, Symbol), } impl RegionName { @@ -249,7 +249,7 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> { assert!(self.regioncx.universal_regions().is_universal_region(fr)); match self.region_names.borrow_mut().entry(fr) { - IndexEntry::Occupied(precomputed_name) => Some(precomputed_name.get().clone()), + IndexEntry::Occupied(precomputed_name) => Some(*precomputed_name.get()), IndexEntry::Vacant(slot) => { let new_name = self .give_name_from_error_region(fr) @@ -262,8 +262,8 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> { self.give_name_if_anonymous_region_appears_in_arg_position_impl_trait(fr) }); - if let Some(new_name) = &new_name { - slot.insert(new_name.clone()); + if let Some(new_name) = new_name { + slot.insert(new_name); } debug!("give_region_a_name: gave name {:?}", new_name); @@ -460,9 +460,9 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> { ); if type_name.contains(&format!("'{counter}")) { // Only add a label if we can confirm that a region was labelled. - RegionNameHighlight::CannotMatchHirTy(span, type_name) + RegionNameHighlight::CannotMatchHirTy(span, Symbol::intern(&type_name)) } else { - RegionNameHighlight::Occluded(span, type_name) + RegionNameHighlight::Occluded(span, Symbol::intern(&type_name)) } } @@ -882,7 +882,7 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> { Some(RegionName { name: self.synthesize_region_name(), - source: RegionNameSource::AnonRegionFromYieldTy(yield_span, type_name), + source: RegionNameSource::AnonRegionFromYieldTy(yield_span, Symbol::intern(&type_name)), }) } @@ -974,7 +974,7 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> { Some(RegionName { name: region_name, source: RegionNameSource::AnonRegionFromArgument( - RegionNameHighlight::CannotMatchHirTy(arg_span, arg_name?.to_string()), + RegionNameHighlight::CannotMatchHirTy(arg_span, arg_name?), ), }) } else { From d80d7ea1e325ded1b8b57204cbf98e65b6e0957c Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Thu, 8 Feb 2024 12:28:35 +0000 Subject: [PATCH 11/16] Add some tests for associated type normalization edge cases --- tests/ui/privacy/projections.rs | 60 +++++++++++++++++++++++++++ tests/ui/privacy/projections.stderr | 62 ++++++++++++++++++++++++++++ tests/ui/privacy/projections2.rs | 38 +++++++++++++++++ tests/ui/privacy/projections2.stderr | 34 +++++++++++++++ 4 files changed, 194 insertions(+) create mode 100644 tests/ui/privacy/projections.rs create mode 100644 tests/ui/privacy/projections.stderr create mode 100644 tests/ui/privacy/projections2.rs create mode 100644 tests/ui/privacy/projections2.stderr diff --git a/tests/ui/privacy/projections.rs b/tests/ui/privacy/projections.rs new file mode 100644 index 0000000000000..0e6590de4f5b4 --- /dev/null +++ b/tests/ui/privacy/projections.rs @@ -0,0 +1,60 @@ +mod m { + struct Priv; + pub type Leak = Priv; //~ WARN: `Priv` is more private than the item `Leak` +} + +trait Trait { + type A; +} + +impl Trait for u8 { + type A = u8; +} + +fn check() -> ::A { + //~^ ERROR: `Priv` is private + 0 +} + +trait Trait2 { + type A; +} + +impl Trait2 for u8 { + type A = m::Leak; + //~^ ERROR: `Priv` is private + //~| ERROR: private type `Priv` in public interface +} + +fn check2() -> ::A { + //~^ ERROR: `Priv` is private + todo!() +} + +trait Trait3 { + type A; +} + +impl Trait3 for u8 { + type A = T::A; + //~^ ERROR: `Priv` is private + //~| ERROR: private type `Priv` in public interface +} + +fn check3() -> ::A { + todo!() +} + +trait Trait4 { + type A; +} + +impl Trait4 for u8 { + type A = T::A; +} + +fn check4() -> ::A { + todo!() +} + +fn main() {} diff --git a/tests/ui/privacy/projections.stderr b/tests/ui/privacy/projections.stderr new file mode 100644 index 0000000000000..010d77998e344 --- /dev/null +++ b/tests/ui/privacy/projections.stderr @@ -0,0 +1,62 @@ +warning: type `Priv` is more private than the item `Leak` + --> $DIR/projections.rs:3:5 + | +LL | pub type Leak = Priv; + | ^^^^^^^^^^^^^ type alias `Leak` is reachable at visibility `pub(crate)` + | +note: but type `Priv` is only usable at visibility `pub(self)` + --> $DIR/projections.rs:2:5 + | +LL | struct Priv; + | ^^^^^^^^^^^ + = note: `#[warn(private_interfaces)]` on by default + +error[E0446]: private type `Priv` in public interface + --> $DIR/projections.rs:24:5 + | +LL | struct Priv; + | ----------- `Priv` declared as private +... +LL | type A = m::Leak; + | ^^^^^^^^^ can't leak private type + +error[E0446]: private type `Priv` in public interface + --> $DIR/projections.rs:39:5 + | +LL | struct Priv; + | ----------- `Priv` declared as private +... +LL | type A = T::A; + | ^^^^^^^^^^^^^^^^ can't leak private type + +error: type `Priv` is private + --> $DIR/projections.rs:14:15 + | +LL | fn check() -> ::A { + | ^^^^^^^^^^^^^^^^^^^^^^^^^ private type + +error: type `Priv` is private + --> $DIR/projections.rs:29:39 + | +LL | fn check2() -> ::A { + | _______________________________________^ +LL | | +LL | | todo!() +LL | | } + | |_^ private type + +error: type `Priv` is private + --> $DIR/projections.rs:24:17 + | +LL | type A = m::Leak; + | ^^^^^^^ private type + +error: type `Priv` is private + --> $DIR/projections.rs:39:24 + | +LL | type A = T::A; + | ^^^^^^^^^^^^^ private type + +error: aborting due to 6 previous errors; 1 warning emitted + +For more information about this error, try `rustc --explain E0446`. diff --git a/tests/ui/privacy/projections2.rs b/tests/ui/privacy/projections2.rs new file mode 100644 index 0000000000000..1afbf6d196e58 --- /dev/null +++ b/tests/ui/privacy/projections2.rs @@ -0,0 +1,38 @@ +mod m { + use super::*; + struct Priv; + pub type Leak = Priv; //~ WARN: `Priv` is more private than the item `Leak` + + trait Trait3 { + type A; + } + + impl Trait3 for u8 { + type A = T::A; + } + + pub trait Trait4 { + type A; + } + + impl Trait4 for u8 { + type A = ::A; + //~^ ERROR: private associated type `Trait3::A` in public interface + //~| ERROR: private trait `Trait3` in public interface + } +} + +pub trait Trait { + type A; +} + +impl Trait for u8 { + type A = u8; +} +use m::*; + +fn check4() -> ::A { + todo!() +} + +fn main() {} diff --git a/tests/ui/privacy/projections2.stderr b/tests/ui/privacy/projections2.stderr new file mode 100644 index 0000000000000..6eae9643c5a8e --- /dev/null +++ b/tests/ui/privacy/projections2.stderr @@ -0,0 +1,34 @@ +warning: type `Priv` is more private than the item `Leak` + --> $DIR/projections2.rs:4:5 + | +LL | pub type Leak = Priv; + | ^^^^^^^^^^^^^ type alias `Leak` is reachable at visibility `pub(crate)` + | +note: but type `Priv` is only usable at visibility `pub(self)` + --> $DIR/projections2.rs:3:5 + | +LL | struct Priv; + | ^^^^^^^^^^^ + = note: `#[warn(private_interfaces)]` on by default + +error[E0446]: private associated type `Trait3::A` in public interface + --> $DIR/projections2.rs:19:9 + | +LL | type A; + | ---------------- `Trait3::A` declared as private +... +LL | type A = ::A; + | ^^^^^^^^^^^^^^^^ can't leak private associated type + +error[E0446]: private trait `Trait3` in public interface + --> $DIR/projections2.rs:19:9 + | +LL | trait Trait3 { + | ------------ `Trait3` declared as private +... +LL | type A = ::A; + | ^^^^^^^^^^^^^^^^ can't leak private trait + +error: aborting due to 2 previous errors; 1 warning emitted + +For more information about this error, try `rustc --explain E0446`. From d70d3204b7e669ff8046bfe55999a36a39896c08 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Thu, 8 Feb 2024 20:40:55 +0100 Subject: [PATCH 12/16] Use `transmute_unchecked` in `NonZero::new`. --- library/core/src/num/nonzero.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/library/core/src/num/nonzero.rs b/library/core/src/num/nonzero.rs index 193f2fa8731af..bf676cb22489e 100644 --- a/library/core/src/num/nonzero.rs +++ b/library/core/src/num/nonzero.rs @@ -8,7 +8,6 @@ use crate::intrinsics; use crate::marker::StructuralEq; use crate::marker::StructuralPartialEq; use crate::ops::{BitOr, BitOrAssign, Div, Neg, Rem}; -use crate::ptr; use crate::str::FromStr; use super::from_str_radix; @@ -91,13 +90,12 @@ where /// Creates a non-zero if the given value is not zero. #[stable(feature = "nonzero", since = "1.28.0")] #[rustc_const_stable(feature = "const_nonzero_int_methods", since = "1.47.0")] - #[rustc_allow_const_fn_unstable(const_refs_to_cell)] #[must_use] #[inline] pub const fn new(n: T) -> Option { // SAFETY: Memory layout optimization guarantees that `Option>` has // the same layout and size as `T`, with `0` representing `None`. - unsafe { ptr::read(ptr::addr_of!(n).cast()) } + unsafe { intrinsics::transmute_unchecked(n) } } /// Creates a non-zero without checking whether the value is non-zero. From 698a3c7adeed1213e1c3af73158566a85795a3c2 Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Thu, 8 Feb 2024 19:47:02 +0000 Subject: [PATCH 13/16] Don't ICE in ByMoveBody when coroutine is tainted --- compiler/rustc_mir_build/src/build/mod.rs | 36 +++++++++++++------ .../src/coroutine/by_move_body.rs | 7 ++-- .../async-closures/tainted-body.rs | 13 +++++++ .../async-closures/tainted-body.stderr | 9 +++++ 4 files changed, 53 insertions(+), 12 deletions(-) create mode 100644 tests/ui/async-await/async-closures/tainted-body.rs create mode 100644 tests/ui/async-await/async-closures/tainted-body.stderr diff --git a/compiler/rustc_mir_build/src/build/mod.rs b/compiler/rustc_mir_build/src/build/mod.rs index c24f2e9f53a84..2b1a9fef360c0 100644 --- a/compiler/rustc_mir_build/src/build/mod.rs +++ b/compiler/rustc_mir_build/src/build/mod.rs @@ -675,16 +675,32 @@ fn construct_error(tcx: TyCtxt<'_>, def_id: LocalDefId, guar: ErrorGuaranteed) - ))), ) } - ty::CoroutineClosure(did, _args) => { - // FIXME(async_closures): Recover the proper error signature - let inputs = tcx - .closure_user_provided_sig(did.expect_local()) - .value - .skip_binder() - .inputs(); - - let err = Ty::new_error(tcx, guar); - (inputs.iter().map(|_| err).collect(), err, None) + ty::CoroutineClosure(did, args) => { + let args = args.as_coroutine_closure(); + let sig = tcx.liberate_late_bound_regions( + def_id.to_def_id(), + args.coroutine_closure_sig(), + ); + let self_ty = match args.kind() { + ty::ClosureKind::Fn => { + Ty::new_imm_ref(tcx, tcx.lifetimes.re_erased, closure_ty) + } + ty::ClosureKind::FnMut => { + Ty::new_mut_ref(tcx, tcx.lifetimes.re_erased, closure_ty) + } + ty::ClosureKind::FnOnce => closure_ty, + }; + ( + [self_ty].into_iter().chain(sig.tupled_inputs_ty.tuple_fields()).collect(), + sig.to_coroutine( + tcx, + args.parent_args(), + args.kind_ty(), + tcx.coroutine_for_closure(*did), + Ty::new_error(tcx, guar), + ), + None, + ) } ty::Error(_) => (vec![closure_ty, closure_ty], closure_ty, None), kind => { diff --git a/compiler/rustc_mir_transform/src/coroutine/by_move_body.rs b/compiler/rustc_mir_transform/src/coroutine/by_move_body.rs index fcd4715b9e88c..e40f4520671bb 100644 --- a/compiler/rustc_mir_transform/src/coroutine/by_move_body.rs +++ b/compiler/rustc_mir_transform/src/coroutine/by_move_body.rs @@ -7,7 +7,7 @@ use rustc_data_structures::fx::FxIndexSet; use rustc_hir as hir; use rustc_middle::mir::visit::MutVisitor; use rustc_middle::mir::{self, dump_mir, MirPass}; -use rustc_middle::ty::{self, InstanceDef, Ty, TyCtxt}; +use rustc_middle::ty::{self, InstanceDef, Ty, TyCtxt, TypeVisitableExt}; use rustc_target::abi::FieldIdx; pub struct ByMoveBody; @@ -23,7 +23,10 @@ impl<'tcx> MirPass<'tcx> for ByMoveBody { return; }; let coroutine_ty = body.local_decls[ty::CAPTURE_STRUCT_LOCAL].ty; - let ty::Coroutine(_, args) = *coroutine_ty.kind() else { bug!() }; + if coroutine_ty.references_error() { + return; + } + let ty::Coroutine(_, args) = *coroutine_ty.kind() else { bug!("{body:#?}") }; let coroutine_kind = args.as_coroutine().kind_ty().to_opt_closure_kind().unwrap(); if coroutine_kind == ty::ClosureKind::FnOnce { diff --git a/tests/ui/async-await/async-closures/tainted-body.rs b/tests/ui/async-await/async-closures/tainted-body.rs new file mode 100644 index 0000000000000..62c28e7e58576 --- /dev/null +++ b/tests/ui/async-await/async-closures/tainted-body.rs @@ -0,0 +1,13 @@ +// edition:2021 + +#![feature(async_closure)] + +// Don't ICE in ByMove shim builder when MIR body is tainted by writeback errors + +fn main() { + let _ = async || { + used_fn(); + //~^ ERROR cannot find function `used_fn` in this scope + 0 + }; +} diff --git a/tests/ui/async-await/async-closures/tainted-body.stderr b/tests/ui/async-await/async-closures/tainted-body.stderr new file mode 100644 index 0000000000000..b06a896b81f52 --- /dev/null +++ b/tests/ui/async-await/async-closures/tainted-body.stderr @@ -0,0 +1,9 @@ +error[E0425]: cannot find function `used_fn` in this scope + --> $DIR/tainted-body.rs:9:9 + | +LL | used_fn(); + | ^^^^^^^ not found in this scope + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0425`. From e32c1ddc5274636c03697f180224f4fa6721f200 Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Fri, 9 Feb 2024 00:40:43 +0000 Subject: [PATCH 14/16] Don't ice in validation when error body is created --- compiler/rustc_const_eval/src/transform/validate.rs | 2 ++ tests/ui/mir/validate/error-body.rs | 9 +++++++++ tests/ui/mir/validate/error-body.stderr | 9 +++++++++ 3 files changed, 20 insertions(+) create mode 100644 tests/ui/mir/validate/error-body.rs create mode 100644 tests/ui/mir/validate/error-body.stderr diff --git a/compiler/rustc_const_eval/src/transform/validate.rs b/compiler/rustc_const_eval/src/transform/validate.rs index c4542aaa7b2fb..3b7b502d3d08a 100644 --- a/compiler/rustc_const_eval/src/transform/validate.rs +++ b/compiler/rustc_const_eval/src/transform/validate.rs @@ -60,6 +60,8 @@ impl<'tcx> MirPass<'tcx> for Validator { ty::Closure(..) => Abi::RustCall, ty::CoroutineClosure(..) => Abi::RustCall, ty::Coroutine(..) => Abi::Rust, + // No need to do MIR validation on error bodies + ty::Error(_) => return, _ => { span_bug!(body.span, "unexpected body ty: {:?} phase {:?}", body_ty, mir_phase) } diff --git a/tests/ui/mir/validate/error-body.rs b/tests/ui/mir/validate/error-body.rs new file mode 100644 index 0000000000000..5b2fbb0b04699 --- /dev/null +++ b/tests/ui/mir/validate/error-body.rs @@ -0,0 +1,9 @@ +// compile-flags: -Zvalidate-mir + +fn _test() { + let x = || 45; + missing(); + //~^ ERROR cannot find function `missing` in this scope +} + +fn main() {} diff --git a/tests/ui/mir/validate/error-body.stderr b/tests/ui/mir/validate/error-body.stderr new file mode 100644 index 0000000000000..1dfeaf0b7e2cb --- /dev/null +++ b/tests/ui/mir/validate/error-body.stderr @@ -0,0 +1,9 @@ +error[E0425]: cannot find function `missing` in this scope + --> $DIR/error-body.rs:5:5 + | +LL | missing(); + | ^^^^^^^ not found in this scope + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0425`. From 76197921079737fdd499e12016ac056674b5119f Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Fri, 9 Feb 2024 06:42:50 +1100 Subject: [PATCH 15/16] Fix `ErrorGuaranteed` unsoundness with stash/steal. When you stash an error, the error count is incremented. You can then use the non-zero error count to get an `ErrorGuaranteed`. You can then steal the error, which decrements the error count. You can then cancel the error. Example code: ``` fn unsound(dcx: &DiagCtxt) -> ErrorGuaranteed { let sp = rustc_span::DUMMY_SP; let k = rustc_errors::StashKey::Cycle; dcx.struct_err("bogus").stash(sp, k); // increment error count on stash let guar = dcx.has_errors().unwrap(); // ErrorGuaranteed from error count > 0 let err = dcx.steal_diagnostic(sp, k).unwrap(); // decrement error count on steal err.cancel(); // cancel error guar // ErrorGuaranteed with no error emitted! } ``` This commit fixes the problem in the simplest way: by not counting stashed errors in `DiagCtxt::{err_count,has_errors}`. However, just doing this without any other changes leads to over 40 ui test failures. Mostly because of uninteresting extra errors (many saying "type annotations needed" when type inference fails), and in a few cases, due to delayed bugs causing ICEs when no normal errors are printed. To fix these, this commit adds `DiagCtxt::stashed_err_count`, and uses it in three places alongside `DiagCtxt::{has_errors,err_count}`. It's dodgy to rely on it, because unlike `DiagCtxt::err_count` it can go up and down. But it's needed to preserve existing behaviour, and at least the three places that need it are now obvious. --- compiler/rustc_errors/src/lib.rs | 45 +++++++++++++--------- compiler/rustc_hir_typeck/src/writeback.rs | 14 ++++--- compiler/rustc_infer/src/infer/at.rs | 1 + compiler/rustc_infer/src/infer/mod.rs | 43 ++++++++++++--------- compiler/rustc_interface/src/passes.rs | 4 ++ 5 files changed, 65 insertions(+), 42 deletions(-) diff --git a/compiler/rustc_errors/src/lib.rs b/compiler/rustc_errors/src/lib.rs index ec5029e505f96..26ee2770d882e 100644 --- a/compiler/rustc_errors/src/lib.rs +++ b/compiler/rustc_errors/src/lib.rs @@ -429,6 +429,10 @@ struct DiagCtxtInner { /// The number of non-lint errors that have been emitted, including duplicates. err_count: usize, + /// The number of stashed errors. Unlike the other counts, this can go up + /// and down, so it doesn't guarantee anything. + stashed_err_count: usize, + /// The error count shown to the user at the end. deduplicated_err_count: usize, /// The warning count shown to the user at the end. @@ -598,6 +602,7 @@ impl DiagCtxt { flags: DiagCtxtFlags { can_emit_warnings: true, ..Default::default() }, lint_err_count: 0, err_count: 0, + stashed_err_count: 0, deduplicated_err_count: 0, deduplicated_warn_count: 0, has_printed: false, @@ -654,6 +659,7 @@ impl DiagCtxt { let mut inner = self.inner.borrow_mut(); inner.lint_err_count = 0; inner.err_count = 0; + inner.stashed_err_count = 0; inner.deduplicated_err_count = 0; inner.deduplicated_warn_count = 0; inner.has_printed = false; @@ -675,10 +681,8 @@ impl DiagCtxt { let key = (span.with_parent(None), key); if diag.is_error() { - if diag.is_lint.is_some() { - inner.lint_err_count += 1; - } else { - inner.err_count += 1; + if diag.is_lint.is_none() { + inner.stashed_err_count += 1; } } @@ -694,10 +698,8 @@ impl DiagCtxt { let key = (span.with_parent(None), key); let diag = inner.stashed_diagnostics.remove(&key)?; if diag.is_error() { - if diag.is_lint.is_some() { - inner.lint_err_count -= 1; - } else { - inner.err_count -= 1; + if diag.is_lint.is_none() { + inner.stashed_err_count -= 1; } } Some(DiagnosticBuilder::new_diagnostic(self, diag)) @@ -922,13 +924,22 @@ impl DiagCtxt { self.struct_bug(msg).emit() } - /// This excludes lint errors and delayed bugs. + /// This excludes lint errors, delayed bugs, and stashed errors. #[inline] pub fn err_count(&self) -> usize { self.inner.borrow().err_count } - /// This excludes lint errors and delayed bugs. + /// This excludes normal errors, lint errors and delayed bugs. Unless + /// absolutely necessary, avoid using this. It's dubious because stashed + /// errors can later be cancelled, so the presence of a stashed error at + /// some point of time doesn't guarantee anything -- there are no + /// `ErrorGuaranteed`s here. + pub fn stashed_err_count(&self) -> usize { + self.inner.borrow().stashed_err_count + } + + /// This excludes lint errors, delayed bugs, and stashed errors. pub fn has_errors(&self) -> Option { self.inner.borrow().has_errors().then(|| { // FIXME(nnethercote) find a way to store an `ErrorGuaranteed`. @@ -937,8 +948,8 @@ impl DiagCtxt { }) } - /// This excludes delayed bugs. Unless absolutely necessary, prefer - /// `has_errors` to this method. + /// This excludes delayed bugs and stashed errors. Unless absolutely + /// necessary, prefer `has_errors` to this method. pub fn has_errors_or_lint_errors(&self) -> Option { let inner = self.inner.borrow(); let result = inner.has_errors() || inner.lint_err_count > 0; @@ -949,8 +960,8 @@ impl DiagCtxt { }) } - /// Unless absolutely necessary, prefer `has_errors` or - /// `has_errors_or_lint_errors` to this method. + /// This excludes stashed errors. Unless absolutely necessary, prefer + /// `has_errors` or `has_errors_or_lint_errors` to this method. pub fn has_errors_or_lint_errors_or_delayed_bugs(&self) -> Option { let inner = self.inner.borrow(); let result = @@ -1224,10 +1235,8 @@ impl DiagCtxtInner { for (_, diag) in std::mem::take(&mut self.stashed_diagnostics).into_iter() { // Decrement the count tracking the stash; emitting will increment it. if diag.is_error() { - if diag.is_lint.is_some() { - self.lint_err_count -= 1; - } else { - self.err_count -= 1; + if diag.is_lint.is_none() { + self.stashed_err_count -= 1; } } else { // Unless they're forced, don't flush stashed warnings when diff --git a/compiler/rustc_hir_typeck/src/writeback.rs b/compiler/rustc_hir_typeck/src/writeback.rs index 3430a5fb00dc9..94f6c06157efe 100644 --- a/compiler/rustc_hir_typeck/src/writeback.rs +++ b/compiler/rustc_hir_typeck/src/writeback.rs @@ -753,10 +753,14 @@ impl<'cx, 'tcx> Resolver<'cx, 'tcx> { } fn report_error(&self, p: impl Into>) -> ErrorGuaranteed { - match self.fcx.dcx().has_errors() { - Some(e) => e, - None => self - .fcx + if let Some(guar) = self.fcx.dcx().has_errors() { + guar + } else if self.fcx.dcx().stashed_err_count() > 0 { + // Without this case we sometimes get uninteresting and extraneous + // "type annotations needed" errors. + self.fcx.dcx().delayed_bug("error in Resolver") + } else { + self.fcx .err_ctxt() .emit_inference_failure_err( self.fcx.tcx.hir().body_owner_def_id(self.body.id()), @@ -765,7 +769,7 @@ impl<'cx, 'tcx> Resolver<'cx, 'tcx> { E0282, false, ) - .emit(), + .emit() } } diff --git a/compiler/rustc_infer/src/infer/at.rs b/compiler/rustc_infer/src/infer/at.rs index 0f1af81d9f04c..859593e119457 100644 --- a/compiler/rustc_infer/src/infer/at.rs +++ b/compiler/rustc_infer/src/infer/at.rs @@ -87,6 +87,7 @@ impl<'tcx> InferCtxt<'tcx> { reported_signature_mismatch: self.reported_signature_mismatch.clone(), tainted_by_errors: self.tainted_by_errors.clone(), err_count_on_creation: self.err_count_on_creation, + stashed_err_count_on_creation: self.stashed_err_count_on_creation, universe: self.universe.clone(), intercrate, next_trait_solver: self.next_trait_solver, diff --git a/compiler/rustc_infer/src/infer/mod.rs b/compiler/rustc_infer/src/infer/mod.rs index 2d8b47a9cc057..20bd0a6b69ab5 100644 --- a/compiler/rustc_infer/src/infer/mod.rs +++ b/compiler/rustc_infer/src/infer/mod.rs @@ -306,6 +306,12 @@ pub struct InferCtxt<'tcx> { // FIXME(matthewjasper) Merge into `tainted_by_errors` err_count_on_creation: usize, + /// Track how many errors were stashed when this infcx is created. + /// Used for the same purpose as `err_count_on_creation`, even + /// though it's weaker because the count can go up and down. + // FIXME(matthewjasper) Merge into `tainted_by_errors` + stashed_err_count_on_creation: usize, + /// What is the innermost universe we have created? Starts out as /// `UniverseIndex::root()` but grows from there as we enter /// universal quantifiers. @@ -711,6 +717,7 @@ impl<'tcx> InferCtxtBuilder<'tcx> { reported_signature_mismatch: Default::default(), tainted_by_errors: Cell::new(None), err_count_on_creation: tcx.dcx().err_count(), + stashed_err_count_on_creation: tcx.dcx().stashed_err_count(), universe: Cell::new(ty::UniverseIndex::ROOT), intercrate, next_trait_solver, @@ -1261,26 +1268,24 @@ impl<'tcx> InferCtxt<'tcx> { /// inference variables, regionck errors). #[must_use = "this method does not have any side effects"] pub fn tainted_by_errors(&self) -> Option { - debug!( - "is_tainted_by_errors(err_count={}, err_count_on_creation={}, \ - tainted_by_errors={})", - self.dcx().err_count(), - self.err_count_on_creation, - self.tainted_by_errors.get().is_some() - ); - - if let Some(e) = self.tainted_by_errors.get() { - return Some(e); - } - - if self.dcx().err_count() > self.err_count_on_creation { - // errors reported since this infcx was made - let e = self.dcx().has_errors().unwrap(); - self.set_tainted_by_errors(e); - return Some(e); + if let Some(guar) = self.tainted_by_errors.get() { + Some(guar) + } else if self.dcx().err_count() > self.err_count_on_creation { + // Errors reported since this infcx was made. + let guar = self.dcx().has_errors().unwrap(); + self.set_tainted_by_errors(guar); + Some(guar) + } else if self.dcx().stashed_err_count() > self.stashed_err_count_on_creation { + // Errors stashed since this infcx was made. Not entirely reliable + // because the count of stashed errors can go down. But without + // this case we get a moderate number of uninteresting and + // extraneous "type annotations needed" errors. + let guar = self.dcx().delayed_bug("tainted_by_errors: stashed bug awaiting emission"); + self.set_tainted_by_errors(guar); + Some(guar) + } else { + None } - - None } /// Set the "tainted by errors" flag to true. We call this when we diff --git a/compiler/rustc_interface/src/passes.rs b/compiler/rustc_interface/src/passes.rs index 9795640412069..50b2bf7da153e 100644 --- a/compiler/rustc_interface/src/passes.rs +++ b/compiler/rustc_interface/src/passes.rs @@ -778,6 +778,10 @@ fn analysis(tcx: TyCtxt<'_>, (): ()) -> Result<()> { // kindck is gone now). -nmatsakis if let Some(reported) = sess.dcx().has_errors() { return Err(reported); + } else if sess.dcx().stashed_err_count() > 0 { + // Without this case we sometimes get delayed bug ICEs and I don't + // understand why. -nnethercote + return Err(sess.dcx().delayed_bug("some stashed error is waiting for use")); } sess.time("misc_checking_3", || { From 575e0aa592757cef5456e38be7d44126a69bf162 Mon Sep 17 00:00:00 2001 From: Nicolas Roche Date: Fri, 9 Feb 2024 09:07:49 +0100 Subject: [PATCH 16/16] Startup objects disappearing from sysroot When launching tests with --keep-stage option, startup objects such as rsbegin.o an rsend.o may disappear from the corresponding stageN compiler. Fix issue #120784 --- src/bootstrap/src/core/build_steps/compile.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/bootstrap/src/core/build_steps/compile.rs b/src/bootstrap/src/core/build_steps/compile.rs index 73f29d6bb6f45..27b1d311864f3 100644 --- a/src/bootstrap/src/core/build_steps/compile.rs +++ b/src/bootstrap/src/core/build_steps/compile.rs @@ -173,6 +173,8 @@ impl Step for Std { { builder.info("WARNING: Using a potentially old libstd. This may not behave well."); + builder.ensure(StartupObjects { compiler, target }); + self.copy_extra_objects(builder, &compiler, target); builder.ensure(StdLink::from_std(self, compiler));