Auto merge of #121327 - Nilstrieb:rollup-zxcwwwy, r=Nilstrieb

Rollup of 10 pull requests

Successful merges:

 - #120716 (Change leak check and suspicious auto trait lint warning messages)
 - #121195 (unstable-book: Separate testing and production sanitizers)
 - #121205 (Merge `CompilerError::CompilationFailed` and `CompilerError::ICE`.)
 - #121233 (Move the extra directives for `Mode::CoverageRun` into `iter_header`)
 - #121256 (Allow AST and HIR visitors to return `ControlFlow`)
 - #121307 (Drive-by `DUMMY_SP` -> `Span` and fmt changes)
 - #121308 (Add regression test for #103369)
 - #121310 (Remove an old hack for rustdoc)
 - #121311 (Make `is_nonoverlapping` `#[inline]`)
 - #121319 (return `ty::Error` when equating `ty::Error`)

r? `@ghost`
`@rustbot` modify labels: rollup
This commit is contained in:
bors 2024-02-20 06:56:41 +00:00
commit 5af2130440
69 changed files with 1289 additions and 1523 deletions

View file

@ -12,10 +12,12 @@
#![allow(internal_features)]
#![feature(rustdoc_internals)]
#![feature(associated_type_bounds)]
#![feature(associated_type_defaults)]
#![feature(box_patterns)]
#![feature(if_let_guard)]
#![feature(let_chains)]
#![cfg_attr(bootstrap, feature(min_specialization))]
#![feature(never_type)]
#![feature(negative_impls)]
#![feature(stmt_expr_attributes)]

File diff suppressed because it is too large Load diff

View file

@ -100,7 +100,7 @@ pub(super) fn normalize_and_prove_instantiated_predicates(
locations: Locations,
) {
for (predicate, span) in instantiated_predicates {
debug!(?predicate);
debug!(?span, ?predicate);
let category = ConstraintCategory::Predicate(span);
let predicate = self.normalize_with_category(predicate, locations, category);
self.prove_predicate(predicate, locations, category);

View file

@ -8,7 +8,7 @@
use rustc_middle::traits::query::NoSolution;
use rustc_middle::traits::ObligationCause;
use rustc_middle::ty::{self, GenericArgKind, Ty, TyCtxt, TypeFoldable, TypeVisitableExt};
use rustc_span::{Span, DUMMY_SP};
use rustc_span::Span;
use rustc_trait_selection::solve::deeply_normalize;
use rustc_trait_selection::traits::query::type_op::custom::CustomTypeOp;
use rustc_trait_selection::traits::query::type_op::{TypeOp, TypeOpOutput};
@ -183,7 +183,7 @@ fn convert(
// we don't actually use this for anything, but
// the `TypeOutlives` code needs an origin.
let origin = infer::RelateParamBound(DUMMY_SP, t1, None);
let origin = infer::RelateParamBound(self.span, t1, None);
TypeOutlives::new(
&mut *self,

View file

@ -10,7 +10,7 @@
use rustc_middle::traits::query::OutlivesBound;
use rustc_middle::traits::ObligationCause;
use rustc_middle::ty::{self, RegionVid, Ty, TypeVisitableExt};
use rustc_span::{ErrorGuaranteed, DUMMY_SP};
use rustc_span::{ErrorGuaranteed, Span};
use rustc_trait_selection::solve::deeply_normalize;
use rustc_trait_selection::traits::error_reporting::TypeErrCtxtExt;
use rustc_trait_selection::traits::query::type_op::{self, TypeOp};
@ -269,7 +269,7 @@ pub(crate) fn create(mut self) -> CreateResult<'tcx> {
debug!("build: input_or_output={:?}", ty);
// We add implied bounds from both the unnormalized and normalized ty.
// See issue #87748
let constraints_unnorm = self.add_implied_bounds(ty);
let constraints_unnorm = self.add_implied_bounds(ty, span);
if let Some(c) = constraints_unnorm {
constraints.push(c)
}
@ -299,7 +299,7 @@ pub(crate) fn create(mut self) -> CreateResult<'tcx> {
// ```
// Both &Self::Bar and &() are WF
if ty != norm_ty {
let constraints_norm = self.add_implied_bounds(norm_ty);
let constraints_norm = self.add_implied_bounds(norm_ty, span);
if let Some(c) = constraints_norm {
constraints.push(c)
}
@ -323,7 +323,7 @@ pub(crate) fn create(mut self) -> CreateResult<'tcx> {
// We currently add implied bounds from the normalized ty only.
// This is more conservative and matches wfcheck behavior.
let c = self.add_implied_bounds(norm_ty);
let c = self.add_implied_bounds(norm_ty, span);
constraints.extend(c);
}
}
@ -361,11 +361,15 @@ pub(crate) fn create(mut self) -> CreateResult<'tcx> {
/// the same time, compute and add any implied bounds that come
/// from this local.
#[instrument(level = "debug", skip(self))]
fn add_implied_bounds(&mut self, ty: Ty<'tcx>) -> Option<&'tcx QueryRegionConstraints<'tcx>> {
fn add_implied_bounds(
&mut self,
ty: Ty<'tcx>,
span: Span,
) -> Option<&'tcx QueryRegionConstraints<'tcx>> {
let TypeOpOutput { output: bounds, constraints, .. } = self
.param_env
.and(type_op::implied_outlives_bounds::ImpliedOutlivesBounds { ty })
.fully_perform(self.infcx, DUMMY_SP)
.fully_perform(self.infcx, span)
.map_err(|_: ErrorGuaranteed| debug!("failed to compute implied bounds {:?}", ty))
.ok()?;
debug!(?bounds, ?constraints);

View file

@ -37,7 +37,7 @@
use rustc_span::def_id::CRATE_DEF_ID;
use rustc_span::source_map::Spanned;
use rustc_span::symbol::sym;
use rustc_span::{Span, DUMMY_SP};
use rustc_span::Span;
use rustc_target::abi::{FieldIdx, FIRST_VARIANT};
use rustc_trait_selection::traits::query::type_op::custom::scrape_region_constraints;
use rustc_trait_selection::traits::query::type_op::custom::CustomTypeOp;
@ -1014,7 +1014,7 @@ fn new(
) -> Self {
let mut checker = Self {
infcx,
last_span: DUMMY_SP,
last_span: body.span,
body,
user_type_annotations: &body.user_type_annotations,
param_env,
@ -2766,7 +2766,7 @@ fn prove_closure_bounds(
self.param_env,
self.known_type_outlives_obligations,
locations,
DUMMY_SP, // irrelevant; will be overridden.
self.body.span, // irrelevant; will be overridden.
ConstraintCategory::Boring, // same as above.
self.borrowck_context.constraints,
)

View file

@ -96,7 +96,7 @@ pub fn visit_attrs(&mut self, f: impl FnOnce(&mut AttrVec)) {
}
}
pub fn visit_with<'a, V: Visitor<'a>>(&'a self, visitor: &mut V) {
pub fn visit_with<'a, V: Visitor<'a>>(&'a self, visitor: &mut V) -> V::Result {
match self {
Annotatable::Item(item) => visitor.visit_item(item),
Annotatable::TraitItem(item) => visitor.visit_assoc_item(item, AssocCtxt::Trait),

View file

@ -14,7 +14,8 @@
use rustc_ast::ptr::P;
use rustc_ast::token::{self, Delimiter};
use rustc_ast::tokenstream::TokenStream;
use rustc_ast::visit::{self, AssocCtxt, Visitor};
use rustc_ast::visit::{self, AssocCtxt, Visitor, VisitorResult};
use rustc_ast::{try_visit, walk_list};
use rustc_ast::{AssocItemKind, AstNodeWrapper, AttrArgs, AttrStyle, AttrVec, ExprKind};
use rustc_ast::{ForeignItemKind, HasAttrs, HasNodeId};
use rustc_ast::{Inline, ItemKind, MacStmtStyle, MetaItemKind, ModKind};
@ -143,16 +144,15 @@ pub fn mut_visit_with<F: MutVisitor>(&mut self, vis: &mut F) {
}
}
pub fn visit_with<'a, V: Visitor<'a>>(&'a self, visitor: &mut V) {
pub fn visit_with<'a, V: Visitor<'a>>(&'a self, visitor: &mut V) -> V::Result {
match self {
AstFragment::OptExpr(Some(expr)) => visitor.visit_expr(expr),
AstFragment::OptExpr(Some(expr)) => try_visit!(visitor.visit_expr(expr)),
AstFragment::OptExpr(None) => {}
AstFragment::MethodReceiverExpr(expr) => visitor.visit_method_receiver_expr(expr),
$($(AstFragment::$Kind(ast) => visitor.$visit_ast(ast),)?)*
$($(AstFragment::$Kind(ast) => for ast_elt in &ast[..] {
visitor.$visit_ast_elt(ast_elt, $($args)*);
})?)*
AstFragment::MethodReceiverExpr(expr) => try_visit!(visitor.visit_method_receiver_expr(expr)),
$($(AstFragment::$Kind(ast) => try_visit!(visitor.$visit_ast(ast)),)?)*
$($(AstFragment::$Kind(ast) => walk_list!(visitor, $visit_ast_elt, &ast[..], $($args)*),)?)*
}
V::Result::output()
}
}

File diff suppressed because it is too large Load diff

View file

@ -1,20 +1,12 @@
//! Orphan checker: every impl either implements a trait defined in this
//! crate or pertains to a type defined in this crate.
use rustc_data_structures::fx::FxHashSet;
use rustc_errors::{DelayDm, ErrorGuaranteed};
use rustc_errors::ErrorGuaranteed;
use rustc_hir as hir;
use rustc_middle::ty::util::CheckRegions;
use rustc_middle::ty::GenericArgs;
use rustc_middle::ty::{
self, AliasKind, ImplPolarity, Ty, TyCtxt, TypeSuperVisitable, TypeVisitable, TypeVisitableExt,
TypeVisitor,
};
use rustc_session::lint;
use rustc_span::def_id::{DefId, LocalDefId};
use rustc_middle::ty::{self, AliasKind, Ty, TyCtxt, TypeVisitableExt};
use rustc_span::def_id::LocalDefId;
use rustc_span::Span;
use rustc_trait_selection::traits;
use std::ops::ControlFlow;
use crate::errors;
@ -26,30 +18,17 @@ pub(crate) fn orphan_check_impl(
let trait_ref = tcx.impl_trait_ref(impl_def_id).unwrap().instantiate_identity();
trait_ref.error_reported()?;
let ret = do_orphan_check_impl(tcx, trait_ref, impl_def_id);
if tcx.trait_is_auto(trait_ref.def_id) {
lint_auto_trait_impl(tcx, trait_ref, impl_def_id);
}
ret
}
fn do_orphan_check_impl<'tcx>(
tcx: TyCtxt<'tcx>,
trait_ref: ty::TraitRef<'tcx>,
def_id: LocalDefId,
) -> Result<(), ErrorGuaranteed> {
let trait_def_id = trait_ref.def_id;
match traits::orphan_check(tcx, def_id.to_def_id()) {
match traits::orphan_check(tcx, impl_def_id.to_def_id()) {
Ok(()) => {}
Err(err) => {
let item = tcx.hir().expect_item(def_id);
let item = tcx.hir().expect_item(impl_def_id);
let hir::ItemKind::Impl(impl_) = item.kind else {
bug!("{:?} is not an impl: {:?}", def_id, item);
bug!("{:?} is not an impl: {:?}", impl_def_id, item);
};
let tr = impl_.of_trait.as_ref().unwrap();
let sp = tcx.def_span(def_id);
let sp = tcx.def_span(impl_def_id);
emit_orphan_check_error(
tcx,
@ -193,7 +172,7 @@ enum NonlocalImpl {
// impl<T> AutoTrait for T {}
// impl<T: ?Sized> AutoTrait for T {}
ty::Param(..) => (
if self_ty.is_sized(tcx, tcx.param_env(def_id)) {
if self_ty.is_sized(tcx, tcx.param_env(impl_def_id)) {
LocalImpl::Allow
} else {
LocalImpl::Disallow { problematic_kind: "generic type" }
@ -250,7 +229,7 @@ enum NonlocalImpl {
| ty::Bound(..)
| ty::Placeholder(..)
| ty::Infer(..) => {
let sp = tcx.def_span(def_id);
let sp = tcx.def_span(impl_def_id);
span_bug!(sp, "weird self type for autotrait impl")
}
@ -262,7 +241,7 @@ enum NonlocalImpl {
LocalImpl::Allow => {}
LocalImpl::Disallow { problematic_kind } => {
return Err(tcx.dcx().emit_err(errors::TraitsWithDefaultImpl {
span: tcx.def_span(def_id),
span: tcx.def_span(impl_def_id),
traits: tcx.def_path_str(trait_def_id),
problematic_kind,
self_ty,
@ -274,13 +253,13 @@ enum NonlocalImpl {
NonlocalImpl::Allow => {}
NonlocalImpl::DisallowBecauseNonlocal => {
return Err(tcx.dcx().emit_err(errors::CrossCrateTraitsDefined {
span: tcx.def_span(def_id),
span: tcx.def_span(impl_def_id),
traits: tcx.def_path_str(trait_def_id),
}));
}
NonlocalImpl::DisallowOther => {
return Err(tcx.dcx().emit_err(errors::CrossCrateTraits {
span: tcx.def_span(def_id),
span: tcx.def_span(impl_def_id),
traits: tcx.def_path_str(trait_def_id),
self_ty,
}));
@ -445,146 +424,3 @@ fn push_to_foreign_or_name<'tcx>(
}
})
}
/// Lint impls of auto traits if they are likely to have
/// unsound or surprising effects on auto impls.
fn lint_auto_trait_impl<'tcx>(
tcx: TyCtxt<'tcx>,
trait_ref: ty::TraitRef<'tcx>,
impl_def_id: LocalDefId,
) {
if trait_ref.args.len() != 1 {
tcx.dcx().span_delayed_bug(
tcx.def_span(impl_def_id),
"auto traits cannot have generic parameters",
);
return;
}
let self_ty = trait_ref.self_ty();
let (self_type_did, args) = match self_ty.kind() {
ty::Adt(def, args) => (def.did(), args),
_ => {
// FIXME: should also lint for stuff like `&i32` but
// considering that auto traits are unstable, that
// isn't too important for now as this only affects
// crates using `nightly`, and std.
return;
}
};
// Impls which completely cover a given root type are fine as they
// disable auto impls entirely. So only lint if the args
// are not a permutation of the identity args.
let Err(arg) = tcx.uses_unique_generic_params(args, CheckRegions::No) else {
// ok
return;
};
// Ideally:
//
// - compute the requirements for the auto impl candidate
// - check whether these are implied by the non covering impls
// - if not, emit the lint
//
// What we do here is a bit simpler:
//
// - badly check if an auto impl candidate definitely does not apply
// for the given simplified type
// - if so, do not lint
if fast_reject_auto_impl(tcx, trait_ref.def_id, self_ty) {
// ok
return;
}
tcx.node_span_lint(
lint::builtin::SUSPICIOUS_AUTO_TRAIT_IMPLS,
tcx.local_def_id_to_hir_id(impl_def_id),
tcx.def_span(impl_def_id),
DelayDm(|| {
format!(
"cross-crate traits with a default impl, like `{}`, \
should not be specialized",
tcx.def_path_str(trait_ref.def_id),
)
}),
|lint| {
let item_span = tcx.def_span(self_type_did);
let self_descr = tcx.def_descr(self_type_did);
match arg {
ty::util::NotUniqueParam::DuplicateParam(arg) => {
lint.note(format!("`{arg}` is mentioned multiple times"));
}
ty::util::NotUniqueParam::NotParam(arg) => {
lint.note(format!("`{arg}` is not a generic parameter"));
}
}
lint.span_note(
item_span,
format!(
"try using the same sequence of generic parameters as the {self_descr} definition",
),
);
},
);
}
fn fast_reject_auto_impl<'tcx>(tcx: TyCtxt<'tcx>, trait_def_id: DefId, self_ty: Ty<'tcx>) -> bool {
struct DisableAutoTraitVisitor<'tcx> {
tcx: TyCtxt<'tcx>,
trait_def_id: DefId,
self_ty_root: Ty<'tcx>,
seen: FxHashSet<DefId>,
}
impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for DisableAutoTraitVisitor<'tcx> {
type BreakTy = ();
fn visit_ty(&mut self, ty: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
let tcx = self.tcx;
if ty != self.self_ty_root {
for impl_def_id in tcx.non_blanket_impls_for_ty(self.trait_def_id, ty) {
match tcx.impl_polarity(impl_def_id) {
ImplPolarity::Negative => return ControlFlow::Break(()),
ImplPolarity::Reservation => {}
// FIXME(@lcnr): That's probably not good enough, idk
//
// We might just want to take the rustdoc code and somehow avoid
// explicit impls for `Self`.
ImplPolarity::Positive => return ControlFlow::Continue(()),
}
}
}
match ty.kind() {
ty::Adt(def, args) if def.is_phantom_data() => args.visit_with(self),
ty::Adt(def, args) => {
// @lcnr: This is the only place where cycles can happen. We avoid this
// by only visiting each `DefId` once.
//
// This will be is incorrect in subtle cases, but I don't care :)
if self.seen.insert(def.did()) {
for ty in def.all_fields().map(|field| field.ty(tcx, args)) {
ty.visit_with(self)?;
}
}
ControlFlow::Continue(())
}
_ => ty.super_visit_with(self),
}
}
}
let self_ty_root = match self_ty.kind() {
ty::Adt(def, _) => Ty::new_adt(tcx, *def, GenericArgs::identity_for_item(tcx, def.did())),
_ => unimplemented!("unexpected self ty {:?}", self_ty),
};
self_ty_root
.visit_with(&mut DisableAutoTraitVisitor {
tcx,
self_ty_root,
trait_def_id,
seen: FxHashSet::default(),
})
.is_break()
}

View file

@ -1630,7 +1630,7 @@ fn early_bound_lifetimes_from_generics<'a, 'tcx: 'a>(
#[instrument(level = "debug", skip(tcx))]
fn predicates_defined_on(tcx: TyCtxt<'_>, def_id: DefId) -> ty::GenericPredicates<'_> {
let mut result = tcx.explicit_predicates_of(def_id);
debug!("predicates_defined_on: explicit_predicates_of({:?}) = {:?}", def_id, result,);
debug!("predicates_defined_on: explicit_predicates_of({:?}) = {:?}", def_id, result);
let inferred_outlives = tcx.inferred_outlives_of(def_id);
if !inferred_outlives.is_empty() {
debug!(

View file

@ -405,7 +405,7 @@ fn query_response_instantiation<R>(
/// will instantiate fresh inference variables for each canonical
/// variable instead. Therefore, the result of this method must be
/// properly unified
#[instrument(level = "debug", skip(self, cause, param_env))]
#[instrument(level = "debug", skip(self, param_env))]
fn query_response_instantiation_guess<R>(
&self,
cause: &ObligationCause<'tcx>,

View file

@ -90,6 +90,11 @@ fn tys(&mut self, a: Ty<'tcx>, b: Ty<'tcx>) -> RelateResult<'tcx, Ty<'tcx>> {
infcx.instantiate_ty_var(self, !self.a_is_expected, b_vid, ty::Invariant, a)?;
}
(&ty::Error(e), _) | (_, &ty::Error(e)) => {
infcx.set_tainted_by_errors(e);
return Ok(Ty::new_error(self.tcx(), e));
}
(
&ty::Alias(ty::Opaque, ty::AliasTy { def_id: a_def_id, .. }),
&ty::Alias(ty::Opaque, ty::AliasTy { def_id: b_def_id, .. }),

View file

@ -524,6 +524,11 @@ macro_rules! add_lint_group {
"no longer needed, see RFC #3535 \
<https://rust-lang.github.io/rfcs/3535-constants-in-patterns.html> for more information",
);
store.register_removed(
"suspicious_auto_trait_impls",
"no longer needed, see #93367 \
<https://github.com/rust-lang/rust/issues/93367> for more information",
);
}
fn register_internals(store: &mut LintStore) {

View file

@ -90,7 +90,6 @@
SOFT_UNSTABLE,
STABLE_FEATURES,
STATIC_MUT_REFS,
SUSPICIOUS_AUTO_TRAIT_IMPLS,
TEST_UNSTABLE_LINT,
TEXT_DIRECTION_CODEPOINT_IN_COMMENT,
TRIVIAL_CASTS,
@ -1503,7 +1502,7 @@
Warn,
"distinct impls distinguished only by the leak-check code",
@future_incompatible = FutureIncompatibleInfo {
reason: FutureIncompatibilityReason::FutureReleaseErrorDontReportInDeps,
reason: FutureIncompatibilityReason::Custom("the behavior may change in a future release"),
reference: "issue #56105 <https://github.com/rust-lang/rust/issues/56105>",
};
}
@ -4032,40 +4031,6 @@
"duplicated attribute"
}
declare_lint! {
/// The `suspicious_auto_trait_impls` lint checks for potentially incorrect
/// implementations of auto traits.
///
/// ### Example
///
/// ```rust
/// struct Foo<T>(T);
///
/// unsafe impl<T> Send for Foo<*const T> {}
/// ```
///
/// {{produces}}
///
/// ### Explanation
///
/// A type can implement auto traits, e.g. `Send`, `Sync` and `Unpin`,
/// in two different ways: either by writing an explicit impl or if
/// all fields of the type implement that auto trait.
///
/// The compiler disables the automatic implementation if an explicit one
/// exists for given type constructor. The exact rules governing this
/// were previously unsound, quite subtle, and have been recently modified.
/// This change caused the automatic implementation to be disabled in more
/// cases, potentially breaking some code.
pub SUSPICIOUS_AUTO_TRAIT_IMPLS,
Warn,
"the rules governing auto traits have recently changed resulting in potential breakage",
@future_incompatible = FutureIncompatibleInfo {
reason: FutureIncompatibilityReason::FutureReleaseSemanticsChange,
reference: "issue #93367 <https://github.com/rust-lang/rust/issues/93367>",
};
}
declare_lint! {
/// The `deprecated_where_clause_location` lint detects when a where clause in front of the equals
/// in an associated type.

View file

@ -3,6 +3,8 @@
use crate::query::LocalCrate;
use crate::ty::TyCtxt;
use rustc_ast as ast;
use rustc_ast::visit::VisitorResult;
use rustc_ast::walk_list;
use rustc_data_structures::fingerprint::Fingerprint;
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
use rustc_data_structures::svh::Svh;
@ -431,23 +433,28 @@ pub fn get_module(self, module: LocalModDefId) -> (&'hir Mod<'hir>, Span, HirId)
}
/// Walks the contents of the local crate. See also `visit_all_item_likes_in_crate`.
pub fn walk_toplevel_module(self, visitor: &mut impl Visitor<'hir>) {
pub fn walk_toplevel_module<V>(self, visitor: &mut V) -> V::Result
where
V: Visitor<'hir>,
{
let (top_mod, span, hir_id) = self.get_module(LocalModDefId::CRATE_DEF_ID);
visitor.visit_mod(top_mod, span, hir_id);
visitor.visit_mod(top_mod, span, hir_id)
}
/// Walks the attributes in a crate.
pub fn walk_attributes(self, visitor: &mut impl Visitor<'hir>) {
pub fn walk_attributes<V>(self, visitor: &mut V) -> V::Result
where
V: Visitor<'hir>,
{
let krate = self.krate();
for info in krate.owners.iter() {
if let MaybeOwner::Owner(info) = info {
for attrs in info.attrs.map.values() {
for a in *attrs {
visitor.visit_attribute(a)
}
walk_list!(visitor, visit_attribute, *attrs);
}
}
}
V::Result::output()
}
/// Visits all item-likes in the crate in some deterministic (but unspecified) order. If you
@ -460,52 +467,38 @@ pub fn walk_attributes(self, visitor: &mut impl Visitor<'hir>) {
/// provided by `tcx.hir_crate_items(())`.
///
/// Please see the notes in `intravisit.rs` for more information.
pub fn visit_all_item_likes_in_crate<V>(self, visitor: &mut V)
pub fn visit_all_item_likes_in_crate<V>(self, visitor: &mut V) -> V::Result
where
V: Visitor<'hir>,
{
let krate = self.tcx.hir_crate_items(());
for id in krate.items() {
visitor.visit_item(self.item(id));
}
for id in krate.trait_items() {
visitor.visit_trait_item(self.trait_item(id));
}
for id in krate.impl_items() {
visitor.visit_impl_item(self.impl_item(id));
}
for id in krate.foreign_items() {
visitor.visit_foreign_item(self.foreign_item(id));
}
walk_list!(visitor, visit_item, krate.items().map(|id| self.item(id)));
walk_list!(visitor, visit_trait_item, krate.trait_items().map(|id| self.trait_item(id)));
walk_list!(visitor, visit_impl_item, krate.impl_items().map(|id| self.impl_item(id)));
walk_list!(
visitor,
visit_foreign_item,
krate.foreign_items().map(|id| self.foreign_item(id))
);
V::Result::output()
}
/// This method is the equivalent of `visit_all_item_likes_in_crate` but restricted to
/// item-likes in a single module.
pub fn visit_item_likes_in_module<V>(self, module: LocalModDefId, visitor: &mut V)
pub fn visit_item_likes_in_module<V>(self, module: LocalModDefId, visitor: &mut V) -> V::Result
where
V: Visitor<'hir>,
{
let module = self.tcx.hir_module_items(module);
for id in module.items() {
visitor.visit_item(self.item(id));
}
for id in module.trait_items() {
visitor.visit_trait_item(self.trait_item(id));
}
for id in module.impl_items() {
visitor.visit_impl_item(self.impl_item(id));
}
for id in module.foreign_items() {
visitor.visit_foreign_item(self.foreign_item(id));
}
walk_list!(visitor, visit_item, module.items().map(|id| self.item(id)));
walk_list!(visitor, visit_trait_item, module.trait_items().map(|id| self.trait_item(id)));
walk_list!(visitor, visit_impl_item, module.impl_items().map(|id| self.impl_item(id)));
walk_list!(
visitor,
visit_foreign_item,
module.foreign_items().map(|id| self.foreign_item(id))
);
V::Result::output()
}
pub fn for_each_module(self, mut f: impl FnMut(LocalModDefId)) {

View file

@ -347,8 +347,14 @@ pub fn run(&mut self) -> Result<C, CompilerError<B>> {
Err(CompilerError::Interrupted(value))
}
(Ok(Ok(_)), None) => Err(CompilerError::Skipped),
(Ok(Err(_)), _) => Err(CompilerError::CompilationFailed),
(Err(_), _) => Err(CompilerError::ICE),
// Two cases here:
// - `run` finished normally and returned `Err`
// - `run` panicked with `FatalErr`
// You might think that normal compile errors cause the former, and
// ICEs cause the latter. But some normal compiler errors also cause
// the latter. So we can't meaningfully distinguish them, and group
// them together.
(Ok(Err(_)), _) | (Err(_), _) => Err(CompilerError::Failed),
}
}
}

View file

@ -62,9 +62,10 @@ fn implied_outlives_bounds<'a, 'tcx>(
};
let mut constraints = QueryRegionConstraints::default();
let span = infcx.tcx.def_span(body_id);
let Ok(InferOk { value: mut bounds, obligations }) = infcx
.instantiate_nll_query_response_and_region_obligations(
&ObligationCause::dummy(),
&ObligationCause::dummy_with_span(span),
param_env,
&canonical_var_values,
canonical_result,
@ -80,8 +81,6 @@ fn implied_outlives_bounds<'a, 'tcx>(
bounds.retain(|bound| !bound.has_placeholders());
if !constraints.is_empty() {
let span = infcx.tcx.def_span(body_id);
debug!(?constraints);
if !constraints.member_constraints.is_empty() {
span_bug!(span, "{:#?}", constraints.member_constraints);

View file

@ -15,10 +15,8 @@ macro_rules! error {
/// An error type used to represent an error that has already been reported by the compiler.
#[derive(Clone, Copy, PartialEq, Eq)]
pub enum CompilerError<T> {
/// Internal compiler error (I.e.: Compiler crashed).
ICE,
/// Compilation failed.
CompilationFailed,
/// Compilation failed, either due to normal errors or ICE.
Failed,
/// Compilation was interrupted.
Interrupted(T),
/// Compilation skipped. This happens when users invoke rustc to retrieve information such as
@ -54,8 +52,7 @@ impl<T> Display for CompilerError<T>
{
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
match self {
CompilerError::ICE => write!(f, "Internal Compiler Error"),
CompilerError::CompilationFailed => write!(f, "Compilation Failed"),
CompilerError::Failed => write!(f, "Compilation Failed"),
CompilerError::Interrupted(reason) => write!(f, "Compilation Interrupted: {reason}"),
CompilerError::Skipped => write!(f, "Compilation Skipped"),
}
@ -68,8 +65,7 @@ impl<T> Debug for CompilerError<T>
{
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
match self {
CompilerError::ICE => write!(f, "Internal Compiler Error"),
CompilerError::CompilationFailed => write!(f, "Compilation Failed"),
CompilerError::Failed => write!(f, "Compilation Failed"),
CompilerError::Interrupted(reason) => write!(f, "Compilation Interrupted: {reason:?}"),
CompilerError::Skipped => write!(f, "Compilation Skipped"),
}

View file

@ -2693,6 +2693,7 @@ pub(crate) fn is_valid_allocation_size(size: usize, len: usize) -> bool {
/// Checks whether the regions of memory starting at `src` and `dst` of size
/// `count * size` do *not* overlap.
#[inline]
pub(crate) fn is_nonoverlapping(src: *const (), dst: *const (), size: usize, count: usize) -> bool {
let src_usize = src.addr();
let dst_usize = dst.addr();

View file

@ -26,8 +26,7 @@
/// unwrapping the `BufReader<R>` with [`BufReader::into_inner`] can also cause
/// data loss.
///
// HACK(#78696): can't use `crate` for associated items
/// [`TcpStream::read`]: super::super::super::net::TcpStream::read
/// [`TcpStream::read`]: crate::net::TcpStream::read
/// [`TcpStream`]: crate::net::TcpStream
///
/// # Examples

View file

@ -62,8 +62,7 @@
/// together by the buffer and will all be written out in one system call when
/// the `stream` is flushed.
///
// HACK(#78696): can't use `crate` for associated items
/// [`TcpStream::write`]: super::super::super::net::TcpStream::write
/// [`TcpStream::write`]: crate::net::TcpStream::write
/// [`TcpStream`]: crate::net::TcpStream
/// [`flush`]: BufWriter::flush
#[stable(feature = "rust1", since = "1.0.0")]

View file

@ -1,5 +1,14 @@
# `sanitizer`
Sanitizers are tools that help detect and prevent various types of bugs and
vulnerabilities in software. They are available in compilers and work by
instrumenting the code to add additional runtime checks. While they provide
powerful tools for identifying bugs or security issues, it's important to note
that using sanitizers can introduce runtime overhead and might not catch all
possible issues. Therefore, they are typically used alongside other best
practices in software development, such as testing and fuzzing, to ensure the
highest level of software quality and security.
The tracking issues for this feature are:
* [#39699](https://github.com/rust-lang/rust/issues/39699).
@ -9,21 +18,26 @@ The tracking issues for this feature are:
This feature allows for use of one of following sanitizers:
* [AddressSanitizer](#addresssanitizer) a fast memory error detector.
* [ControlFlowIntegrity](#controlflowintegrity) LLVM Control Flow Integrity (CFI) provides
forward-edge control flow protection.
* [HWAddressSanitizer](#hwaddresssanitizer) a memory error detector similar to
AddressSanitizer, but based on partial hardware assistance.
* [KernelControlFlowIntegrity](#kernelcontrolflowintegrity) LLVM Kernel Control
Flow Integrity (KCFI) provides forward-edge control flow protection for
operating systems kernels.
* [LeakSanitizer](#leaksanitizer) a run-time memory leak detector.
* [MemorySanitizer](#memorysanitizer) a detector of uninitialized reads.
* [MemTagSanitizer](#memtagsanitizer) fast memory error detector based on
Armv8.5-A Memory Tagging Extension.
* [SafeStack](#safestack) provides backward-edge control flow protection by separating the stack into safe and unsafe regions.
* [ShadowCallStack](#shadowcallstack) provides backward-edge control flow protection (aarch64 only).
* [ThreadSanitizer](#threadsanitizer) a fast data race detector.
* Those intended for testing or fuzzing (but not production use):
* [AddressSanitizer](#addresssanitizer) a fast memory error detector.
* [HWAddressSanitizer](#hwaddresssanitizer) a memory error detector similar to
AddressSanitizer, but based on partial hardware assistance.
* [LeakSanitizer](#leaksanitizer) a run-time memory leak detector.
* [MemorySanitizer](#memorysanitizer) a detector of uninitialized reads.
* [ThreadSanitizer](#threadsanitizer) a fast data race detector.
* Those that apart from testing, may be used in production:
* [ControlFlowIntegrity](#controlflowintegrity) LLVM Control Flow Integrity
(CFI) provides forward-edge control flow protection.
* [KernelControlFlowIntegrity](#kernelcontrolflowintegrity) LLVM Kernel
Control Flow Integrity (KCFI) provides forward-edge control flow protection
for operating systems kernels.
* [MemTagSanitizer](#memtagsanitizer) fast memory error detector based on
Armv8.5-A Memory Tagging Extension.
* [SafeStack](#safestack) provides backward-edge control flow protection by
separating the stack into safe and unsafe regions.
* [ShadowCallStack](#shadowcallstack) provides backward-edge control flow
protection (aarch64 only).
To enable a sanitizer compile with `-Zsanitizer=address`,`-Zsanitizer=cfi`,
`-Zsanitizer=hwaddress`, `-Zsanitizer=leak`, `-Zsanitizer=memory`,

View file

@ -1,5 +1,4 @@
#![warn(clippy::non_send_fields_in_send_ty)]
#![allow(suspicious_auto_trait_impls)]
#![feature(extern_types)]
use std::cell::UnsafeCell;

View file

@ -1,11 +1,11 @@
error: some fields in `RingBuffer<T>` are not safe to be sent to another thread
--> $DIR/non_send_fields_in_send_ty.rs:17:1
--> $DIR/non_send_fields_in_send_ty.rs:16:1
|
LL | unsafe impl<T> Send for RingBuffer<T> {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
note: it is not safe to send field `data` to another thread
--> $DIR/non_send_fields_in_send_ty.rs:12:5
--> $DIR/non_send_fields_in_send_ty.rs:11:5
|
LL | data: Vec<UnsafeCell<T>>,
| ^^^^^^^^^^^^^^^^^^^^^^^^
@ -14,155 +14,155 @@ LL | data: Vec<UnsafeCell<T>>,
= help: to override `-D warnings` add `#[allow(clippy::non_send_fields_in_send_ty)]`
error: some fields in `MvccRwLock<T>` are not safe to be sent to another thread
--> $DIR/non_send_fields_in_send_ty.rs:26:1
--> $DIR/non_send_fields_in_send_ty.rs:25:1
|
LL | unsafe impl<T> Send for MvccRwLock<T> {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
note: it is not safe to send field `lock` to another thread
--> $DIR/non_send_fields_in_send_ty.rs:23:5
--> $DIR/non_send_fields_in_send_ty.rs:22:5
|
LL | lock: Mutex<Box<T>>,
| ^^^^^^^^^^^^^^^^^^^
= help: add bounds on type parameter `T` that satisfy `Mutex<Box<T>>: Send`
error: some fields in `ArcGuard<RC, T>` are not safe to be sent to another thread
--> $DIR/non_send_fields_in_send_ty.rs:35:1
--> $DIR/non_send_fields_in_send_ty.rs:34:1
|
LL | unsafe impl<RC, T: Send> Send for ArcGuard<RC, T> {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
note: it is not safe to send field `head` to another thread
--> $DIR/non_send_fields_in_send_ty.rs:32:5
--> $DIR/non_send_fields_in_send_ty.rs:31:5
|
LL | head: Arc<RC>,
| ^^^^^^^^^^^^^
= help: add bounds on type parameter `RC` that satisfy `Arc<RC>: Send`
error: some fields in `DeviceHandle<T>` are not safe to be sent to another thread
--> $DIR/non_send_fields_in_send_ty.rs:52:1
--> $DIR/non_send_fields_in_send_ty.rs:51:1
|
LL | unsafe impl<T: UsbContext> Send for DeviceHandle<T> {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
note: it is not safe to send field `context` to another thread
--> $DIR/non_send_fields_in_send_ty.rs:48:5
--> $DIR/non_send_fields_in_send_ty.rs:47:5
|
LL | context: T,
| ^^^^^^^^^^
= help: add `T: Send` bound in `Send` impl
error: some fields in `NoGeneric` are not safe to be sent to another thread
--> $DIR/non_send_fields_in_send_ty.rs:60:1
--> $DIR/non_send_fields_in_send_ty.rs:59:1
|
LL | unsafe impl Send for NoGeneric {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
note: it is not safe to send field `rc_is_not_send` to another thread
--> $DIR/non_send_fields_in_send_ty.rs:57:5
--> $DIR/non_send_fields_in_send_ty.rs:56:5
|
LL | rc_is_not_send: Rc<String>,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
= help: use a thread-safe type that implements `Send`
error: some fields in `MultiField<T>` are not safe to be sent to another thread
--> $DIR/non_send_fields_in_send_ty.rs:69:1
--> $DIR/non_send_fields_in_send_ty.rs:68:1
|
LL | unsafe impl<T> Send for MultiField<T> {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
note: it is not safe to send field `field1` to another thread
--> $DIR/non_send_fields_in_send_ty.rs:64:5
--> $DIR/non_send_fields_in_send_ty.rs:63:5
|
LL | field1: T,
| ^^^^^^^^^
= help: add `T: Send` bound in `Send` impl
note: it is not safe to send field `field2` to another thread
--> $DIR/non_send_fields_in_send_ty.rs:65:5
--> $DIR/non_send_fields_in_send_ty.rs:64:5
|
LL | field2: T,
| ^^^^^^^^^
= help: add `T: Send` bound in `Send` impl
note: it is not safe to send field `field3` to another thread
--> $DIR/non_send_fields_in_send_ty.rs:66:5
--> $DIR/non_send_fields_in_send_ty.rs:65:5
|
LL | field3: T,
| ^^^^^^^^^
= help: add `T: Send` bound in `Send` impl
error: some fields in `MyOption<T>` are not safe to be sent to another thread
--> $DIR/non_send_fields_in_send_ty.rs:77:1
--> $DIR/non_send_fields_in_send_ty.rs:76:1
|
LL | unsafe impl<T> Send for MyOption<T> {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
note: it is not safe to send field `0` to another thread
--> $DIR/non_send_fields_in_send_ty.rs:73:12
--> $DIR/non_send_fields_in_send_ty.rs:72:12
|
LL | MySome(T),
| ^
= help: add `T: Send` bound in `Send` impl
error: some fields in `MultiParam<A, B>` are not safe to be sent to another thread
--> $DIR/non_send_fields_in_send_ty.rs:90:1
--> $DIR/non_send_fields_in_send_ty.rs:89:1
|
LL | unsafe impl<A, B> Send for MultiParam<A, B> {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
note: it is not safe to send field `vec` to another thread
--> $DIR/non_send_fields_in_send_ty.rs:87:5
--> $DIR/non_send_fields_in_send_ty.rs:86:5
|
LL | vec: Vec<(A, B)>,
| ^^^^^^^^^^^^^^^^
= help: add bounds on type parameters `A, B` that satisfy `Vec<(A, B)>: Send`
error: some fields in `HeuristicTest` are not safe to be sent to another thread
--> $DIR/non_send_fields_in_send_ty.rs:109:1
--> $DIR/non_send_fields_in_send_ty.rs:108:1
|
LL | unsafe impl Send for HeuristicTest {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
note: it is not safe to send field `field4` to another thread
--> $DIR/non_send_fields_in_send_ty.rs:104:5
--> $DIR/non_send_fields_in_send_ty.rs:103:5
|
LL | field4: (*const NonSend, Rc<u8>),
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= help: use a thread-safe type that implements `Send`
error: some fields in `AttrTest3<T>` are not safe to be sent to another thread
--> $DIR/non_send_fields_in_send_ty.rs:129:1
--> $DIR/non_send_fields_in_send_ty.rs:128:1
|
LL | unsafe impl<T> Send for AttrTest3<T> {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
note: it is not safe to send field `0` to another thread
--> $DIR/non_send_fields_in_send_ty.rs:124:11
--> $DIR/non_send_fields_in_send_ty.rs:123:11
|
LL | Enum2(T),
| ^
= help: add `T: Send` bound in `Send` impl
error: some fields in `Complex<P, u32>` are not safe to be sent to another thread
--> $DIR/non_send_fields_in_send_ty.rs:138:1
--> $DIR/non_send_fields_in_send_ty.rs:137:1
|
LL | unsafe impl<P> Send for Complex<P, u32> {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
note: it is not safe to send field `field1` to another thread
--> $DIR/non_send_fields_in_send_ty.rs:134:5
--> $DIR/non_send_fields_in_send_ty.rs:133:5
|
LL | field1: A,
| ^^^^^^^^^
= help: add `P: Send` bound in `Send` impl
error: some fields in `Complex<Q, MutexGuard<'static, bool>>` are not safe to be sent to another thread
--> $DIR/non_send_fields_in_send_ty.rs:142:1
--> $DIR/non_send_fields_in_send_ty.rs:141:1
|
LL | unsafe impl<Q: Send> Send for Complex<Q, MutexGuard<'static, bool>> {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
note: it is not safe to send field `field2` to another thread
--> $DIR/non_send_fields_in_send_ty.rs:135:5
--> $DIR/non_send_fields_in_send_ty.rs:134:5
|
LL | field2: B,
| ^^^^^^^^^

View file

@ -55,7 +55,7 @@ pub fn from_reader<R: Read>(config: &Config, testfile: &Path, rdr: R) -> Self {
&mut poisoned,
testfile,
rdr,
&mut |_, _, ln, _| {
&mut |HeaderLine { directive: ln, .. }| {
config.push_name_value_directive(ln, directives::AUX_BUILD, &mut props.aux, |r| {
r.trim().to_string()
});
@ -330,8 +330,8 @@ fn load_from(&mut self, testfile: &Path, cfg: Option<&str>, config: &Config) {
&mut poisoned,
testfile,
file,
&mut |revision, _, ln, _| {
if revision.is_some() && revision != cfg {
&mut |HeaderLine { header_revision, directive: ln, .. }| {
if header_revision.is_some() && header_revision != cfg {
return;
}
@ -672,17 +672,6 @@ pub fn line_directive<'line>(
}
}
fn iter_header<R: Read>(
mode: Mode,
suite: &str,
poisoned: &mut bool,
testfile: &Path,
rdr: R,
it: &mut dyn FnMut(Option<&str>, &str, &str, usize),
) {
iter_header_extra(mode, suite, poisoned, testfile, rdr, &[], it)
}
/// This is generated by collecting directives from ui tests and then extracting their directive
/// names. This is **not** an exhaustive list of all possible directives. Instead, this is a
/// best-effort approximation for diagnostics.
@ -801,23 +790,49 @@ fn iter_header<R: Read>(
"unset-rustc-env",
];
fn iter_header_extra(
/// Arguments passed to the callback in [`iter_header`].
struct HeaderLine<'ln> {
/// Contents of the square brackets preceding this header, if present.
header_revision: Option<&'ln str>,
/// Raw line from the test file, including comment prefix and any revision.
original_line: &'ln str,
/// Remainder of the directive line, after the initial comment prefix
/// (`//` or `//@` or `#`) and revision (if any) have been stripped.
directive: &'ln str,
line_number: usize,
}
fn iter_header(
mode: Mode,
suite: &str,
poisoned: &mut bool,
testfile: &Path,
rdr: impl Read,
extra_directives: &[&str],
it: &mut dyn FnMut(Option<&str>, &str, &str, usize),
it: &mut dyn FnMut(HeaderLine<'_>),
) {
if testfile.is_dir() {
return;
}
// Process any extra directives supplied by the caller (e.g. because they
// are implied by the test mode), with a dummy line number of 0.
for directive in extra_directives {
it(None, directive, directive, 0);
// Coverage tests in coverage-run mode always have these extra directives,
// without needing to specify them manually in every test file.
// (Some of the comments below have been copied over from the old
// `tests/run-make/coverage-reports/Makefile`, which no longer exists.)
if mode == Mode::CoverageRun {
let extra_directives: &[&str] = &[
"needs-profiler-support",
// FIXME(mati865): MinGW GCC miscompiles compiler-rt profiling library but with Clang it works
// properly. Since we only have GCC on the CI ignore the test for now.
"ignore-windows-gnu",
// FIXME(pietroalbini): this test currently does not work on cross-compiled
// targets because remote-test is not capable of sending back the *.profraw
// files generated by the LLVM instrumentation.
"ignore-cross-compile",
];
// Process the extra implied directives, with a dummy line number of 0.
for directive in extra_directives {
it(HeaderLine { header_revision: None, original_line: "", directive, line_number: 0 });
}
}
let comment = if testfile.extension().is_some_and(|e| e == "rs") {
@ -843,14 +858,14 @@ fn iter_header_extra(
// Assume that any directives will be found before the first
// module or function. This doesn't seem to be an optimization
// with a warm page cache. Maybe with a cold one.
let orig_ln = &ln;
let original_line = &ln;
let ln = ln.trim();
if ln.starts_with("fn") || ln.starts_with("mod") {
return;
// First try to accept `ui_test` style comments
} else if let Some((lncfg, ln)) = line_directive(comment, ln) {
it(lncfg, orig_ln, ln, line_number);
} else if let Some((header_revision, directive)) = line_directive(comment, ln) {
it(HeaderLine { header_revision, original_line, directive, line_number });
} else if mode == Mode::Ui && suite == "ui" && !REVISION_MAGIC_COMMENT_RE.is_match(ln) {
let Some((_, rest)) = line_directive("//", ln) else {
continue;
@ -1150,37 +1165,16 @@ pub fn make_test_description<R: Read>(
let mut ignore_message = None;
let mut should_fail = false;
let extra_directives: &[&str] = match config.mode {
// The coverage-run tests are treated as having these extra directives,
// without needing to specify them manually in every test file.
// (Some of the comments below have been copied over from
// `tests/run-make/coverage-reports/Makefile`, which no longer exists.)
Mode::CoverageRun => {
&[
"needs-profiler-support",
// FIXME(mati865): MinGW GCC miscompiles compiler-rt profiling library but with Clang it works
// properly. Since we only have GCC on the CI ignore the test for now.
"ignore-windows-gnu",
// FIXME(pietroalbini): this test currently does not work on cross-compiled
// targets because remote-test is not capable of sending back the *.profraw
// files generated by the LLVM instrumentation.
"ignore-cross-compile",
]
}
_ => &[],
};
let mut local_poisoned = false;
iter_header_extra(
iter_header(
config.mode,
&config.suite,
&mut local_poisoned,
path,
src,
extra_directives,
&mut |revision, og_ln, ln, line_number| {
if revision.is_some() && revision != cfg {
&mut |HeaderLine { header_revision, original_line, directive: ln, line_number }| {
if header_revision.is_some() && header_revision != cfg {
return;
}
@ -1204,7 +1198,7 @@ macro_rules! decision {
};
}
if let Some((_, post)) = og_ln.trim_start().split_once("//") {
if let Some((_, post)) = original_line.trim_start().split_once("//") {
let post = post.trim_start();
if post.starts_with("ignore-tidy")
&& config.mode == Mode::Ui

View file

@ -502,10 +502,6 @@ pub struct LintGroup {
label: "stable_features",
description: r##"stable features found in `#[feature]` directive"##,
},
Lint {
label: "suspicious_auto_trait_impls",
description: r##"the rules governing auto traits have recently changed resulting in potential breakage"##,
},
Lint {
label: "suspicious_double_ref_op",
description: r##"suspicious call of trait method on `&&T`"##,
@ -778,7 +774,6 @@ pub struct LintGroup {
"repr_transparent_external_private_fields",
"semicolon_in_expressions_from_macros",
"soft_unstable",
"suspicious_auto_trait_impls",
"uninhabited_static",
"unstable_name_collisions",
"unstable_syntax_pre_expansion",

View file

@ -55,7 +55,7 @@ fn test_skipped(mut args: Vec<String>) {
fn test_failed(mut args: Vec<String>) {
args.push("--cfg=broken".to_string());
let result = run!(args, || unreachable!() as ControlFlow<()>);
assert_eq!(result, Err(stable_mir::CompilerError::CompilationFailed));
assert_eq!(result, Err(stable_mir::CompilerError::Failed));
}
/// Test that we are able to pass a closure and set the return according to the captured value.

View file

@ -1,5 +1,3 @@
#![deny(suspicious_auto_trait_impls)]
auto trait Trait<P> {} //~ ERROR auto traits cannot have generic parameters
//~^ ERROR auto traits are experimental and possibly buggy
impl<P> Trait<P> for () {}

View file

@ -1,5 +1,5 @@
error[E0567]: auto traits cannot have generic parameters
--> $DIR/issue-117789.rs:3:17
--> $DIR/issue-117789.rs:1:17
|
LL | auto trait Trait<P> {}
| -----^^^ help: remove the parameters
@ -7,7 +7,7 @@ LL | auto trait Trait<P> {}
| auto trait cannot have generic parameters
error[E0658]: auto traits are experimental and possibly buggy
--> $DIR/issue-117789.rs:3:1
--> $DIR/issue-117789.rs:1:1
|
LL | auto trait Trait<P> {}
| ^^^^^^^^^^^^^^^^^^^^^^

View file

@ -1,4 +1,3 @@
#![allow(suspicious_auto_trait_impls)]
// Tests that we don't incorrectly allow overlap between a builtin auto trait
// impl and a user written one. See #83857 for more details

View file

@ -1,12 +1,12 @@
error[E0277]: `Foo<T, U>` cannot be sent between threads safely
--> $DIR/issue-83857-ub.rs:22:38
--> $DIR/issue-83857-ub.rs:21:38
|
LL | fn generic<T, U>(v: Foo<T, U>, f: fn(<Foo<T, U> as WithAssoc>::Output) -> i32) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `Foo<T, U>` cannot be sent between threads safely
|
= help: the trait `Send` is not implemented for `Foo<T, U>`, which is required by `Foo<T, U>: WithAssoc`
note: required for `Foo<T, U>` to implement `WithAssoc`
--> $DIR/issue-83857-ub.rs:15:15
--> $DIR/issue-83857-ub.rs:14:15
|
LL | impl<T: Send> WithAssoc for T {
| ---- ^^^^^^^^^ ^
@ -18,7 +18,7 @@ LL | fn generic<T, U>(v: Foo<T, U>, f: fn(<Foo<T, U> as WithAssoc>::Output) -> i
| +++++++++++++++++++++
error[E0277]: `Foo<T, U>` cannot be sent between threads safely
--> $DIR/issue-83857-ub.rs:22:80
--> $DIR/issue-83857-ub.rs:21:80
|
LL | fn generic<T, U>(v: Foo<T, U>, f: fn(<Foo<T, U> as WithAssoc>::Output) -> i32) {
| ________________________________________________________________________________^
@ -31,7 +31,7 @@ LL | | }
|
= help: the trait `Send` is not implemented for `Foo<T, U>`, which is required by `Foo<T, U>: WithAssoc`
note: required for `Foo<T, U>` to implement `WithAssoc`
--> $DIR/issue-83857-ub.rs:15:15
--> $DIR/issue-83857-ub.rs:14:15
|
LL | impl<T: Send> WithAssoc for T {
| ---- ^^^^^^^^^ ^
@ -43,7 +43,7 @@ LL | fn generic<T, U>(v: Foo<T, U>, f: fn(<Foo<T, U> as WithAssoc>::Output) -> i
| +++++++++++++++++++++
error[E0277]: `Foo<T, U>` cannot be sent between threads safely
--> $DIR/issue-83857-ub.rs:25:11
--> $DIR/issue-83857-ub.rs:24:11
|
LL | f(foo(v));
| --- ^ `Foo<T, U>` cannot be sent between threads safely
@ -52,7 +52,7 @@ LL | f(foo(v));
|
= help: the trait `Send` is not implemented for `Foo<T, U>`
note: required by a bound in `foo`
--> $DIR/issue-83857-ub.rs:29:11
--> $DIR/issue-83857-ub.rs:28:11
|
LL | fn foo<T: Send>(x: T) -> <T as WithAssoc>::Output {
| ^^^^ required by this bound in `foo`

View file

@ -1,50 +0,0 @@
#![deny(suspicious_auto_trait_impls)]
use std::marker::PhantomData;
struct MayImplementSendOk<T>(T);
unsafe impl<T: Send> Send for MayImplementSendOk<T> {} // ok
struct MayImplementSendErr<T>(T);
unsafe impl<T: Send> Send for MayImplementSendErr<&T> {}
//~^ ERROR
//~| WARNING this will change its meaning
struct ContainsNonSendDirect<T>(*const T);
unsafe impl<T: Send> Send for ContainsNonSendDirect<&T> {} // ok
struct ContainsPtr<T>(*const T);
struct ContainsIndirectNonSend<T>(ContainsPtr<T>);
unsafe impl<T: Send> Send for ContainsIndirectNonSend<&T> {} // ok
struct ContainsVec<T>(Vec<T>);
unsafe impl Send for ContainsVec<i32> {}
//~^ ERROR
//~| WARNING this will change its meaning
struct TwoParams<T, U>(T, U);
unsafe impl<T: Send, U: Send> Send for TwoParams<T, U> {} // ok
struct TwoParamsFlipped<T, U>(T, U);
unsafe impl<T: Send, U: Send> Send for TwoParamsFlipped<U, T> {} // ok
struct TwoParamsSame<T, U>(T, U);
unsafe impl<T: Send> Send for TwoParamsSame<T, T> {}
//~^ ERROR
//~| WARNING this will change its meaning
pub struct WithPhantomDataNonSend<T, U>(PhantomData<*const T>, U);
unsafe impl<T> Send for WithPhantomDataNonSend<T, i8> {} // ok
pub struct WithPhantomDataSend<T, U>(PhantomData<T>, U);
unsafe impl<T> Send for WithPhantomDataSend<*const T, i8> {}
//~^ ERROR
//~| WARNING this will change its meaning
pub struct WithLifetime<'a, T>(&'a (), T);
unsafe impl<T> Send for WithLifetime<'static, T> {} // ok
unsafe impl<T> Sync for WithLifetime<'static, Vec<T>> {}
//~^ ERROR
//~| WARNING this will change its meaning
fn main() {}

View file

@ -1,82 +0,0 @@
error: cross-crate traits with a default impl, like `Send`, should not be specialized
--> $DIR/suspicious-impls-lint.rs:9:1
|
LL | unsafe impl<T: Send> Send for MayImplementSendErr<&T> {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= warning: this will change its meaning in a future release!
= note: for more information, see issue #93367 <https://github.com/rust-lang/rust/issues/93367>
= note: `&T` is not a generic parameter
note: try using the same sequence of generic parameters as the struct definition
--> $DIR/suspicious-impls-lint.rs:8:1
|
LL | struct MayImplementSendErr<T>(T);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: the lint level is defined here
--> $DIR/suspicious-impls-lint.rs:1:9
|
LL | #![deny(suspicious_auto_trait_impls)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: cross-crate traits with a default impl, like `Send`, should not be specialized
--> $DIR/suspicious-impls-lint.rs:21:1
|
LL | unsafe impl Send for ContainsVec<i32> {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= warning: this will change its meaning in a future release!
= note: for more information, see issue #93367 <https://github.com/rust-lang/rust/issues/93367>
= note: `i32` is not a generic parameter
note: try using the same sequence of generic parameters as the struct definition
--> $DIR/suspicious-impls-lint.rs:20:1
|
LL | struct ContainsVec<T>(Vec<T>);
| ^^^^^^^^^^^^^^^^^^^^^
error: cross-crate traits with a default impl, like `Send`, should not be specialized
--> $DIR/suspicious-impls-lint.rs:32:1
|
LL | unsafe impl<T: Send> Send for TwoParamsSame<T, T> {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= warning: this will change its meaning in a future release!
= note: for more information, see issue #93367 <https://github.com/rust-lang/rust/issues/93367>
= note: `T` is mentioned multiple times
note: try using the same sequence of generic parameters as the struct definition
--> $DIR/suspicious-impls-lint.rs:31:1
|
LL | struct TwoParamsSame<T, U>(T, U);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
error: cross-crate traits with a default impl, like `Send`, should not be specialized
--> $DIR/suspicious-impls-lint.rs:40:1
|
LL | unsafe impl<T> Send for WithPhantomDataSend<*const T, i8> {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= warning: this will change its meaning in a future release!
= note: for more information, see issue #93367 <https://github.com/rust-lang/rust/issues/93367>
= note: `*const T` is not a generic parameter
note: try using the same sequence of generic parameters as the struct definition
--> $DIR/suspicious-impls-lint.rs:39:1
|
LL | pub struct WithPhantomDataSend<T, U>(PhantomData<T>, U);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: cross-crate traits with a default impl, like `Sync`, should not be specialized
--> $DIR/suspicious-impls-lint.rs:46:1
|
LL | unsafe impl<T> Sync for WithLifetime<'static, Vec<T>> {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= warning: this will change its meaning in a future release!
= note: for more information, see issue #93367 <https://github.com/rust-lang/rust/issues/93367>
= note: `Vec<T>` is not a generic parameter
note: try using the same sequence of generic parameters as the struct definition
--> $DIR/suspicious-impls-lint.rs:44:1
|
LL | pub struct WithLifetime<'a, T>(&'a (), T);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 5 previous errors

View file

@ -1,21 +0,0 @@
#![feature(negative_impls)]
#![deny(suspicious_auto_trait_impls)]
use std::marker::PhantomData;
struct ContainsVec<T>(Vec<T>);
impl !Send for ContainsVec<u32> {}
//~^ ERROR
//~| WARNING this will change its meaning
pub struct WithPhantomDataSend<T, U>(PhantomData<T>, U);
impl<T> !Send for WithPhantomDataSend<*const T, u8> {}
//~^ ERROR
//~| WARNING this will change its meaning
pub struct WithLifetime<'a, T>(&'a (), T);
impl<T> !Sync for WithLifetime<'static, Option<T>> {}
//~^ ERROR
//~| WARNING this will change its meaning
fn main() {}

View file

@ -1,52 +0,0 @@
error: cross-crate traits with a default impl, like `Send`, should not be specialized
--> $DIR/suspicious-negative-impls-lint.rs:7:1
|
LL | impl !Send for ContainsVec<u32> {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= warning: this will change its meaning in a future release!
= note: for more information, see issue #93367 <https://github.com/rust-lang/rust/issues/93367>
= note: `u32` is not a generic parameter
note: try using the same sequence of generic parameters as the struct definition
--> $DIR/suspicious-negative-impls-lint.rs:6:1
|
LL | struct ContainsVec<T>(Vec<T>);
| ^^^^^^^^^^^^^^^^^^^^^
note: the lint level is defined here
--> $DIR/suspicious-negative-impls-lint.rs:2:9
|
LL | #![deny(suspicious_auto_trait_impls)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: cross-crate traits with a default impl, like `Send`, should not be specialized
--> $DIR/suspicious-negative-impls-lint.rs:12:1
|
LL | impl<T> !Send for WithPhantomDataSend<*const T, u8> {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= warning: this will change its meaning in a future release!
= note: for more information, see issue #93367 <https://github.com/rust-lang/rust/issues/93367>
= note: `*const T` is not a generic parameter
note: try using the same sequence of generic parameters as the struct definition
--> $DIR/suspicious-negative-impls-lint.rs:11:1
|
LL | pub struct WithPhantomDataSend<T, U>(PhantomData<T>, U);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: cross-crate traits with a default impl, like `Sync`, should not be specialized
--> $DIR/suspicious-negative-impls-lint.rs:17:1
|
LL | impl<T> !Sync for WithLifetime<'static, Option<T>> {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= warning: this will change its meaning in a future release!
= note: for more information, see issue #93367 <https://github.com/rust-lang/rust/issues/93367>
= note: `Option<T>` is not a generic parameter
note: try using the same sequence of generic parameters as the struct definition
--> $DIR/suspicious-negative-impls-lint.rs:16:1
|
LL | pub struct WithLifetime<'a, T>(&'a (), T);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 3 previous errors

View file

@ -13,7 +13,5 @@ impl<T: MyTrait> !Send for TestType<T> {} //~ ERROR found both positive and nega
unsafe impl<T: 'static> Send for TestType<T> {} //~ ERROR conflicting implementations
impl !Send for TestType<i32> {}
//~^ WARNING
//~| WARNING this will change its meaning
fn main() {}

View file

@ -16,23 +16,7 @@ LL | unsafe impl<T: MyTrait + 'static> Send for TestType<T> {}
LL | unsafe impl<T: 'static> Send for TestType<T> {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `TestType<_>`
warning: cross-crate traits with a default impl, like `Send`, should not be specialized
--> $DIR/coherence-conflicting-negative-trait-impl.rs:15:1
|
LL | impl !Send for TestType<i32> {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= warning: this will change its meaning in a future release!
= note: for more information, see issue #93367 <https://github.com/rust-lang/rust/issues/93367>
= note: `i32` is not a generic parameter
note: try using the same sequence of generic parameters as the struct definition
--> $DIR/coherence-conflicting-negative-trait-impl.rs:7:1
|
LL | struct TestType<T>(::std::marker::PhantomData<T>);
| ^^^^^^^^^^^^^^^^^^
= note: `#[warn(suspicious_auto_trait_impls)]` on by default
error: aborting due to 2 previous errors; 1 warning emitted
error: aborting due to 2 previous errors
Some errors have detailed explanations: E0119, E0751.
For more information about an error, try `rustc --explain E0119`.

View file

@ -20,7 +20,7 @@ impl Trait for for<'a, 'b> fn(&'a &'b u32, &'b &'a u32) -> &'b u32 {}
impl Trait for for<'c> fn(&'c &'c u32, &'c &'c u32) -> &'c u32 {
//~^ ERROR conflicting implementations
//~| WARNING this was previously accepted by the compiler
//~| WARN the behavior may change in a future release
}
fn main() {}

View file

@ -7,7 +7,7 @@ LL |
LL | impl Trait for for<'c> fn(&'c &'c u32, &'c &'c u32) -> &'c u32 {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `for<'a, 'b> fn(&'a &'b u32, &'b &'a u32) -> &'b u32`
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= warning: the behavior may change in a future release
= note: for more information, see issue #56105 <https://github.com/rust-lang/rust/issues/56105>
= note: this behavior recently changed as a result of a bug fix; see rust-lang/rust#56105 for details
note: the lint level is defined here

View file

@ -15,7 +15,7 @@ impl<'a> TheTrait for fn(&'a u8) {}
impl TheTrait for fn(&u8) {
//~^ ERROR conflicting implementations of trait
//~| WARNING this was previously accepted by the compiler
//~| WARN the behavior may change in a future release
}
fn main() {}

View file

@ -7,7 +7,7 @@ LL |
LL | impl TheTrait for fn(&u8) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `fn(&u8)`
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= warning: the behavior may change in a future release
= note: for more information, see issue #56105 <https://github.com/rust-lang/rust/issues/56105>
= note: this behavior recently changed as a result of a bug fix; see rust-lang/rust#56105 for details
note: the lint level is defined here

View file

@ -7,18 +7,16 @@
struct TheType;
impl TheTrait<usize> for isize { }
impl TheTrait<usize> for isize {}
//~^ ERROR E0117
//~| ERROR not all trait items implemented
impl TheTrait<TheType> for isize { }
impl TheTrait<TheType> for isize {}
//~^ ERROR not all trait items implemented
impl TheTrait<isize> for TheType { }
impl TheTrait<isize> for TheType {}
//~^ ERROR not all trait items implemented
impl !Send for Vec<isize> { } //~ ERROR E0117
//~^ WARNING
//~| WARNING this will change its meaning
impl !Send for Vec<isize> {} //~ ERROR E0117
fn main() { }
fn main() {}

View file

@ -1,7 +1,7 @@
error[E0117]: only traits defined in the current crate can be implemented for primitive types
--> $DIR/coherence-orphan.rs:10:1
|
LL | impl TheTrait<usize> for isize { }
LL | impl TheTrait<usize> for isize {}
| ^^^^^---------------^^^^^-----
| | | |
| | | `isize` is not defined in the current crate
@ -13,7 +13,7 @@ LL | impl TheTrait<usize> for isize { }
error[E0117]: only traits defined in the current crate can be implemented for types defined outside of the crate
--> $DIR/coherence-orphan.rs:20:1
|
LL | impl !Send for Vec<isize> { }
LL | impl !Send for Vec<isize> {}
| ^^^^^^^^^^^^^^^----------
| | |
| | `Vec` is not defined in the current crate
@ -21,23 +21,10 @@ LL | impl !Send for Vec<isize> { }
|
= note: define and implement a trait or new type instead
warning: cross-crate traits with a default impl, like `Send`, should not be specialized
--> $DIR/coherence-orphan.rs:20:1
|
LL | impl !Send for Vec<isize> { }
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
= warning: this will change its meaning in a future release!
= note: for more information, see issue #93367 <https://github.com/rust-lang/rust/issues/93367>
= note: `isize` is not a generic parameter
note: try using the same sequence of generic parameters as the struct definition
--> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL
= note: `#[warn(suspicious_auto_trait_impls)]` on by default
error[E0046]: not all trait items implemented, missing: `the_fn`
--> $DIR/coherence-orphan.rs:10:1
|
LL | impl TheTrait<usize> for isize { }
LL | impl TheTrait<usize> for isize {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `the_fn` in implementation
|
= help: implement the missing item: `fn the_fn(&self) { todo!() }`
@ -45,7 +32,7 @@ LL | impl TheTrait<usize> for isize { }
error[E0046]: not all trait items implemented, missing: `the_fn`
--> $DIR/coherence-orphan.rs:14:1
|
LL | impl TheTrait<TheType> for isize { }
LL | impl TheTrait<TheType> for isize {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `the_fn` in implementation
|
= help: implement the missing item: `fn the_fn(&self) { todo!() }`
@ -53,12 +40,12 @@ LL | impl TheTrait<TheType> for isize { }
error[E0046]: not all trait items implemented, missing: `the_fn`
--> $DIR/coherence-orphan.rs:17:1
|
LL | impl TheTrait<isize> for TheType { }
LL | impl TheTrait<isize> for TheType {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `the_fn` in implementation
|
= help: implement the missing item: `fn the_fn(&self) { todo!() }`
error: aborting due to 5 previous errors; 1 warning emitted
error: aborting due to 5 previous errors
Some errors have detailed explanations: E0046, E0117.
For more information about an error, try `rustc --explain E0046`.

View file

@ -15,16 +15,20 @@
trait Fold<F> {}
impl<T, F> Fold<F> for Cons<T> // 0
impl<T, F> Fold<F> for Cons<T>
// 0
where
T: Fold<Nil>,
{}
{
}
impl<T, F> Fold<F> for Cons<T> // 1
impl<T, F> Fold<F> for Cons<T>
// 1
where
T: Fold<F>,
private::Is<T>: private::NotNil,
{}
{
}
impl<F> Fold<F> for Test {} // 2
@ -34,7 +38,6 @@ mod private {
pub struct Is<T>(T);
pub auto trait NotNil {}
#[allow(suspicious_auto_trait_impls)]
impl !NotNil for Is<Nil> {}
}

View file

@ -13,8 +13,8 @@ fn foo(&self) {}
impl TheTrait for for<'a, 'b> fn(&'a u8, &'b u8) -> &'a u8 {}
impl TheTrait for for<'a> fn(&'a u8, &'a u8) -> &'a u8 {
//~^ WARNING conflicting implementation
//~^^ WARNING this was previously accepted by the compiler but is being phased out
//~^ WARN conflicting implementation
//~| WARN the behavior may change in a future release
}
fn main() {}

View file

@ -7,7 +7,7 @@ LL |
LL | impl TheTrait for for<'a> fn(&'a u8, &'a u8) -> &'a u8 {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `for<'a, 'b> fn(&'a u8, &'b u8) -> &'a u8`
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= warning: the behavior may change in a future release
= note: for more information, see issue #56105 <https://github.com/rust-lang/rust/issues/56105>
= note: this behavior recently changed as a result of a bug fix; see rust-lang/rust#56105 for details
= note: `#[warn(coherence_leak_check)]` on by default

View file

@ -31,7 +31,7 @@ impl<'a, 'b, A, R> IntoWasmAbi for &'a (dyn for<'x> Fn(&'x A) -> R + 'b)
R: ReturnWasmAbi,
{
//~^^^^^ ERROR conflicting implementation
//~| WARNING this was previously accepted
//~| WARN the behavior may change in a future release
}
fn main() {}

View file

@ -13,7 +13,7 @@ LL | | A: RefFromWasmAbi,
LL | | R: ReturnWasmAbi,
| |_____________________^ conflicting implementation for `&dyn Fn(&_) -> _`
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= warning: the behavior may change in a future release
= note: for more information, see issue #56105 <https://github.com/rust-lang/rust/issues/56105>
= note: downstream crates may implement trait `FromWasmAbi` for type `&_`
= note: this behavior recently changed as a result of a bug fix; see rust-lang/rust#56105 for details

View file

@ -0,0 +1,14 @@
// #103369: don't complain about conflicting implementations with [const error]
pub trait ConstGenericTrait<const N: u32> {}
impl ConstGenericTrait<{my_fn(1)}> for () {}
impl ConstGenericTrait<{my_fn(2)}> for () {}
const fn my_fn(v: u32) -> u32 {
panic!("Some error occurred"); //~ ERROR E0080
//~| ERROR E0080
}
fn main() {}

View file

@ -0,0 +1,39 @@
error[E0080]: evaluation of constant value failed
--> $DIR/const-errs-dont-conflict-103369.rs:10:5
|
LL | panic!("Some error occurred");
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'Some error occurred', $DIR/const-errs-dont-conflict-103369.rs:10:5
|
note: inside `my_fn`
--> $DIR/const-errs-dont-conflict-103369.rs:10:5
|
LL | panic!("Some error occurred");
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: inside `<() as ConstGenericTrait<{my_fn(1)}>>::{constant#0}`
--> $DIR/const-errs-dont-conflict-103369.rs:5:25
|
LL | impl ConstGenericTrait<{my_fn(1)}> for () {}
| ^^^^^^^^
= note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0080]: evaluation of constant value failed
--> $DIR/const-errs-dont-conflict-103369.rs:10:5
|
LL | panic!("Some error occurred");
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'Some error occurred', $DIR/const-errs-dont-conflict-103369.rs:10:5
|
note: inside `my_fn`
--> $DIR/const-errs-dont-conflict-103369.rs:10:5
|
LL | panic!("Some error occurred");
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: inside `<() as ConstGenericTrait<{my_fn(2)}>>::{constant#0}`
--> $DIR/const-errs-dont-conflict-103369.rs:7:25
|
LL | impl ConstGenericTrait<{my_fn(2)}> for () {}
| ^^^^^^^^
= note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0080`.

View file

@ -6,7 +6,7 @@ LL | impl<T: ?Sized + Marker> FnMarker for fn(T) {}
LL | impl<T: ?Sized> FnMarker for fn(&T) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `fn(&_)`
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= warning: the behavior may change in a future release
= note: for more information, see issue #56105 <https://github.com/rust-lang/rust/issues/56105>
= note: this behavior recently changed as a result of a bug fix; see rust-lang/rust#56105 for details
note: the lint level is defined here

View file

@ -20,6 +20,6 @@ trait FnMarker {}
impl<T: ?Sized + Marker> FnMarker for fn(T) {}
impl<T: ?Sized> FnMarker for fn(&T) {}
//[explicit]~^ ERROR conflicting implementations of trait `FnMarker` for type `fn(&_)`
//[explicit]~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
//[explicit]~| WARN the behavior may change in a future release
fn main() {}

View file

@ -12,18 +12,16 @@ impl SadBee for for<'a> fn(&'a ()) {
const ASSOC: usize = 0;
}
impl SadBee for fn(&'static ()) {
//~^ WARNING conflicting implementations of trait
//~| WARNING this was previously accepted
//~^ WARN conflicting implementations of trait
//~| WARN the behavior may change in a future release
const ASSOC: usize = 100;
}
struct Foo<T: SadBee>([u8; <T as SadBee>::ASSOC], PhantomData<T>)
where
[(); <T as SadBee>::ASSOC]: ;
[(); <T as SadBee>::ASSOC]:;
fn covariant(
v: &'static Foo<for<'a> fn(&'a ())>
) -> &'static Foo<fn(&'static ())> {
fn covariant(v: &'static Foo<for<'a> fn(&'a ())>) -> &'static Foo<fn(&'static ())> {
v
//~^ ERROR mismatched types
}

View file

@ -7,13 +7,13 @@ LL | impl SadBee for for<'a> fn(&'a ()) {
LL | impl SadBee for fn(&'static ()) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `for<'a> fn(&'a ())`
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= warning: the behavior may change in a future release
= note: for more information, see issue #56105 <https://github.com/rust-lang/rust/issues/56105>
= note: this behavior recently changed as a result of a bug fix; see rust-lang/rust#56105 for details
= note: `#[warn(coherence_leak_check)]` on by default
error[E0308]: mismatched types
--> $DIR/invariant.rs:27:5
--> $DIR/invariant.rs:25:5
|
LL | v
| ^ one type is more general than the other

View file

@ -15,7 +15,6 @@ fn join<MOuter, MInner, A>(outer: MOuter) -> MOuter::Wrapped<A>
//~^ ERROR: missing generics for associated type `Monad::Wrapped`
{
outer.bind(|inner| inner)
//~^ ERROR type annotations needed
}
fn main() {

View file

@ -30,19 +30,8 @@ help: function arguments must have a statically known size, borrowed types alway
LL | fn bind<B, F>(&self, f: F) -> Self::Wrapped<B> {
| +
error[E0282]: type annotations needed
--> $DIR/issue-79636-1.rs:17:17
|
LL | outer.bind(|inner| inner)
| ^^^^^
|
help: consider giving this closure parameter an explicit type
|
LL | outer.bind(|inner: /* Type */| inner)
| ++++++++++++
error[E0277]: the trait bound `Option<Option<bool>>: Monad` is not satisfied
--> $DIR/issue-79636-1.rs:22:21
--> $DIR/issue-79636-1.rs:21:21
|
LL | assert_eq!(join(Some(Some(true))), Some(true));
| ---- ^^^^^^^^^^^^^^^^ the trait `Monad` is not implemented for `Option<Option<bool>>`
@ -63,7 +52,7 @@ LL | where
LL | MOuter: Monad<Unwrapped = MInner>,
| ^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `join`
error: aborting due to 4 previous errors
error: aborting due to 3 previous errors
Some errors have detailed explanations: E0107, E0277, E0282.
Some errors have detailed explanations: E0107, E0277.
For more information about an error, try `rustc --explain E0107`.

View file

@ -59,7 +59,6 @@ fn in_impl_Fn_return_in_parameters(_: &impl Fn() -> impl Debug) { panic!() }
fn in_impl_Fn_parameter_in_return() -> &'static impl Fn(impl Debug) { panic!() }
//~^ ERROR `impl Trait` is not allowed in the parameters of `Fn` trait bounds
//~| ERROR nested `impl Trait` is not allowed
//~| ERROR: type annotations needed
// Allowed
fn in_impl_Fn_return_in_return() -> &'static impl Fn() -> impl Debug { panic!() }

View file

@ -17,7 +17,7 @@ LL | fn in_impl_Fn_parameter_in_return() -> &'static impl Fn(impl Debug) { panic
| outer `impl Trait`
error[E0658]: `impl Trait` in associated types is unstable
--> $DIR/where-allowed.rs:123:16
--> $DIR/where-allowed.rs:122:16
|
LL | type Out = impl Debug;
| ^^^^^^^^^^
@ -27,7 +27,7 @@ LL | type Out = impl Debug;
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
error[E0658]: `impl Trait` in type aliases is unstable
--> $DIR/where-allowed.rs:160:23
--> $DIR/where-allowed.rs:159:23
|
LL | type InTypeAlias<R> = impl Debug;
| ^^^^^^^^^^
@ -37,7 +37,7 @@ LL | type InTypeAlias<R> = impl Debug;
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
error[E0658]: `impl Trait` in type aliases is unstable
--> $DIR/where-allowed.rs:163:39
--> $DIR/where-allowed.rs:162:39
|
LL | type InReturnInTypeAlias<R> = fn() -> impl Debug;
| ^^^^^^^^^^
@ -127,7 +127,7 @@ LL | fn in_impl_Fn_parameter_in_return() -> &'static impl Fn(impl Debug) { panic
= note: `impl Trait` is only allowed in arguments and return types of functions and methods
error[E0562]: `impl Trait` is not allowed in the parameters of `Fn` trait bounds
--> $DIR/where-allowed.rs:69:38
--> $DIR/where-allowed.rs:68:38
|
LL | fn in_Fn_parameter_in_generics<F: Fn(impl Debug)> (_: F) { panic!() }
| ^^^^^^^^^^
@ -135,7 +135,7 @@ LL | fn in_Fn_parameter_in_generics<F: Fn(impl Debug)> (_: F) { panic!() }
= note: `impl Trait` is only allowed in arguments and return types of functions and methods
error[E0562]: `impl Trait` is not allowed in the return type of `Fn` trait bounds
--> $DIR/where-allowed.rs:73:40
--> $DIR/where-allowed.rs:72:40
|
LL | fn in_Fn_return_in_generics<F: Fn() -> impl Debug> (_: F) { panic!() }
| ^^^^^^^^^^
@ -143,7 +143,7 @@ LL | fn in_Fn_return_in_generics<F: Fn() -> impl Debug> (_: F) { panic!() }
= note: `impl Trait` is only allowed in arguments and return types of functions and methods
error[E0562]: `impl Trait` is not allowed in field types
--> $DIR/where-allowed.rs:87:32
--> $DIR/where-allowed.rs:86:32
|
LL | struct InBraceStructField { x: impl Debug }
| ^^^^^^^^^^
@ -151,7 +151,7 @@ LL | struct InBraceStructField { x: impl Debug }
= note: `impl Trait` is only allowed in arguments and return types of functions and methods
error[E0562]: `impl Trait` is not allowed in field types
--> $DIR/where-allowed.rs:91:41
--> $DIR/where-allowed.rs:90:41
|
LL | struct InAdtInBraceStructField { x: Vec<impl Debug> }
| ^^^^^^^^^^
@ -159,7 +159,7 @@ LL | struct InAdtInBraceStructField { x: Vec<impl Debug> }
= note: `impl Trait` is only allowed in arguments and return types of functions and methods
error[E0562]: `impl Trait` is not allowed in field types
--> $DIR/where-allowed.rs:95:27
--> $DIR/where-allowed.rs:94:27
|
LL | struct InTupleStructField(impl Debug);
| ^^^^^^^^^^
@ -167,7 +167,7 @@ LL | struct InTupleStructField(impl Debug);
= note: `impl Trait` is only allowed in arguments and return types of functions and methods
error[E0562]: `impl Trait` is not allowed in field types
--> $DIR/where-allowed.rs:100:25
--> $DIR/where-allowed.rs:99:25
|
LL | InBraceVariant { x: impl Debug },
| ^^^^^^^^^^
@ -175,7 +175,7 @@ LL | InBraceVariant { x: impl Debug },
= note: `impl Trait` is only allowed in arguments and return types of functions and methods
error[E0562]: `impl Trait` is not allowed in field types
--> $DIR/where-allowed.rs:102:20
--> $DIR/where-allowed.rs:101:20
|
LL | InTupleVariant(impl Debug),
| ^^^^^^^^^^
@ -183,7 +183,7 @@ LL | InTupleVariant(impl Debug),
= note: `impl Trait` is only allowed in arguments and return types of functions and methods
error[E0562]: `impl Trait` is not allowed in `extern fn` parameters
--> $DIR/where-allowed.rs:144:33
--> $DIR/where-allowed.rs:143:33
|
LL | fn in_foreign_parameters(_: impl Debug);
| ^^^^^^^^^^
@ -191,7 +191,7 @@ LL | fn in_foreign_parameters(_: impl Debug);
= note: `impl Trait` is only allowed in arguments and return types of functions and methods
error[E0562]: `impl Trait` is not allowed in `extern fn` return types
--> $DIR/where-allowed.rs:147:31
--> $DIR/where-allowed.rs:146:31
|
LL | fn in_foreign_return() -> impl Debug;
| ^^^^^^^^^^
@ -199,7 +199,7 @@ LL | fn in_foreign_return() -> impl Debug;
= note: `impl Trait` is only allowed in arguments and return types of functions and methods
error[E0562]: `impl Trait` is not allowed in `fn` pointer return types
--> $DIR/where-allowed.rs:163:39
--> $DIR/where-allowed.rs:162:39
|
LL | type InReturnInTypeAlias<R> = fn() -> impl Debug;
| ^^^^^^^^^^
@ -207,7 +207,7 @@ LL | type InReturnInTypeAlias<R> = fn() -> impl Debug;
= note: `impl Trait` is only allowed in arguments and return types of functions and methods
error[E0562]: `impl Trait` is not allowed in traits
--> $DIR/where-allowed.rs:168:16
--> $DIR/where-allowed.rs:167:16
|
LL | impl PartialEq<impl Debug> for () {
| ^^^^^^^^^^
@ -215,7 +215,7 @@ LL | impl PartialEq<impl Debug> for () {
= note: `impl Trait` is only allowed in arguments and return types of functions and methods
error[E0562]: `impl Trait` is not allowed in impl headers
--> $DIR/where-allowed.rs:173:24
--> $DIR/where-allowed.rs:172:24
|
LL | impl PartialEq<()> for impl Debug {
| ^^^^^^^^^^
@ -223,7 +223,7 @@ LL | impl PartialEq<()> for impl Debug {
= note: `impl Trait` is only allowed in arguments and return types of functions and methods
error[E0562]: `impl Trait` is not allowed in impl headers
--> $DIR/where-allowed.rs:178:6
--> $DIR/where-allowed.rs:177:6
|
LL | impl impl Debug {
| ^^^^^^^^^^
@ -231,7 +231,7 @@ LL | impl impl Debug {
= note: `impl Trait` is only allowed in arguments and return types of functions and methods
error[E0562]: `impl Trait` is not allowed in impl headers
--> $DIR/where-allowed.rs:184:24
--> $DIR/where-allowed.rs:183:24
|
LL | impl InInherentImplAdt<impl Debug> {
| ^^^^^^^^^^
@ -239,7 +239,7 @@ LL | impl InInherentImplAdt<impl Debug> {
= note: `impl Trait` is only allowed in arguments and return types of functions and methods
error[E0562]: `impl Trait` is not allowed in bounds
--> $DIR/where-allowed.rs:190:11
--> $DIR/where-allowed.rs:189:11
|
LL | where impl Debug: Debug
| ^^^^^^^^^^
@ -247,7 +247,7 @@ LL | where impl Debug: Debug
= note: `impl Trait` is only allowed in arguments and return types of functions and methods
error[E0562]: `impl Trait` is not allowed in bounds
--> $DIR/where-allowed.rs:197:15
--> $DIR/where-allowed.rs:196:15
|
LL | where Vec<impl Debug>: Debug
| ^^^^^^^^^^
@ -255,7 +255,7 @@ LL | where Vec<impl Debug>: Debug
= note: `impl Trait` is only allowed in arguments and return types of functions and methods
error[E0562]: `impl Trait` is not allowed in bounds
--> $DIR/where-allowed.rs:204:24
--> $DIR/where-allowed.rs:203:24
|
LL | where T: PartialEq<impl Debug>
| ^^^^^^^^^^
@ -263,7 +263,7 @@ LL | where T: PartialEq<impl Debug>
= note: `impl Trait` is only allowed in arguments and return types of functions and methods
error[E0562]: `impl Trait` is not allowed in the parameters of `Fn` trait bounds
--> $DIR/where-allowed.rs:211:17
--> $DIR/where-allowed.rs:210:17
|
LL | where T: Fn(impl Debug)
| ^^^^^^^^^^
@ -271,7 +271,7 @@ LL | where T: Fn(impl Debug)
= note: `impl Trait` is only allowed in arguments and return types of functions and methods
error[E0562]: `impl Trait` is not allowed in the return type of `Fn` trait bounds
--> $DIR/where-allowed.rs:218:22
--> $DIR/where-allowed.rs:217:22
|
LL | where T: Fn() -> impl Debug
| ^^^^^^^^^^
@ -279,7 +279,7 @@ LL | where T: Fn() -> impl Debug
= note: `impl Trait` is only allowed in arguments and return types of functions and methods
error[E0562]: `impl Trait` is not allowed in generic parameter defaults
--> $DIR/where-allowed.rs:224:40
--> $DIR/where-allowed.rs:223:40
|
LL | struct InStructGenericParamDefault<T = impl Debug>(T);
| ^^^^^^^^^^
@ -287,7 +287,7 @@ LL | struct InStructGenericParamDefault<T = impl Debug>(T);
= note: `impl Trait` is only allowed in arguments and return types of functions and methods
error[E0562]: `impl Trait` is not allowed in generic parameter defaults
--> $DIR/where-allowed.rs:228:36
--> $DIR/where-allowed.rs:227:36
|
LL | enum InEnumGenericParamDefault<T = impl Debug> { Variant(T) }
| ^^^^^^^^^^
@ -295,7 +295,7 @@ LL | enum InEnumGenericParamDefault<T = impl Debug> { Variant(T) }
= note: `impl Trait` is only allowed in arguments and return types of functions and methods
error[E0562]: `impl Trait` is not allowed in generic parameter defaults
--> $DIR/where-allowed.rs:232:38
--> $DIR/where-allowed.rs:231:38
|
LL | trait InTraitGenericParamDefault<T = impl Debug> {}
| ^^^^^^^^^^
@ -303,7 +303,7 @@ LL | trait InTraitGenericParamDefault<T = impl Debug> {}
= note: `impl Trait` is only allowed in arguments and return types of functions and methods
error[E0562]: `impl Trait` is not allowed in generic parameter defaults
--> $DIR/where-allowed.rs:236:41
--> $DIR/where-allowed.rs:235:41
|
LL | type InTypeAliasGenericParamDefault<T = impl Debug> = T;
| ^^^^^^^^^^
@ -311,7 +311,7 @@ LL | type InTypeAliasGenericParamDefault<T = impl Debug> = T;
= note: `impl Trait` is only allowed in arguments and return types of functions and methods
error[E0562]: `impl Trait` is not allowed in generic parameter defaults
--> $DIR/where-allowed.rs:240:11
--> $DIR/where-allowed.rs:239:11
|
LL | impl <T = impl Debug> T {}
| ^^^^^^^^^^
@ -319,7 +319,7 @@ LL | impl <T = impl Debug> T {}
= note: `impl Trait` is only allowed in arguments and return types of functions and methods
error[E0562]: `impl Trait` is not allowed in generic parameter defaults
--> $DIR/where-allowed.rs:247:40
--> $DIR/where-allowed.rs:246:40
|
LL | fn in_method_generic_param_default<T = impl Debug>(_: T) {}
| ^^^^^^^^^^
@ -327,7 +327,7 @@ LL | fn in_method_generic_param_default<T = impl Debug>(_: T) {}
= note: `impl Trait` is only allowed in arguments and return types of functions and methods
error[E0562]: `impl Trait` is not allowed in the type of variable bindings
--> $DIR/where-allowed.rs:253:29
--> $DIR/where-allowed.rs:252:29
|
LL | let _in_local_variable: impl Fn() = || {};
| ^^^^^^^^^
@ -335,7 +335,7 @@ LL | let _in_local_variable: impl Fn() = || {};
= note: `impl Trait` is only allowed in arguments and return types of functions and methods
error[E0562]: `impl Trait` is not allowed in closure return types
--> $DIR/where-allowed.rs:255:46
--> $DIR/where-allowed.rs:254:46
|
LL | let _in_return_in_local_variable = || -> impl Fn() { || {} };
| ^^^^^^^^^
@ -343,7 +343,7 @@ LL | let _in_return_in_local_variable = || -> impl Fn() { || {} };
= note: `impl Trait` is only allowed in arguments and return types of functions and methods
error: defaults for type parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions
--> $DIR/where-allowed.rs:240:7
--> $DIR/where-allowed.rs:239:7
|
LL | impl <T = impl Debug> T {}
| ^^^^^^^^^^^^^^
@ -353,7 +353,7 @@ LL | impl <T = impl Debug> T {}
= note: `#[deny(invalid_type_param_default)]` on by default
error: defaults for type parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions
--> $DIR/where-allowed.rs:247:36
--> $DIR/where-allowed.rs:246:36
|
LL | fn in_method_generic_param_default<T = impl Debug>(_: T) {}
| ^^^^^^^^^^^^^^
@ -362,7 +362,7 @@ LL | fn in_method_generic_param_default<T = impl Debug>(_: T) {}
= note: for more information, see issue #36887 <https://github.com/rust-lang/rust/issues/36887>
error[E0118]: no nominal type found for inherent implementation
--> $DIR/where-allowed.rs:240:1
--> $DIR/where-allowed.rs:239:1
|
LL | impl <T = impl Debug> T {}
| ^^^^^^^^^^^^^^^^^^^^^^^ impl requires a nominal type
@ -377,14 +377,8 @@ LL | fn in_dyn_Fn_return_in_return() -> &'static dyn Fn() -> impl Debug { panic!
|
= note: cannot satisfy `_: Debug`
error[E0282]: type annotations needed
--> $DIR/where-allowed.rs:59:49
|
LL | fn in_impl_Fn_parameter_in_return() -> &'static impl Fn(impl Debug) { panic!() }
| ^^^^^^^^^^^^^^^^^^^ cannot infer type
error[E0283]: type annotations needed
--> $DIR/where-allowed.rs:65:46
--> $DIR/where-allowed.rs:64:46
|
LL | fn in_impl_Fn_return_in_return() -> &'static impl Fn() -> impl Debug { panic!() }
| ^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type
@ -396,7 +390,7 @@ LL | fn in_impl_Fn_return_in_return() -> &'static impl Fn() -> impl Debug { pani
where Args: Tuple, F: Fn<Args>, A: Allocator, F: ?Sized;
error[E0599]: no function or associated item named `into_vec` found for slice `[_]` in the current scope
--> $DIR/where-allowed.rs:82:5
--> $DIR/where-allowed.rs:81:5
|
LL | vec![vec![0; 10], vec![12; 7], vec![8; 3]]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function or associated item not found in `[_]`
@ -404,7 +398,7 @@ LL | vec![vec![0; 10], vec![12; 7], vec![8; 3]]
= note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0053]: method `in_trait_impl_return` has an incompatible type for trait
--> $DIR/where-allowed.rs:130:34
--> $DIR/where-allowed.rs:129:34
|
LL | type Out = impl Debug;
| ---------- the expected opaque type
@ -416,7 +410,7 @@ LL | fn in_trait_impl_return() -> impl Debug { () }
| help: change the output type to match the trait: `<() as DummyTrait>::Out`
|
note: type in trait
--> $DIR/where-allowed.rs:120:34
--> $DIR/where-allowed.rs:119:34
|
LL | fn in_trait_impl_return() -> Self::Out;
| ^^^^^^^^^
@ -425,14 +419,14 @@ LL | fn in_trait_impl_return() -> Self::Out;
= note: distinct uses of `impl Trait` result in different opaque types
error: unconstrained opaque type
--> $DIR/where-allowed.rs:123:16
--> $DIR/where-allowed.rs:122:16
|
LL | type Out = impl Debug;
| ^^^^^^^^^^
|
= note: `Out` must be used in combination with a concrete type within the same impl
error: aborting due to 51 previous errors
error: aborting due to 50 previous errors
Some errors have detailed explanations: E0053, E0118, E0282, E0283, E0562, E0599, E0658, E0666.
Some errors have detailed explanations: E0053, E0118, E0283, E0562, E0599, E0658, E0666.
For more information about an error, try `rustc --explain E0053`.

View file

@ -1,6 +1,16 @@
error: internal compiler error: error performing ParamEnvAnd { param_env: ParamEnv { caller_bounds: [], reveal: UserFacing }, value: ImpliedOutlivesBounds { ty: &'?2 mut StateContext<'?3, usize> } }
--> $DIR/issue-80409.rs:49:30
|
= query stack during panic:
LL | builder.state().on_entry(|_| {});
| ^^^
|
note:
--> $DIR/issue-80409.rs:49:30
|
LL | builder.state().on_entry(|_| {});
| ^^^
query stack during panic:
end of query stack
error: aborting due to 1 previous error

View file

@ -8,6 +8,7 @@
//@[no-compat] check-fail
//@[no-compat] known-bug: #80409
//@[no-compat] failure-status: 101
//@[no-compat] normalize-stderr-test "delayed at.*" -> ""
//@[no-compat] normalize-stderr-test "note: .*\n\n" -> ""
//@[no-compat] normalize-stderr-test "thread 'rustc' panicked.*\n" -> ""
//@[no-compat] normalize-stderr-test "(error: internal compiler error: [^:]+):\d+:\d+: " -> "$1:LL:CC: "

View file

@ -15,7 +15,5 @@ impl<T: MyTrait> !Send for TestType<T> {} //~ ERROR found both positive and nega
unsafe impl<T: 'static> Send for TestType<T> {} //~ ERROR conflicting implementations
impl !Send for TestType<i32> {}
//~^ WARNING
//~| WARNING this will change its meaning
fn main() {}

View file

@ -16,23 +16,7 @@ LL | unsafe impl<T: MyTrait + 'static> Send for TestType<T> {}
LL | unsafe impl<T: 'static> Send for TestType<T> {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `TestType<_>`
warning: cross-crate traits with a default impl, like `Send`, should not be specialized
--> $DIR/issue-106755.rs:17:1
|
LL | impl !Send for TestType<i32> {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= warning: this will change its meaning in a future release!
= note: for more information, see issue #93367 <https://github.com/rust-lang/rust/issues/93367>
= note: `i32` is not a generic parameter
note: try using the same sequence of generic parameters as the struct definition
--> $DIR/issue-106755.rs:9:1
|
LL | struct TestType<T>(::std::marker::PhantomData<T>);
| ^^^^^^^^^^^^^^^^^^
= note: `#[warn(suspicious_auto_trait_impls)]` on by default
error: aborting due to 2 previous errors; 1 warning emitted
error: aborting due to 2 previous errors
Some errors have detailed explanations: E0119, E0751.
For more information about an error, try `rustc --explain E0119`.

View file

@ -18,7 +18,6 @@ impl Foo for () {
type Baz<T> = impl Sized;
//~^ ERROR type `Baz` has 1 type parameter but its trait declaration has 0 type parameters
//~| ERROR unconstrained opaque type
fn test<'a>() -> Self::Bar<'a> {
&()

View file

@ -7,14 +7,6 @@ LL | type Baz<'a>;
LL | type Baz<T> = impl Sized;
| ^ found 1 type parameter
error: unconstrained opaque type
--> $DIR/impl-trait-in-type-alias-with-bad-substs.rs:19:19
|
LL | type Baz<T> = impl Sized;
| ^^^^^^^^^^
|
= note: `Baz` must be used in combination with a concrete type within the same impl
error: aborting due to 2 previous errors
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0049`.

View file

@ -1,5 +1,4 @@
//@ aux-build:tdticc_coherence_lib.rs
#![allow(suspicious_auto_trait_impls)]
// Test that we do not consider associated types to be sendable without
// some applicable trait bound (and we don't ICE).
@ -11,15 +10,15 @@
use lib::DefaultedTrait;
struct A;
impl DefaultedTrait for (A,) { } //~ ERROR E0117
impl DefaultedTrait for (A,) {} //~ ERROR E0117
struct B;
impl !DefaultedTrait for (B,) { } //~ ERROR E0117
impl !DefaultedTrait for (B,) {} //~ ERROR E0117
struct C;
struct D<T>(T);
impl DefaultedTrait for Box<C> { } //~ ERROR E0321
impl DefaultedTrait for lib::Something<C> { } //~ ERROR E0117
impl DefaultedTrait for D<C> { } // OK
impl DefaultedTrait for Box<C> {} //~ ERROR E0321
impl DefaultedTrait for lib::Something<C> {} //~ ERROR E0117
impl DefaultedTrait for D<C> {} // OK
fn main() { }
fn main() {}

View file

@ -1,7 +1,7 @@
error[E0117]: only traits defined in the current crate can be implemented for arbitrary types
--> $DIR/typeck-default-trait-impl-cross-crate-coherence.rs:14:1
--> $DIR/typeck-default-trait-impl-cross-crate-coherence.rs:13:1
|
LL | impl DefaultedTrait for (A,) { }
LL | impl DefaultedTrait for (A,) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^----
| | |
| | this is not defined in the current crate because tuples are always foreign
@ -10,9 +10,9 @@ LL | impl DefaultedTrait for (A,) { }
= note: define and implement a trait or new type instead
error[E0117]: only traits defined in the current crate can be implemented for arbitrary types
--> $DIR/typeck-default-trait-impl-cross-crate-coherence.rs:17:1
--> $DIR/typeck-default-trait-impl-cross-crate-coherence.rs:16:1
|
LL | impl !DefaultedTrait for (B,) { }
LL | impl !DefaultedTrait for (B,) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^----
| | |
| | this is not defined in the current crate because tuples are always foreign
@ -21,15 +21,15 @@ LL | impl !DefaultedTrait for (B,) { }
= note: define and implement a trait or new type instead
error[E0321]: cross-crate traits with a default impl, like `DefaultedTrait`, can only be implemented for a struct/enum type defined in the current crate
--> $DIR/typeck-default-trait-impl-cross-crate-coherence.rs:21:1
--> $DIR/typeck-default-trait-impl-cross-crate-coherence.rs:20:1
|
LL | impl DefaultedTrait for Box<C> { }
LL | impl DefaultedTrait for Box<C> {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't implement cross-crate trait for type in another crate
error[E0117]: only traits defined in the current crate can be implemented for types defined outside of the crate
--> $DIR/typeck-default-trait-impl-cross-crate-coherence.rs:22:1
--> $DIR/typeck-default-trait-impl-cross-crate-coherence.rs:21:1
|
LL | impl DefaultedTrait for lib::Something<C> { }
LL | impl DefaultedTrait for lib::Something<C> {}
| ^^^^^^^^^^^^^^^^^^^^^^^^-----------------
| | |
| | `Something` is not defined in the current crate

View file

@ -1,8 +1,7 @@
struct NeedsDropTypes<'tcx, F>(std::marker::PhantomData<&'tcx F>);
impl<'tcx, F, I> Iterator for NeedsDropTypes<'tcx, F>
//~^ ERROR type annotations needed
//~| ERROR not all trait items implemented
//~^ ERROR not all trait items implemented
where
F: Fn(&Missing) -> Result<I, ()>,
//~^ ERROR cannot find type `Missing` in this scope

View file

@ -1,37 +1,20 @@
error[E0412]: cannot find type `Missing` in this scope
--> $DIR/issue-110157.rs:7:12
--> $DIR/issue-110157.rs:6:12
|
LL | F: Fn(&Missing) -> Result<I, ()>,
| ^^^^^^^ not found in this scope
error[E0412]: cannot find type `Missing` in this scope
--> $DIR/issue-110157.rs:9:24
--> $DIR/issue-110157.rs:8:24
|
LL | I: Iterator<Item = Missing>,
| ^^^^^^^ not found in this scope
error[E0283]: type annotations needed
--> $DIR/issue-110157.rs:3:31
|
LL | impl<'tcx, F, I> Iterator for NeedsDropTypes<'tcx, F>
| ^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type for type parameter `I`
|
= note: cannot satisfy `_: Iterator`
note: required for `NeedsDropTypes<'tcx, F>` to implement `Iterator`
--> $DIR/issue-110157.rs:3:18
|
LL | impl<'tcx, F, I> Iterator for NeedsDropTypes<'tcx, F>
| ^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^
...
LL | I: Iterator<Item = Missing>,
| ------------------------ unsatisfied trait bound introduced here
error[E0046]: not all trait items implemented, missing: `Item`, `next`
--> $DIR/issue-110157.rs:3:1
|
LL | / impl<'tcx, F, I> Iterator for NeedsDropTypes<'tcx, F>
LL | |
LL | |
LL | | where
LL | | F: Fn(&Missing) -> Result<I, ()>,
LL | |
@ -41,7 +24,7 @@ LL | | I: Iterator<Item = Missing>,
= help: implement the missing item: `type Item = /* Type */;`
= help: implement the missing item: `fn next(&mut self) -> Option<<Self as Iterator>::Item> { todo!() }`
error: aborting due to 4 previous errors
error: aborting due to 3 previous errors
Some errors have detailed explanations: E0046, E0283, E0412.
Some errors have detailed explanations: E0046, E0412.
For more information about an error, try `rustc --explain E0046`.