1
Fork 0

Auto merge of #133516 - compiler-errors:rollup-mq334h8, r=compiler-errors

Rollup of 8 pull requests

Successful merges:

 - #115293 (Remove -Zfuel.)
 - #132605 (CI: increase timeout from 4h to 6h)
 - #133304 (Revert diagnostics hack to fix ICE 132920)
 - #133402 (Constify `Drop` and `Destruct`)
 - #133458 (Fix `Result` and `Option` not getting a jump to def link generated)
 - #133471 (gce: fix typing_mode mismatch)
 - #133475 (`MaybeStorage` improvements)
 - #133513 (Only ignore windows-gnu in avr-jmp-offset)

r? `@ghost`
`@rustbot` modify labels: rollup
This commit is contained in:
bors 2024-11-27 02:13:49 +00:00
commit 48696f5bd6
73 changed files with 388 additions and 1086 deletions

View file

@ -65,7 +65,7 @@ jobs:
defaults:
run:
shell: ${{ contains(matrix.os, 'windows') && 'msys2 {0}' || 'bash' }}
timeout-minutes: 240
timeout-minutes: 360
env:
CI_JOB_NAME: ${{ matrix.image }}
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse

View file

@ -18,8 +18,7 @@ use rustc_middle::span_bug;
use rustc_middle::ty::adjustment::PointerCoercion;
use rustc_middle::ty::{self, Ty, TypeVisitableExt};
use rustc_mir_dataflow::Analysis;
use rustc_mir_dataflow::impls::MaybeStorageLive;
use rustc_mir_dataflow::storage::always_storage_live_locals;
use rustc_mir_dataflow::impls::{MaybeStorageLive, always_storage_live_locals};
use rustc_span::{Span, Symbol, sym};
use rustc_trait_selection::traits::{
Obligation, ObligationCause, ObligationCauseCode, ObligationCtxt,

View file

@ -10,7 +10,7 @@ use rustc_index::IndexVec;
use rustc_middle::ty::layout::{LayoutOf, TyAndLayout};
use rustc_middle::ty::{self, Ty, TyCtxt};
use rustc_middle::{bug, mir};
use rustc_mir_dataflow::storage::always_storage_live_locals;
use rustc_mir_dataflow::impls::always_storage_live_locals;
use rustc_span::Span;
use tracing::{info_span, instrument, trace};

View file

@ -472,10 +472,6 @@ fn run_compiler(
linker.link(sess, codegen_backend)?
}
if let Some(fuel) = sess.opts.unstable_opts.print_fuel.as_deref() {
eprintln!("Fuel used by {}: {}", fuel, sess.print_fuel.load(Ordering::SeqCst));
}
Ok(())
})
}

View file

@ -784,7 +784,6 @@ fn test_unstable_options_tracking_hash() {
tracked!(flatten_format_args, false);
tracked!(fmt_debug, FmtDebug::Shallow);
tracked!(force_unstable_if_unmarked, true);
tracked!(fuel, Some(("abc".to_string(), 99)));
tracked!(function_return, FunctionReturn::ThunkExtern);
tracked!(function_sections, Some(false));
tracked!(human_readable_cgu_names, true);
@ -830,7 +829,6 @@ fn test_unstable_options_tracking_hash() {
tracked!(plt, Some(true));
tracked!(polonius, Polonius::Legacy);
tracked!(precise_enum_drop_elaboration, false);
tracked!(print_fuel, Some("abc".to_string()));
tracked!(profile_sample_use, Some(PathBuf::from("abc")));
tracked!(profiler_runtime, "abc".to_string());
tracked!(regparm, Some(3));

View file

@ -1566,10 +1566,6 @@ impl<'tcx> TyCtxt<'tcx> {
}
}
pub fn consider_optimizing<T: Fn() -> String>(self, msg: T) -> bool {
self.sess.consider_optimizing(|| self.crate_name(LOCAL_CRATE), msg)
}
/// Obtain all lang items of this crate and all dependencies (recursively)
pub fn lang_items(self) -> &'tcx rustc_hir::lang_items::LanguageItems {
self.get_lang_items(())

View file

@ -1558,10 +1558,7 @@ impl<'tcx> TyCtxt<'tcx> {
let is_box = self.is_lang_item(did.to_def_id(), LangItem::OwnedBox);
// This is here instead of layout because the choice must make it into metadata.
if is_box
|| !self
.consider_optimizing(|| format!("Reorder fields of {:?}", self.def_path_str(did)))
{
if is_box {
flags.insert(ReprFlags::IS_LINEAR);
}

View file

@ -14,4 +14,6 @@ pub use self::initialized::{
pub use self::liveness::{
MaybeLiveLocals, MaybeTransitiveLiveLocals, TransferFunction as LivenessTransferFunction,
};
pub use self::storage_liveness::{MaybeRequiresStorage, MaybeStorageDead, MaybeStorageLive};
pub use self::storage_liveness::{
MaybeRequiresStorage, MaybeStorageDead, MaybeStorageLive, always_storage_live_locals,
};

View file

@ -7,6 +7,23 @@ use rustc_middle::mir::*;
use super::MaybeBorrowedLocals;
use crate::{Analysis, GenKill, ResultsCursor};
/// The set of locals in a MIR body that do not have `StorageLive`/`StorageDead` annotations.
///
/// These locals have fixed storage for the duration of the body.
pub fn always_storage_live_locals(body: &Body<'_>) -> BitSet<Local> {
let mut always_live_locals = BitSet::new_filled(body.local_decls.len());
for block in &*body.basic_blocks {
for statement in &block.statements {
if let StatementKind::StorageLive(l) | StatementKind::StorageDead(l) = statement.kind {
always_live_locals.remove(l);
}
}
}
always_live_locals
}
pub struct MaybeStorageLive<'a> {
always_live_locals: Cow<'a, BitSet<Local>>,
}
@ -28,10 +45,7 @@ impl<'a, 'tcx> Analysis<'tcx> for MaybeStorageLive<'a> {
}
fn initialize_start_block(&self, body: &Body<'tcx>, on_entry: &mut Self::Domain) {
assert_eq!(body.local_decls.len(), self.always_live_locals.domain_size());
for local in self.always_live_locals.iter() {
on_entry.insert(local);
}
on_entry.union(&*self.always_live_locals);
for arg in body.args_iter() {
on_entry.insert(arg);

View file

@ -25,7 +25,7 @@ pub use self::framework::{
use self::move_paths::MoveData;
pub mod debuginfo;
pub mod drop_flag_effects;
mod drop_flag_effects;
pub mod elaborate_drops;
mod errors;
mod framework;
@ -33,8 +33,7 @@ pub mod impls;
pub mod move_paths;
pub mod points;
pub mod rustc_peek;
pub mod storage;
pub mod un_derefer;
mod un_derefer;
pub mod value_analysis;
rustc_fluent_macro::fluent_messages! { "../messages.ftl" }

View file

@ -1,20 +0,0 @@
use rustc_index::bit_set::BitSet;
use rustc_middle::mir::{self, Local};
/// The set of locals in a MIR body that do not have `StorageLive`/`StorageDead` annotations.
///
/// These locals have fixed storage for the duration of the body.
pub fn always_storage_live_locals(body: &mir::Body<'_>) -> BitSet<Local> {
let mut always_live_locals = BitSet::new_filled(body.local_decls.len());
for block in &*body.basic_blocks {
for statement in &block.statements {
use mir::StatementKind::{StorageDead, StorageLive};
if let StorageLive(l) | StorageDead(l) = statement.kind {
always_live_locals.remove(l);
}
}
}
always_live_locals
}

View file

@ -70,8 +70,8 @@ use rustc_middle::ty::{
use rustc_middle::{bug, span_bug};
use rustc_mir_dataflow::impls::{
MaybeBorrowedLocals, MaybeLiveLocals, MaybeRequiresStorage, MaybeStorageLive,
always_storage_live_locals,
};
use rustc_mir_dataflow::storage::always_storage_live_locals;
use rustc_mir_dataflow::{Analysis, Results, ResultsVisitor};
use rustc_span::Span;
use rustc_span::def_id::{DefId, LocalDefId};
@ -696,8 +696,7 @@ fn locals_live_across_suspend_points<'tcx>(
let loc = Location { block, statement_index: data.statements.len() };
liveness.seek_to_block_end(block);
let mut live_locals: BitSet<_> = BitSet::new_empty(body.local_decls.len());
live_locals.union(liveness.get());
let mut live_locals = liveness.get().clone();
if !movable {
// The `liveness` variable contains the liveness of MIR locals ignoring borrows.

View file

@ -217,11 +217,6 @@ impl<'tcx> crate::MirPass<'tcx> for DestinationPropagation {
else {
continue;
};
if !tcx.consider_optimizing(|| {
format!("{} round {}", tcx.def_path_str(def_id), round_count)
}) {
break;
}
// Replace `src` by `dest` everywhere.
merges.insert(*src, *dest);

View file

@ -108,10 +108,6 @@ impl<'tcx> crate::MirPass<'tcx> for EarlyOtherwiseBranch {
let parent = BasicBlock::from_usize(i);
let Some(opt_data) = evaluate_candidate(tcx, body, parent) else { continue };
if !tcx.consider_optimizing(|| format!("EarlyOtherwiseBranch {opt_data:?}")) {
break;
}
trace!("SUCCESS: found optimization possibility to apply: {opt_data:?}");
should_cleanup = true;

View file

@ -210,12 +210,6 @@ impl<'tcx> Inliner<'tcx> {
let callee_body = try_instance_mir(self.tcx, callsite.callee.def)?;
self.check_mir_body(callsite, callee_body, callee_attrs, cross_crate_inlinable)?;
if !self.tcx.consider_optimizing(|| {
format!("Inline {:?} into {:?}", callsite.callee, caller_body.source)
}) {
return Err("optimization fuel exhausted");
}
let Ok(callee_body) = callsite.callee.try_instantiate_mir_and_normalize_erasing_regions(
self.tcx,
self.typing_env,

View file

@ -7,8 +7,8 @@ use rustc_middle::bug;
use rustc_middle::mir::*;
use rustc_middle::ty::layout::ValidityRequirement;
use rustc_middle::ty::{self, GenericArgsRef, Ty, TyCtxt, layout};
use rustc_span::sym;
use rustc_span::symbol::Symbol;
use rustc_span::{DUMMY_SP, sym};
use crate::simplify::simplify_duplicate_switch_targets;
use crate::take_array;
@ -43,12 +43,12 @@ impl<'tcx> crate::MirPass<'tcx> for InstSimplify {
match statement.kind {
StatementKind::Assign(box (_place, ref mut rvalue)) => {
if !preserve_ub_checks {
ctx.simplify_ub_check(&statement.source_info, rvalue);
ctx.simplify_ub_check(rvalue);
}
ctx.simplify_bool_cmp(&statement.source_info, rvalue);
ctx.simplify_ref_deref(&statement.source_info, rvalue);
ctx.simplify_len(&statement.source_info, rvalue);
ctx.simplify_ptr_aggregate(&statement.source_info, rvalue);
ctx.simplify_bool_cmp(rvalue);
ctx.simplify_ref_deref(rvalue);
ctx.simplify_len(rvalue);
ctx.simplify_ptr_aggregate(rvalue);
ctx.simplify_cast(rvalue);
}
_ => {}
@ -70,23 +70,8 @@ struct InstSimplifyContext<'a, 'tcx> {
}
impl<'tcx> InstSimplifyContext<'_, 'tcx> {
fn should_simplify(&self, source_info: &SourceInfo, rvalue: &Rvalue<'tcx>) -> bool {
self.should_simplify_custom(source_info, "Rvalue", rvalue)
}
fn should_simplify_custom(
&self,
source_info: &SourceInfo,
label: &str,
value: impl std::fmt::Debug,
) -> bool {
self.tcx.consider_optimizing(|| {
format!("InstSimplify - {label}: {value:?} SourceInfo: {source_info:?}")
})
}
/// Transform boolean comparisons into logical operations.
fn simplify_bool_cmp(&self, source_info: &SourceInfo, rvalue: &mut Rvalue<'tcx>) {
fn simplify_bool_cmp(&self, rvalue: &mut Rvalue<'tcx>) {
match rvalue {
Rvalue::BinaryOp(op @ (BinOp::Eq | BinOp::Ne), box (a, b)) => {
let new = match (op, self.try_eval_bool(a), self.try_eval_bool(b)) {
@ -117,9 +102,7 @@ impl<'tcx> InstSimplifyContext<'_, 'tcx> {
_ => None,
};
if let Some(new) = new
&& self.should_simplify(source_info, rvalue)
{
if let Some(new) = new {
*rvalue = new;
}
}
@ -134,17 +117,13 @@ impl<'tcx> InstSimplifyContext<'_, 'tcx> {
}
/// Transform `&(*a)` ==> `a`.
fn simplify_ref_deref(&self, source_info: &SourceInfo, rvalue: &mut Rvalue<'tcx>) {
fn simplify_ref_deref(&self, rvalue: &mut Rvalue<'tcx>) {
if let Rvalue::Ref(_, _, place) | Rvalue::RawPtr(_, place) = rvalue {
if let Some((base, ProjectionElem::Deref)) = place.as_ref().last_projection() {
if rvalue.ty(self.local_decls, self.tcx) != base.ty(self.local_decls, self.tcx).ty {
return;
}
if !self.should_simplify(source_info, rvalue) {
return;
}
*rvalue = Rvalue::Use(Operand::Copy(Place {
local: base.local,
projection: self.tcx.mk_place_elems(base.projection),
@ -154,36 +133,24 @@ impl<'tcx> InstSimplifyContext<'_, 'tcx> {
}
/// Transform `Len([_; N])` ==> `N`.
fn simplify_len(&self, source_info: &SourceInfo, rvalue: &mut Rvalue<'tcx>) {
fn simplify_len(&self, rvalue: &mut Rvalue<'tcx>) {
if let Rvalue::Len(ref place) = *rvalue {
let place_ty = place.ty(self.local_decls, self.tcx).ty;
if let ty::Array(_, len) = *place_ty.kind() {
if !self.should_simplify(source_info, rvalue) {
return;
}
let const_ = Const::from_ty_const(len, self.tcx.types.usize, self.tcx);
let constant = ConstOperand { span: source_info.span, const_, user_ty: None };
let constant = ConstOperand { span: DUMMY_SP, const_, user_ty: None };
*rvalue = Rvalue::Use(Operand::Constant(Box::new(constant)));
}
}
}
/// Transform `Aggregate(RawPtr, [p, ()])` ==> `Cast(PtrToPtr, p)`.
fn simplify_ptr_aggregate(&self, source_info: &SourceInfo, rvalue: &mut Rvalue<'tcx>) {
fn simplify_ptr_aggregate(&self, rvalue: &mut Rvalue<'tcx>) {
if let Rvalue::Aggregate(box AggregateKind::RawPtr(pointee_ty, mutability), fields) = rvalue
{
let meta_ty = fields.raw[1].ty(self.local_decls, self.tcx);
if meta_ty.is_unit() {
// The mutable borrows we're holding prevent printing `rvalue` here
if !self.should_simplify_custom(
source_info,
"Aggregate::RawPtr",
(&pointee_ty, *mutability, &fields),
) {
return;
}
let mut fields = std::mem::take(fields);
let _meta = fields.pop().unwrap();
let data = fields.pop().unwrap();
@ -193,10 +160,10 @@ impl<'tcx> InstSimplifyContext<'_, 'tcx> {
}
}
fn simplify_ub_check(&self, source_info: &SourceInfo, rvalue: &mut Rvalue<'tcx>) {
fn simplify_ub_check(&self, rvalue: &mut Rvalue<'tcx>) {
if let Rvalue::NullaryOp(NullOp::UbChecks, _) = *rvalue {
let const_ = Const::from_bool(self.tcx, self.tcx.sess.ub_checks());
let constant = ConstOperand { span: source_info.span, const_, user_ty: None };
let constant = ConstOperand { span: DUMMY_SP, const_, user_ty: None };
*rvalue = Rvalue::Use(Operand::Constant(Box::new(constant)));
}
}
@ -284,16 +251,6 @@ impl<'tcx> InstSimplifyContext<'_, 'tcx> {
return;
}
if !self.tcx.consider_optimizing(|| {
format!(
"InstSimplify - Call: {:?} SourceInfo: {:?}",
(fn_def_id, fn_args),
terminator.source_info
)
}) {
return;
}
let Ok([arg]) = take_array(args) else { return };
let Some(arg_place) = arg.node.place() else { return };

View file

@ -9,8 +9,7 @@ use rustc_index::bit_set::BitSet;
use rustc_middle::mir::visit::{PlaceContext, Visitor};
use rustc_middle::mir::*;
use rustc_middle::ty::TyCtxt;
use rustc_mir_dataflow::impls::{MaybeStorageDead, MaybeStorageLive};
use rustc_mir_dataflow::storage::always_storage_live_locals;
use rustc_mir_dataflow::impls::{MaybeStorageDead, MaybeStorageLive, always_storage_live_locals};
use rustc_mir_dataflow::{Analysis, ResultsCursor};
pub(super) fn lint_body<'tcx>(tcx: TyCtxt<'tcx>, body: &Body<'tcx>, when: String) {

View file

@ -18,16 +18,11 @@ impl<'tcx> crate::MirPass<'tcx> for MatchBranchSimplification {
}
fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
let def_id = body.source.def_id();
let typing_env = body.typing_env(tcx);
let mut should_cleanup = false;
for i in 0..body.basic_blocks.len() {
let bbs = &*body.basic_blocks;
let bb_idx = BasicBlock::from_usize(i);
if !tcx.consider_optimizing(|| format!("MatchBranchSimplification {def_id:?} ")) {
continue;
}
match bbs[bb_idx].terminator().kind {
TerminatorKind::SwitchInt {
discr: ref _discr @ (Operand::Copy(_) | Operand::Move(_)),

View file

@ -14,10 +14,9 @@ impl<'tcx> crate::MirPass<'tcx> for MultipleReturnTerminators {
sess.mir_opt_level() >= 4
}
fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
fn run_pass(&self, _: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
// find basic blocks with no statement and a return terminator
let mut bbs_simple_returns = BitSet::new_empty(body.basic_blocks.len());
let def_id = body.source.def_id();
let bbs = body.basic_blocks_mut();
for idx in bbs.indices() {
if bbs[idx].statements.is_empty()
@ -28,10 +27,6 @@ impl<'tcx> crate::MirPass<'tcx> for MultipleReturnTerminators {
}
for bb in bbs {
if !tcx.consider_optimizing(|| format!("MultipleReturnTerminators {def_id:?} ")) {
break;
}
if let TerminatorKind::Goto { target } = bb.terminator().kind {
if bbs_simple_returns.contains(target) {
bb.terminator_mut().kind = TerminatorKind::Return;

View file

@ -45,10 +45,6 @@ impl<'tcx> crate::MirPass<'tcx> for RenameReturnPlace {
return;
};
if !tcx.consider_optimizing(|| format!("RenameReturnPlace {def_id:?}")) {
return;
}
debug!(
"`{:?}` was eligible for NRVO, making {:?} the return place",
def_id, returned_local

View file

@ -8,8 +8,7 @@ use rustc_middle::mir::visit::*;
use rustc_middle::mir::*;
use rustc_middle::ty::TyCtxt;
use rustc_mir_dataflow::Analysis;
use rustc_mir_dataflow::impls::MaybeStorageDead;
use rustc_mir_dataflow::storage::always_storage_live_locals;
use rustc_mir_dataflow::impls::{MaybeStorageDead, always_storage_live_locals};
use tracing::{debug, instrument};
use crate::ssa::{SsaLocals, StorageLiveLocals};

View file

@ -26,11 +26,6 @@ impl<'tcx> crate::MirPass<'tcx> for RemoveUnneededDrops {
if ty.ty.needs_drop(tcx, typing_env) {
continue;
}
if !tcx.consider_optimizing(|| {
format!("RemoveUnneededDrops {:?}", body.source.def_id())
}) {
continue;
}
debug!("SUCCESS: replacing `drop` with goto({:?})", target);
terminator.kind = TerminatorKind::Goto { target };
should_simplify = true;

View file

@ -17,10 +17,6 @@ impl<'tcx> crate::MirPass<'tcx> for RemoveZsts {
return;
}
if !tcx.consider_optimizing(|| format!("RemoveZsts - {:?}", body.source.def_id())) {
return;
}
let typing_env = body.typing_env(tcx);
let local_decls = &body.local_decls;
let mut replacer = Replacer { tcx, typing_env, local_decls };
@ -94,16 +90,12 @@ impl<'tcx> MutVisitor<'tcx> for Replacer<'_, 'tcx> {
}
}
fn visit_operand(&mut self, operand: &mut Operand<'tcx>, loc: Location) {
fn visit_operand(&mut self, operand: &mut Operand<'tcx>, _: Location) {
if let Operand::Constant(_) = operand {
return;
}
let op_ty = operand.ty(self.local_decls, self.tcx);
if self.known_to_be_zst(op_ty)
&& self.tcx.consider_optimizing(|| {
format!("RemoveZsts - Operand: {operand:?} Location: {loc:?}")
})
{
if self.known_to_be_zst(op_ty) {
*operand = Operand::Constant(Box::new(self.make_zst(op_ty)))
}
}

View file

@ -43,12 +43,6 @@ impl crate::MirPass<'_> for UnreachablePropagation {
}
}
if !tcx
.consider_optimizing(|| format!("UnreachablePropagation {:?} ", body.source.def_id()))
{
return;
}
patch.apply(body);
// We do want do keep some unreachable blocks, but make them empty.

View file

@ -84,8 +84,6 @@ session_not_supported = not supported
session_octal_float_literal_not_supported = octal float literal is not supported
session_optimization_fuel_exhausted = optimization-fuel-exhausted: {$msg}
session_profile_sample_use_file_does_not_exist = file `{$path}` passed to `-C profile-sample-use` does not exist
session_profile_use_file_does_not_exist = file `{$path}` passed to `-C profile-use` does not exist

View file

@ -2356,14 +2356,6 @@ pub fn build_session_options(early_dcx: &mut EarlyDiagCtxt, matches: &getopts::M
early_dcx.early_warn(format!("number of threads was capped at {}", parse::MAX_THREADS_CAP));
}
let fuel = unstable_opts.fuel.is_some() || unstable_opts.print_fuel.is_some();
if fuel && unstable_opts.threads > 1 {
early_dcx.early_fatal("optimization fuel is incompatible with multiple threads");
}
if fuel && cg.incremental.is_some() {
early_dcx.early_fatal("optimization fuel is incompatible with incremental compilation");
}
let incremental = cg.incremental.as_ref().map(PathBuf::from);
let assert_incr_state = parse_assert_incr_state(early_dcx, &unstable_opts.assert_incr_state);

View file

@ -463,12 +463,6 @@ pub fn report_lit_error(
}
}
#[derive(Diagnostic)]
#[diag(session_optimization_fuel_exhausted)]
pub(crate) struct OptimisationFuelExhausted {
pub(crate) msg: String,
}
#[derive(Diagnostic)]
#[diag(session_incompatible_linker_flavor)]
#[note]

View file

@ -394,7 +394,6 @@ mod desc {
pub(crate) const parse_collapse_macro_debuginfo: &str = "one of `no`, `external`, or `yes`";
pub(crate) const parse_strip: &str = "either `none`, `debuginfo`, or `symbols`";
pub(crate) const parse_linker_flavor: &str = ::rustc_target::spec::LinkerFlavorCli::one_of();
pub(crate) const parse_optimization_fuel: &str = "crate=integer";
pub(crate) const parse_dump_mono_stats: &str = "`markdown` (default) or `json`";
pub(crate) const parse_instrument_coverage: &str = parse_bool;
pub(crate) const parse_coverage_options: &str =
@ -948,21 +947,6 @@ pub mod parse {
true
}
pub(crate) fn parse_optimization_fuel(
slot: &mut Option<(String, u64)>,
v: Option<&str>,
) -> bool {
match v {
None => false,
Some(s) => {
let [crate_name, fuel] = *s.split('=').collect::<Vec<_>>() else { return false };
let Ok(fuel) = fuel.parse::<u64>() else { return false };
*slot = Some((crate_name.to_string(), fuel));
true
}
}
}
pub(crate) fn parse_unpretty(slot: &mut Option<String>, v: Option<&str>) -> bool {
match v {
None => false,
@ -1794,8 +1778,6 @@ options! {
`shallow` prints only type names, `none` prints nothing and disables `{:?}`. (default: `full`)"),
force_unstable_if_unmarked: bool = (false, parse_bool, [TRACKED],
"force all crates to be `rustc_private` unstable (default: no)"),
fuel: Option<(String, u64)> = (None, parse_optimization_fuel, [TRACKED],
"set the optimization fuel quota for a crate"),
function_return: FunctionReturn = (FunctionReturn::default(), parse_function_return, [TRACKED],
"replace returns with jumps to `__x86_return_thunk` (default: `keep`)"),
function_sections: Option<bool> = (None, parse_opt_bool, [TRACKED],
@ -1978,8 +1960,6 @@ options! {
#[rustc_lint_opt_deny_field_access("use `Session::print_codegen_stats` instead of this field")]
print_codegen_stats: bool = (false, parse_bool, [UNTRACKED],
"print codegen statistics (default: no)"),
print_fuel: Option<String> = (None, parse_opt_string, [TRACKED],
"make rustc print the total optimization fuel used by a crate"),
print_llvm_passes: bool = (false, parse_bool, [UNTRACKED],
"print the LLVM optimization passes being run (default: no)"),
print_mono_items: Option<String> = (None, parse_opt_string, [UNTRACKED],

View file

@ -4,7 +4,6 @@ use std::path::{Path, PathBuf};
use std::str::FromStr;
use std::sync::Arc;
use std::sync::atomic::AtomicBool;
use std::sync::atomic::Ordering::SeqCst;
use std::{env, fmt, io};
use rustc_data_structures::flock;
@ -12,7 +11,7 @@ use rustc_data_structures::fx::{FxHashMap, FxIndexSet};
use rustc_data_structures::jobserver::{self, Client};
use rustc_data_structures::profiling::{SelfProfiler, SelfProfilerRef};
use rustc_data_structures::sync::{
AtomicU64, DynSend, DynSync, Lock, Lrc, MappedReadGuard, ReadGuard, RwLock,
DynSend, DynSync, Lock, Lrc, MappedReadGuard, ReadGuard, RwLock,
};
use rustc_errors::annotate_snippet_emitter_writer::AnnotateSnippetEmitter;
use rustc_errors::codes::*;
@ -49,13 +48,6 @@ use crate::parse::{ParseSess, add_feature_diagnostics};
use crate::search_paths::SearchPath;
use crate::{errors, filesearch, lint};
struct OptimizationFuel {
/// If `-zfuel=crate=n` is specified, initially set to `n`, otherwise `0`.
remaining: u64,
/// We're rejecting all further optimizations.
out_of_fuel: bool,
}
/// The behavior of the CTFE engine when an error occurs with regards to backtraces.
#[derive(Clone, Copy)]
pub enum CtfeBacktrace {
@ -163,12 +155,6 @@ pub struct Session {
/// Data about code being compiled, gathered during compilation.
pub code_stats: CodeStats,
/// Tracks fuel info if `-zfuel=crate=n` is specified.
optimization_fuel: Lock<OptimizationFuel>,
/// Always set to zero and incremented so that we can print fuel expended by a crate.
pub print_fuel: AtomicU64,
/// Loaded up early on in the initialization of this `Session` to avoid
/// false positives about a job server in our environment.
pub jobserver: Client,
@ -532,41 +518,6 @@ impl Session {
self.opts.incremental.as_ref().map(|_| self.incr_comp_session_dir())
}
/// We want to know if we're allowed to do an optimization for crate foo from -z fuel=foo=n.
/// This expends fuel if applicable, and records fuel if applicable.
pub fn consider_optimizing(
&self,
get_crate_name: impl Fn() -> Symbol,
msg: impl Fn() -> String,
) -> bool {
let mut ret = true;
if let Some((ref c, _)) = self.opts.unstable_opts.fuel {
if c == get_crate_name().as_str() {
assert_eq!(self.threads(), 1);
let mut fuel = self.optimization_fuel.lock();
ret = fuel.remaining != 0;
if fuel.remaining == 0 && !fuel.out_of_fuel {
if self.dcx().can_emit_warnings() {
// We only call `msg` in case we can actually emit warnings.
// Otherwise, this could cause a `must_produce_diag` ICE
// (issue #79546).
self.dcx().emit_warn(errors::OptimisationFuelExhausted { msg: msg() });
}
fuel.out_of_fuel = true;
} else if fuel.remaining > 0 {
fuel.remaining -= 1;
}
}
}
if let Some(ref c) = self.opts.unstable_opts.print_fuel {
if c == get_crate_name().as_str() {
assert_eq!(self.threads(), 1);
self.print_fuel.fetch_add(1, SeqCst);
}
}
ret
}
/// Is this edition 2015?
pub fn is_rust_2015(&self) -> bool {
self.edition().is_rust_2015()
@ -1097,12 +1048,6 @@ pub fn build_session(
Lrc::new(SearchPath::from_sysroot_and_triple(&sysroot, target_triple))
};
let optimization_fuel = Lock::new(OptimizationFuel {
remaining: sopts.unstable_opts.fuel.as_ref().map_or(0, |&(_, i)| i),
out_of_fuel: false,
});
let print_fuel = AtomicU64::new(0);
let prof = SelfProfilerRef::new(
self_profiler,
sopts.unstable_opts.time_passes.then(|| sopts.unstable_opts.time_passes_format),
@ -1130,8 +1075,6 @@ pub fn build_session(
incr_comp_session: RwLock::new(IncrCompSession::NotInitialized),
prof,
code_stats: Default::default(),
optimization_fuel,
print_fuel,
jobserver: jobserver::client(),
lint_store: None,
registered_lints: false,

View file

@ -1803,24 +1803,6 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
StringPart::highlighted("cargo tree".to_string()),
StringPart::normal("` to explore your dependency tree".to_string()),
]);
// FIXME: this is a giant hack for the benefit of this specific diagnostic. Because
// we're so nested in method calls before the error gets emitted, bubbling a single bit
// flag informing the top level caller to stop adding extra detail to the diagnostic,
// would actually be harder to follow. So we do something naughty here: we consume the
// diagnostic, emit it and leave in its place a "delayed bug" that will continue being
// modified but won't actually be printed to end users. This *is not ideal*, but allows
// us to reduce the verbosity of an error that is already quite verbose and increase its
// specificity. Below we modify the main message as well, in a way that *could* break if
// the implementation of Diagnostics change significantly, but that would be caught with
// a make test failure when this diagnostic is tested.
err.primary_message(format!(
"{} because the trait comes from a different crate version",
err.messages[0].0.as_str().unwrap(),
));
let diag = err.clone();
err.downgrade_to_delayed_bug();
self.tcx.dcx().emit_diagnostic(diag);
return true;
}

View file

@ -551,8 +551,18 @@ pub fn try_evaluate_const<'tcx>(
| ty::ConstKind::Placeholder(_)
| ty::ConstKind::Expr(_) => Err(EvaluateConstErr::HasGenericsOrInfers),
ty::ConstKind::Unevaluated(uv) => {
// Postpone evaluation of constants that depend on generic parameters or inference variables.
let (args, param_env) = if tcx.features().generic_const_exprs()
// Postpone evaluation of constants that depend on generic parameters or
// inference variables.
//
// We use `TypingMode::PostAnalysis` here which is not *technically* correct
// to be revealing opaque types here as borrowcheck has not run yet. However,
// CTFE itself uses `TypingMode::PostAnalysis` unconditionally even during
// typeck and not doing so has a lot of (undesirable) fallout (#101478, #119821).
// As a result we always use a revealed env when resolving the instance to evaluate.
//
// FIXME: `const_eval_resolve_for_typeck` should probably just modify the env itself
// instead of having this logic here
let (args, typing_env) = if tcx.features().generic_const_exprs()
&& uv.has_non_region_infer()
{
// `feature(generic_const_exprs)` causes anon consts to inherit all parent generics. This can cause
@ -568,13 +578,17 @@ pub fn try_evaluate_const<'tcx>(
// the generic arguments provided for it, then we should *not* attempt to evaluate it.
return Err(EvaluateConstErr::HasGenericsOrInfers);
} else {
(replace_param_and_infer_args_with_placeholder(tcx, uv.args), param_env)
let args = replace_param_and_infer_args_with_placeholder(tcx, uv.args);
let typing_env = infcx
.typing_env(tcx.erase_regions(param_env))
.with_post_analysis_normalized(tcx);
(args, typing_env)
}
}
Err(_) | Ok(None) => {
let args = GenericArgs::identity_for_item(tcx, uv.def);
let param_env = tcx.param_env(uv.def);
(args, param_env)
let typing_env = ty::TypingEnv::post_analysis(tcx, uv.def);
(args, typing_env)
}
}
} else if tcx.def_kind(uv.def) == DefKind::AnonConst && uv.has_non_region_infer() {
@ -593,27 +607,20 @@ pub fn try_evaluate_const<'tcx>(
);
let args = GenericArgs::identity_for_item(tcx, uv.def);
let param_env = tcx.param_env(uv.def);
(args, param_env)
let typing_env = ty::TypingEnv::post_analysis(tcx, uv.def);
(args, typing_env)
} else {
// FIXME: This codepath is reachable under `associated_const_equality` and in the
// future will be reachable by `min_generic_const_args`. We should handle inference
// variables and generic parameters properly instead of doing nothing.
(uv.args, param_env)
let typing_env = infcx
.typing_env(tcx.erase_regions(param_env))
.with_post_analysis_normalized(tcx);
(uv.args, typing_env)
};
let uv = ty::UnevaluatedConst::new(uv.def, args);
// It's not *technically* correct to be revealing opaque types here as borrowcheck has
// not run yet. However, CTFE itself uses `TypingMode::PostAnalysis` unconditionally even
// during typeck and not doing so has a lot of (undesirable) fallout (#101478, #119821).
// As a result we always use a revealed env when resolving the instance to evaluate.
//
// FIXME: `const_eval_resolve_for_typeck` should probably just modify the env itself
// instead of having this logic here
let typing_env =
tcx.erase_regions(infcx.typing_env(param_env)).with_post_analysis_normalized(tcx);
let erased_uv = tcx.erase_regions(uv);
use rustc_middle::mir::interpret::ErrorHandled;
match tcx.const_eval_resolve_for_typeck(typing_env, erased_uv, DUMMY_SP) {
Ok(Ok(val)) => Ok(ty::Const::new_value(

View file

@ -957,6 +957,7 @@ marker_impls! {
#[lang = "destruct"]
#[rustc_on_unimplemented(message = "can't drop `{Self}`", append_const_msg)]
#[rustc_deny_explicit_impl(implement_via_object = false)]
#[cfg_attr(not(bootstrap), const_trait)]
pub trait Destruct {}
/// A marker for tuple types.

View file

@ -203,7 +203,7 @@
/// [nomicon]: ../../nomicon/phantom-data.html#an-exception-the-special-case-of-the-standard-library-and-its-unstable-may_dangle
#[lang = "drop"]
#[stable(feature = "rust1", since = "1.0.0")]
// FIXME(const_trait_impl) #[const_trait]
#[cfg_attr(not(bootstrap), const_trait)]
pub trait Drop {
/// Executes the destructor for this type.
///

View file

@ -181,6 +181,9 @@ impl<'a, 'tcx, F: Write> TokenHandler<'a, 'tcx, F> {
// current parent tag is not the same as our pending content.
let close_tag = if self.pending_elems.len() > 1
&& let Some(current_class) = current_class
// `PreludeTy` can never include more than an ident so it should not generate
// a wrapping `span`.
&& !matches!(current_class, Class::PreludeTy(_))
{
Some(enter_span(self.out, current_class, &self.href_context))
} else {
@ -333,7 +336,7 @@ enum Class {
/// `Ident` isn't rendered in the HTML but we still need it for the `Span` it contains.
Ident(Span),
Lifetime,
PreludeTy,
PreludeTy(Span),
PreludeVal,
QuestionMark,
Decoration(&'static str),
@ -381,7 +384,7 @@ impl Class {
Class::Bool => "bool-val",
Class::Ident(_) => "",
Class::Lifetime => "lifetime",
Class::PreludeTy => "prelude-ty",
Class::PreludeTy(_) => "prelude-ty",
Class::PreludeVal => "prelude-val",
Class::QuestionMark => "question-mark",
Class::Decoration(kind) => kind,
@ -392,7 +395,7 @@ impl Class {
/// a "span" (a tuple representing `(lo, hi)` equivalent of `Span`).
fn get_span(self) -> Option<Span> {
match self {
Self::Ident(sp) | Self::Self_(sp) | Self::Macro(sp) => Some(sp),
Self::Ident(sp) | Self::Self_(sp) | Self::Macro(sp) | Self::PreludeTy(sp) => Some(sp),
Self::Comment
| Self::DocComment
| Self::Attribute
@ -403,7 +406,6 @@ impl Class {
| Self::Number
| Self::Bool
| Self::Lifetime
| Self::PreludeTy
| Self::PreludeVal
| Self::QuestionMark
| Self::Decoration(_) => None,
@ -411,6 +413,7 @@ impl Class {
}
}
#[derive(Debug)]
enum Highlight<'a> {
Token { text: &'a str, class: Option<Class> },
EnterSpan { class: Class },
@ -847,7 +850,7 @@ impl<'src> Classifier<'src> {
}
TokenKind::Ident => match get_real_ident_class(text, false) {
None => match text {
"Option" | "Result" => Class::PreludeTy,
"Option" | "Result" => Class::PreludeTy(self.new_span(before, text)),
"Some" | "None" | "Ok" | "Err" => Class::PreludeVal,
// "union" is a weak keyword and is only considered as a keyword when declaring
// a union type.

View file

@ -2756,7 +2756,6 @@ ui/lint/issue-57410-1.rs
ui/lint/issue-57410.rs
ui/lint/issue-63364.rs
ui/lint/issue-70819-dont-override-forbid-in-same-scope.rs
ui/lint/issue-79546-fuel-ice.rs
ui/lint/issue-79744.rs
ui/lint/issue-81218.rs
ui/lint/issue-83477.rs

View file

@ -13,7 +13,7 @@
// FIXME(#133480): this has been randomly failing on `x86_64-mingw` due to linker hangs or
// crashes... so I'm going to disable this test for windows for now.
//@ ignore-windows
//@ ignore-windows-gnu
use run_make_support::{llvm_objdump, rustc};

View file

@ -18,31 +18,37 @@ fn main() {
.extern_("dependency", rust_lib_name("dependency"))
.extern_("dep_2_reexport", rust_lib_name("foo"))
.run_fail()
.assert_stderr_contains(r#"error[E0277]: the trait bound `dep_2_reexport::Type: Trait` is not satisfied because the trait comes from a different crate version
--> multiple-dep-versions.rs:7:18
|
7 | do_something(Type);
| ^^^^ the trait `Trait` is not implemented for `dep_2_reexport::Type`
|
.assert_stderr_contains(r#"error[E0277]: the trait bound `dep_2_reexport::Type: Trait` is not satisfied
--> multiple-dep-versions.rs:7:18
|
7 | do_something(Type);
| ------------ ^^^^ the trait `Trait` is not implemented for `dep_2_reexport::Type`
| |
| required by a bound introduced by this call
|
note: there are multiple different versions of crate `dependency` in the dependency graph"#)
.assert_stderr_contains(r#"
3 | pub struct Type(pub i32);
| --------------- this type implements the required trait
4 | pub trait Trait {
| ^^^^^^^^^^^^^^^ this is the required trait
3 | pub struct Type(pub i32);
| --------------- this type implements the required trait
4 | pub trait Trait {
| ^^^^^^^^^^^^^^^ this is the required trait
"#)
.assert_stderr_contains(r#"
1 | extern crate dep_2_reexport;
| ---------------------------- one version of crate `dependency` is used here, as a dependency of crate `foo`
2 | extern crate dependency;
| ------------------------ one version of crate `dependency` is used here, as a direct dependency of the current crate"#)
1 | extern crate dep_2_reexport;
| ---------------------------- one version of crate `dependency` is used here, as a dependency of crate `foo`
2 | extern crate dependency;
| ------------------------ one version of crate `dependency` is used here, as a direct dependency of the current crate"#)
.assert_stderr_contains(r#"
3 | pub struct Type;
| --------------- this type doesn't implement the required trait
4 | pub trait Trait {
| --------------- this is the found trait
= note: two types coming from two different versions of the same crate are different types even if they look the same
= help: you can use `cargo tree` to explore your dependency tree"#)
3 | pub struct Type;
| --------------- this type doesn't implement the required trait
4 | pub trait Trait {
| --------------- this is the found trait
= note: two types coming from two different versions of the same crate are different types even if they look the same
= help: you can use `cargo tree` to explore your dependency tree"#)
.assert_stderr_contains(r#"note: required by a bound in `do_something`"#)
.assert_stderr_contains(r#"
12 | pub fn do_something<X: Trait>(_: X) {}
| ^^^^^ required by this bound in `do_something`"#)
.assert_stderr_contains(r#"error[E0599]: no method named `foo` found for struct `dep_2_reexport::Type` in the current scope
--> multiple-dep-versions.rs:8:10
|

View file

@ -0,0 +1,2 @@
pub trait Resource {}
pub struct Ray2d;

View file

@ -0,0 +1 @@
pub type Ray = minibevy::Ray2d;

View file

@ -0,0 +1,14 @@
extern crate minibevy;
extern crate minirapier;
use minibevy::Resource;
use minirapier::Ray;
fn insert_resource<R: Resource>(_resource: R) {}
struct Res;
impl Resource for Res {}
fn main() {
insert_resource(Res.into());
}

View file

@ -0,0 +1,45 @@
// Non-regression test for issue #132920 where multiple versions of the same crate are present in
// the dependency graph, and an unexpected error in a dependent crate caused an ICE in the
// unsatisfied bounds diagnostics for traits present in multiple crate versions.
//
// Setup:
// - two versions of the same crate: minibevy_a and minibevy_b
// - minirapier: depends on minibevy_a
// - repro: depends on minirapier and minibevy_b
use run_make_support::rustc;
fn main() {
// Prepare dependencies, mimicking a check build with cargo.
rustc()
.input("minibevy.rs")
.crate_name("minibevy")
.crate_type("lib")
.emit("metadata")
.metadata("a")
.extra_filename("-a")
.run();
rustc()
.input("minibevy.rs")
.crate_name("minibevy")
.crate_type("lib")
.emit("metadata")
.metadata("b")
.extra_filename("-b")
.run();
rustc()
.input("minirapier.rs")
.crate_name("minirapier")
.crate_type("lib")
.emit("metadata")
.extern_("minibevy", "libminibevy-a.rmeta")
.run();
// Building the main crate used to ICE here when printing the `type annotations needed` error.
rustc()
.input("repro.rs")
.extern_("minibevy", "libminibevy-b.rmeta")
.extern_("minirapier", "libminirapier.rmeta")
.run_fail()
.assert_stderr_not_contains("error: the compiler unexpectedly panicked. this is a bug");
}

View file

@ -0,0 +1,23 @@
// This test checks that prelude types like `Result` and `Option` still get a link generated.
//@ compile-flags: -Zunstable-options --generate-link-to-definition
#![crate_name = "foo"]
//@ has 'src/foo/jump-to-def-prelude-types.rs.html'
// FIXME: would be nice to be able to check both the class and the href at the same time so
// we could check the text as well...
//@ has - '//a[@class="prelude-ty"]/@href' '{{channel}}/core/result/enum.Result.html'
//@ has - '//a[@class="prelude-ty"]/@href' '{{channel}}/core/option/enum.Option.html'
pub fn foo() -> Result<Option<()>, ()> { Err(()) }
// This part is to ensure that they are not linking to the actual prelude ty.
pub mod bar {
struct Result;
struct Option;
//@ has - '//a[@href="#16"]' 'Result'
pub fn bar() -> Result { Result }
//@ has - '//a[@href="#17"]' 'Option'
pub fn bar2() -> Option { Option }
}

View file

@ -0,0 +1,18 @@
// Regression test for #133271.
#![feature(generic_const_exprs)]
//~^ WARN the feature `generic_const_exprs` is incomplete
struct Foo;
impl<'a, const NUM: usize> std::ops::Add<&'a Foo> for Foo
//~^ ERROR the const parameter `NUM` is not constrained by the impl trait, self type, or predicates
where
[(); 1 + 0]: Sized,
{
fn unimplemented(self, _: &Foo) -> Self::Output {
//~^ ERROR method `unimplemented` is not a member of trait `std::ops::Add`
//~| ERROR type annotations needed
loop {}
}
}
fn main() {}

View file

@ -0,0 +1,46 @@
error[E0407]: method `unimplemented` is not a member of trait `std::ops::Add`
--> $DIR/post-analysis-user-facing-param-env.rs:11:5
|
LL | / fn unimplemented(self, _: &Foo) -> Self::Output {
LL | |
LL | |
LL | | loop {}
LL | | }
| |_____^ not a member of trait `std::ops::Add`
warning: the feature `generic_const_exprs` is incomplete and may not be safe to use and/or cause compiler crashes
--> $DIR/post-analysis-user-facing-param-env.rs:2:12
|
LL | #![feature(generic_const_exprs)]
| ^^^^^^^^^^^^^^^^^^^
|
= note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information
= note: `#[warn(incomplete_features)]` on by default
error[E0207]: the const parameter `NUM` is not constrained by the impl trait, self type, or predicates
--> $DIR/post-analysis-user-facing-param-env.rs:6:10
|
LL | impl<'a, const NUM: usize> std::ops::Add<&'a Foo> for Foo
| ^^^^^^^^^^^^^^^^ unconstrained const parameter
|
= note: expressions using a const parameter must map each value to a distinct output value
= note: proving the result of expressions other than the parameter are unique is not supported
error[E0284]: type annotations needed
--> $DIR/post-analysis-user-facing-param-env.rs:11:40
|
LL | fn unimplemented(self, _: &Foo) -> Self::Output {
| ^^^^^^^^^^^^ cannot infer the value of const parameter `NUM`
|
note: required for `Foo` to implement `Add<&'a Foo>`
--> $DIR/post-analysis-user-facing-param-env.rs:6:28
|
LL | impl<'a, const NUM: usize> std::ops::Add<&'a Foo> for Foo
| ---------------- ^^^^^^^^^^^^^^^^^^^^^^ ^^^
| |
| unsatisfied trait bound introduced here
error: aborting due to 3 previous errors; 1 warning emitted
Some errors have detailed explanations: E0207, E0284, E0407.
For more information about an error, try `rustc --explain E0207`.

View file

@ -1,25 +1,9 @@
error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/const-block-const-bound.rs:8:15
error[E0277]: the trait bound `UnconstDrop: const Destruct` is not satisfied
--> $DIR/const-block-const-bound.rs:18:9
|
LL | const fn f<T: ~const Destruct>(x: T) {}
| ^^^^^^
LL | f(UnconstDrop);
| ^^^^^^^^^^^^^^
error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/const-block-const-bound.rs:8:15
|
LL | const fn f<T: ~const Destruct>(x: T) {}
| ^^^^^^
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error: aborting due to 1 previous error
error[E0493]: destructor of `T` cannot be evaluated at compile-time
--> $DIR/const-block-const-bound.rs:8:32
|
LL | const fn f<T: ~const Destruct>(x: T) {}
| ^ - value is dropped here
| |
| the destructor for this type cannot be evaluated in constant functions
error: aborting due to 3 previous errors
For more information about this error, try `rustc --explain E0493`.
For more information about this error, try `rustc --explain E0277`.

View file

@ -16,12 +16,6 @@ error: `~const` can only be applied to `#[const_trait]` traits
LL | T: ~const Fn<()> + ~const Destruct,
| ^^^^^^
error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/fn_trait_refs.rs:14:24
|
LL | T: ~const Fn<()> + ~const Destruct,
| ^^^^^^
error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/fn_trait_refs.rs:14:8
|
@ -38,26 +32,12 @@ LL | T: ~const Fn<()> + ~const Destruct,
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/fn_trait_refs.rs:14:24
|
LL | T: ~const Fn<()> + ~const Destruct,
| ^^^^^^
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/fn_trait_refs.rs:21:8
|
LL | T: ~const FnMut<()> + ~const Destruct,
| ^^^^^^
error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/fn_trait_refs.rs:21:27
|
LL | T: ~const FnMut<()> + ~const Destruct,
| ^^^^^^
error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/fn_trait_refs.rs:21:8
|
@ -74,14 +54,6 @@ LL | T: ~const FnMut<()> + ~const Destruct,
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/fn_trait_refs.rs:21:27
|
LL | T: ~const FnMut<()> + ~const Destruct,
| ^^^^^^
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/fn_trait_refs.rs:28:8
|
@ -110,12 +82,6 @@ error: `~const` can only be applied to `#[const_trait]` traits
LL | T: ~const Fn<()> + ~const Destruct,
| ^^^^^^
error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/fn_trait_refs.rs:35:24
|
LL | T: ~const Fn<()> + ~const Destruct,
| ^^^^^^
error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/fn_trait_refs.rs:35:8
|
@ -132,26 +98,12 @@ LL | T: ~const Fn<()> + ~const Destruct,
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/fn_trait_refs.rs:35:24
|
LL | T: ~const Fn<()> + ~const Destruct,
| ^^^^^^
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/fn_trait_refs.rs:49:8
|
LL | T: ~const FnMut<()> + ~const Destruct,
| ^^^^^^
error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/fn_trait_refs.rs:49:27
|
LL | T: ~const FnMut<()> + ~const Destruct,
| ^^^^^^
error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/fn_trait_refs.rs:49:8
|
@ -168,29 +120,35 @@ LL | T: ~const FnMut<()> + ~const Destruct,
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/fn_trait_refs.rs:49:27
error[E0277]: the trait bound `fn() -> i32 {one}: const Destruct` is not satisfied
--> $DIR/fn_trait_refs.rs:70:24
|
LL | T: ~const FnMut<()> + ~const Destruct,
| ^^^^^^
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
LL | let test_one = test_fn(one);
| ^^^^^^^^^^^^
error[E0015]: cannot call non-const operator in constants
--> $DIR/fn_trait_refs.rs:71:17
error[E0277]: the trait bound `fn() -> i32 {two}: const Destruct` is not satisfied
--> $DIR/fn_trait_refs.rs:73:24
|
LL | assert!(test_one == (1, 1, 1));
| ^^^^^^^^^^^^^^^^^^^^^
|
= note: calls in constants are limited to constant functions, tuple structs and tuple variants
LL | let test_two = test_fn_mut(two);
| ^^^^^^^^^^^^^^^^
error[E0015]: cannot call non-const operator in constants
--> $DIR/fn_trait_refs.rs:74:17
error[E0277]: the trait bound `&T: ~const Destruct` is not satisfied
--> $DIR/fn_trait_refs.rs:39:9
|
LL | assert!(test_two == (2, 2));
| ^^^^^^^^^^^^^^^^^^
LL | tester_fn(&f),
| ^^^^^^^^^^^^^
error[E0277]: the trait bound `&T: ~const Destruct` is not satisfied
--> $DIR/fn_trait_refs.rs:41:9
|
= note: calls in constants are limited to constant functions, tuple structs and tuple variants
LL | tester_fn_mut(&f),
| ^^^^^^^^^^^^^^^^^
error[E0277]: the trait bound `&mut T: ~const Destruct` is not satisfied
--> $DIR/fn_trait_refs.rs:53:9
|
LL | tester_fn_mut(&mut f),
| ^^^^^^^^^^^^^^^^^^^^^
error[E0015]: cannot call non-const closure in constant functions
--> $DIR/fn_trait_refs.rs:16:5
@ -204,15 +162,6 @@ help: consider further restricting this bound
LL | T: ~const Fn<()> + ~const Destruct + ~const Fn(),
| +++++++++++++
error[E0493]: destructor of `T` cannot be evaluated at compile-time
--> $DIR/fn_trait_refs.rs:12:23
|
LL | const fn tester_fn<T>(f: T) -> T::Output
| ^ the destructor for this type cannot be evaluated in constant functions
...
LL | }
| - value is dropped here
error[E0015]: cannot call non-const closure in constant functions
--> $DIR/fn_trait_refs.rs:23:5
|
@ -225,15 +174,6 @@ help: consider further restricting this bound
LL | T: ~const FnMut<()> + ~const Destruct + ~const FnMut(),
| ++++++++++++++++
error[E0493]: destructor of `T` cannot be evaluated at compile-time
--> $DIR/fn_trait_refs.rs:19:27
|
LL | const fn tester_fn_mut<T>(mut f: T) -> T::Output
| ^^^^^ the destructor for this type cannot be evaluated in constant functions
...
LL | }
| - value is dropped here
error[E0015]: cannot call non-const closure in constant functions
--> $DIR/fn_trait_refs.rs:30:5
|
@ -246,25 +186,7 @@ help: consider further restricting this bound
LL | T: ~const FnOnce<()> + ~const FnOnce(),
| +++++++++++++++++
error[E0493]: destructor of `T` cannot be evaluated at compile-time
--> $DIR/fn_trait_refs.rs:33:21
|
LL | const fn test_fn<T>(mut f: T) -> (T::Output, T::Output, T::Output)
| ^^^^^ the destructor for this type cannot be evaluated in constant functions
...
LL | }
| - value is dropped here
error: aborting due to 25 previous errors
error[E0493]: destructor of `T` cannot be evaluated at compile-time
--> $DIR/fn_trait_refs.rs:47:25
|
LL | const fn test_fn_mut<T>(mut f: T) -> (T::Output, T::Output)
| ^^^^^ the destructor for this type cannot be evaluated in constant functions
...
LL | }
| - value is dropped here
error: aborting due to 34 previous errors
Some errors have detailed explanations: E0015, E0493, E0635.
Some errors have detailed explanations: E0015, E0277, E0635.
For more information about an error, try `rustc --explain E0015`.

View file

@ -3,7 +3,6 @@
struct A();
impl const Drop for A {
//~^ ERROR const `impl` for trait `Drop` which is not marked with `#[const_trait]`
fn drop(&mut self) {}
}

View file

@ -1,14 +1,5 @@
error: const `impl` for trait `Drop` which is not marked with `#[const_trait]`
--> $DIR/promoted-const-drop.rs:5:12
|
LL | impl const Drop for A {
| ^^^^
|
= note: marking a trait with `#[const_trait]` ensures all default method bodies are `const`
= note: adding a non-const method body in the future would be a breaking change
error[E0716]: temporary value dropped while borrowed
--> $DIR/promoted-const-drop.rs:13:26
--> $DIR/promoted-const-drop.rs:12:26
|
LL | let _: &'static A = &A();
| ---------- ^^^ creates a temporary value which is freed while still in use
@ -19,7 +10,7 @@ LL | }
| - temporary value is freed at the end of this statement
error[E0716]: temporary value dropped while borrowed
--> $DIR/promoted-const-drop.rs:14:28
--> $DIR/promoted-const-drop.rs:13:28
|
LL | let _: &'static [A] = &[C];
| ------------ ^^^ creates a temporary value which is freed while still in use
@ -28,6 +19,6 @@ LL | let _: &'static [A] = &[C];
LL | }
| - temporary value is freed at the end of this statement
error: aborting due to 3 previous errors
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0716`.

View file

@ -1,12 +1,3 @@
error: const `impl` for trait `Drop` which is not marked with `#[const_trait]`
--> $DIR/promoted_const_call.rs:6:12
|
LL | impl const Drop for Panic { fn drop(&mut self) { panic!(); } }
| ^^^^
|
= note: marking a trait with `#[const_trait]` ensures all default method bodies are `const`
= note: adding a non-const method body in the future would be a breaking change
error[E0493]: destructor of `Panic` cannot be evaluated at compile-time
--> $DIR/promoted_const_call.rs:10:30
|
@ -57,7 +48,7 @@ LL | let _: &'static _ = &&(Panic, 0).1;
LL | }
| - temporary value is freed at the end of this statement
error: aborting due to 6 previous errors
error: aborting due to 5 previous errors
Some errors have detailed explanations: E0493, E0716.
For more information about an error, try `rustc --explain E0493`.

View file

@ -1,8 +0,0 @@
struct A();
impl const Drop for A {}
//~^ ERROR: const trait impls are experimental
//~| const `impl` for trait `Drop` which is not marked with `#[const_trait]`
//~| not all trait items implemented, missing: `drop`
fn main() {}

View file

@ -1,31 +0,0 @@
error[E0658]: const trait impls are experimental
--> $DIR/const_drop_is_valid.rs:3:6
|
LL | impl const Drop for A {}
| ^^^^^
|
= note: see issue #67792 <https://github.com/rust-lang/rust/issues/67792> for more information
= help: add `#![feature(const_trait_impl)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
error: const `impl` for trait `Drop` which is not marked with `#[const_trait]`
--> $DIR/const_drop_is_valid.rs:3:12
|
LL | impl const Drop for A {}
| ^^^^
|
= note: marking a trait with `#[const_trait]` ensures all default method bodies are `const`
= note: adding a non-const method body in the future would be a breaking change
error[E0046]: not all trait items implemented, missing: `drop`
--> $DIR/const_drop_is_valid.rs:3:1
|
LL | impl const Drop for A {}
| ^^^^^^^^^^^^^^^^^^^^^ missing `drop` in implementation
|
= help: implement the missing item: `fn drop(&mut self) { todo!() }`
error: aborting due to 3 previous errors
Some errors have detailed explanations: E0046, E0658.
For more information about an error, try `rustc --explain E0046`.

View file

@ -1,17 +0,0 @@
//@ run-pass
#![crate_name="foo"]
use std::mem::size_of;
//@ compile-flags: -Z fuel=foo=0
#[allow(dead_code)]
struct S1(u8, u16, u8);
#[allow(dead_code)]
struct S2(u8, u16, u8);
fn main() {
assert_eq!(size_of::<S1>(), 6);
assert_eq!(size_of::<S2>(), 6);
}

View file

@ -1,4 +0,0 @@
warning: optimization-fuel-exhausted: Reorder fields of "S1"
warning: 1 warning emitted

View file

@ -1,18 +0,0 @@
//@ run-pass
#![crate_name="foo"]
use std::mem::size_of;
//@ compile-flags: -Z fuel=foo=1
#[allow(dead_code)]
struct S1(u8, u16, u8);
#[allow(dead_code)]
struct S2(u8, u16, u8);
fn main() {
let optimized = (size_of::<S1>() == 4) as usize
+(size_of::<S2>() == 4) as usize;
assert_eq!(optimized, 1);
}

View file

@ -1,4 +0,0 @@
warning: optimization-fuel-exhausted: Reorder fields of "S2"
warning: 1 warning emitted

View file

@ -1,13 +0,0 @@
#![crate_name="foo"]
#![allow(dead_code)]
// (#55495: The --error-format is to sidestep an issue in our test harness)
//@ compile-flags: -C opt-level=0 --error-format human -Z print-fuel=foo
//@ check-pass
struct S1(u8, u16, u8);
struct S2(u8, u16, u8);
struct S3(u8, u16, u8);
fn main() {
}

View file

@ -1 +0,0 @@
Fuel used by foo: 3

View file

@ -4,12 +4,6 @@ error: `~const` can only be applied to `#[const_trait]` traits
LL | const fn with_positive<F: for<'a> ~const Fn(&'a Alias<'a>) + ~const Destruct>(fun: F) {
| ^^^^^^
error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/normalize-tait-in-const.rs:26:62
|
LL | const fn with_positive<F: for<'a> ~const Fn(&'a Alias<'a>) + ~const Destruct>(fun: F) {
| ^^^^^^
error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/normalize-tait-in-const.rs:26:35
|
@ -18,13 +12,11 @@ LL | const fn with_positive<F: for<'a> ~const Fn(&'a Alias<'a>) + ~const Destruc
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/normalize-tait-in-const.rs:26:62
error[E0277]: the trait bound `for<'a, 'b> fn(&'a foo::Alias<'b>) {foo}: const Destruct` is not satisfied
--> $DIR/normalize-tait-in-const.rs:33:5
|
LL | const fn with_positive<F: for<'a> ~const Fn(&'a Alias<'a>) + ~const Destruct>(fun: F) {
| ^^^^^^
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
LL | with_positive(foo);
| ^^^^^^^^^^^^^^^^^^
error[E0015]: cannot call non-const closure in constant functions
--> $DIR/normalize-tait-in-const.rs:27:5
@ -38,16 +30,7 @@ help: consider further restricting this bound
LL | const fn with_positive<F: for<'a> ~const Fn(&'a Alias<'a>) + ~const Destruct + ~const Fn(&foo::Alias<'_>)>(fun: F) {
| ++++++++++++++++++++++++++++
error[E0493]: destructor of `F` cannot be evaluated at compile-time
--> $DIR/normalize-tait-in-const.rs:26:79
|
LL | const fn with_positive<F: for<'a> ~const Fn(&'a Alias<'a>) + ~const Destruct>(fun: F) {
| ^^^ the destructor for this type cannot be evaluated in constant functions
LL | fun(filter_positive());
LL | }
| - value is dropped here
error: aborting due to 4 previous errors
error: aborting due to 6 previous errors
Some errors have detailed explanations: E0015, E0493.
Some errors have detailed explanations: E0015, E0277.
For more information about an error, try `rustc --explain E0015`.

View file

@ -1,11 +0,0 @@
//@ revisions: incremental threads
//@ dont-check-compiler-stderr
//
//@ [threads] compile-flags: -Zfuel=a=1 -Zthreads=2
//@ [threads] error-pattern:optimization fuel is incompatible with multiple threads
//
//@ [incremental] incremental
//@ [incremental] compile-flags: -Zprint-fuel=a
//@ [incremental] error-pattern:optimization fuel is incompatible with incremental compilation
fn main() {}

View file

@ -1,8 +0,0 @@
// Regression test for the ICE described in #79546.
//@ compile-flags: --cap-lints=allow -Zfuel=issue79546=0
//@ check-pass
#![crate_name="issue79546"]
struct S;
fn main() {}

View file

@ -1,53 +1,9 @@
error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/const-drop-bound.rs:9:61
error[E0277]: the trait bound `Foo<E>: ~const Destruct` is not satisfied
--> $DIR/const-drop-bound.rs:23:5
|
LL | const fn foo<T, E>(res: Result<T, E>) -> Option<T> where E: ~const Destruct {
| ^^^^^^
LL | foo(res)
| ^^^^^^^^
error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/const-drop-bound.rs:9:61
|
LL | const fn foo<T, E>(res: Result<T, E>) -> Option<T> where E: ~const Destruct {
| ^^^^^^
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error: aborting due to 1 previous error
error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/const-drop-bound.rs:20:8
|
LL | T: ~const Destruct,
| ^^^^^^
error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/const-drop-bound.rs:21:8
|
LL | E: ~const Destruct,
| ^^^^^^
error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/const-drop-bound.rs:20:8
|
LL | T: ~const Destruct,
| ^^^^^^
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/const-drop-bound.rs:21:8
|
LL | E: ~const Destruct,
| ^^^^^^
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error[E0493]: destructor of `E` cannot be evaluated at compile-time
--> $DIR/const-drop-bound.rs:12:13
|
LL | Err(_e) => None,
| ^^ - value is dropped here
| |
| the destructor for this type cannot be evaluated in constant functions
error: aborting due to 7 previous errors
For more information about this error, try `rustc --explain E0493`.
For more information about this error, try `rustc --explain E0277`.

View file

@ -1,26 +1,13 @@
error: const `impl` for trait `Drop` which is not marked with `#[const_trait]`
--> $DIR/const-drop-fail-2.rs:23:25
error[E0277]: the trait bound `ConstDropImplWithBounds<NonTrivialDrop>: const Destruct` is not satisfied
--> $DIR/const-drop-fail-2.rs:31:15
|
LL | impl<T: ~const A> const Drop for ConstDropImplWithBounds<T> {
| ^^^^
|
= note: marking a trait with `#[const_trait]` ensures all default method bodies are `const`
= note: adding a non-const method body in the future would be a breaking change
LL | const _: () = check::<ConstDropImplWithBounds<NonTrivialDrop>>(
| _______________^
LL | |
LL | | ConstDropImplWithBounds(PhantomData)
LL | | );
| |_^
error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/const-drop-fail-2.rs:29:26
|
LL | const fn check<T: ~const Destruct>(_: T) {}
| ^^^^^^^^
error: const `impl` for trait `Drop` which is not marked with `#[const_trait]`
--> $DIR/const-drop-fail-2.rs:39:25
|
LL | impl<T: ~const A> const Drop for ConstDropImplWithNonConstBounds<T> {
| ^^^^
|
= note: marking a trait with `#[const_trait]` ensures all default method bodies are `const`
= note: adding a non-const method body in the future would be a breaking change
error: aborting due to 3 previous errors
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0277`.

View file

@ -1,6 +1,7 @@
//@ known-bug: #110395
//@ revisions: stock precise
#![feature(const_trait_impl, const_destruct)]
// #![cfg_attr(precise, feature(const_precise_live_drops))]
#![cfg_attr(precise, feature(const_precise_live_drops))]
use std::marker::{Destruct, PhantomData};
@ -19,9 +20,7 @@ impl A for NonTrivialDrop {}
const fn check<T: ~const Destruct>(_: T) {}
/* FIXME(const_trait_impl)
struct ConstDropImplWithBounds<T: ~const A>(PhantomData<T>);
struct ConstDropImplWithBounds<T: A>(PhantomData<T>);
impl<T: ~const A> const Drop for ConstDropImplWithBounds<T> {
fn drop(&mut self) {
@ -30,9 +29,9 @@ impl<T: ~const A> const Drop for ConstDropImplWithBounds<T> {
}
const _: () = check::<ConstDropImplWithBounds<NonTrivialDrop>>(
//~^ ERROR the trait bound
ConstDropImplWithBounds(PhantomData)
);
*/
struct ConstDropImplWithNonConstBounds<T: A>(PhantomData<T>);

View file

@ -1,41 +0,0 @@
error: const `impl` for trait `Drop` which is not marked with `#[const_trait]`
--> $DIR/const-drop-fail-2.rs:39:25
|
LL | impl<T: ~const A> const Drop for ConstDropImplWithNonConstBounds<T> {
| ^^^^
|
= note: marking a trait with `#[const_trait]` ensures all default method bodies are `const`
= note: adding a non-const method body in the future would be a breaking change
error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/const-drop-fail-2.rs:20:19
|
LL | const fn check<T: ~const Destruct>(_: T) {}
| ^^^^^^
error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/const-drop-fail-2.rs:20:19
|
LL | const fn check<T: ~const Destruct>(_: T) {}
| ^^^^^^
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error[E0277]: the trait bound `T: ~const A` is not satisfied
--> $DIR/const-drop-fail-2.rs:41:9
|
LL | T::a();
| ^^^^^^
error[E0493]: destructor of `T` cannot be evaluated at compile-time
--> $DIR/const-drop-fail-2.rs:20:36
|
LL | const fn check<T: ~const Destruct>(_: T) {}
| ^ - value is dropped here
| |
| the destructor for this type cannot be evaluated in constant functions
error: aborting due to 5 previous errors
Some errors have detailed explanations: E0277, E0493.
For more information about an error, try `rustc --explain E0277`.

View file

@ -1,26 +1,13 @@
error: const `impl` for trait `Drop` which is not marked with `#[const_trait]`
--> $DIR/const-drop-fail-2.rs:23:25
error[E0277]: the trait bound `ConstDropImplWithBounds<NonTrivialDrop>: const Destruct` is not satisfied
--> $DIR/const-drop-fail-2.rs:31:15
|
LL | impl<T: ~const A> const Drop for ConstDropImplWithBounds<T> {
| ^^^^
|
= note: marking a trait with `#[const_trait]` ensures all default method bodies are `const`
= note: adding a non-const method body in the future would be a breaking change
LL | const _: () = check::<ConstDropImplWithBounds<NonTrivialDrop>>(
| _______________^
LL | |
LL | | ConstDropImplWithBounds(PhantomData)
LL | | );
| |_^
error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/const-drop-fail-2.rs:29:26
|
LL | const fn check<T: ~const Destruct>(_: T) {}
| ^^^^^^^^
error: const `impl` for trait `Drop` which is not marked with `#[const_trait]`
--> $DIR/const-drop-fail-2.rs:39:25
|
LL | impl<T: ~const A> const Drop for ConstDropImplWithNonConstBounds<T> {
| ^^^^
|
= note: marking a trait with `#[const_trait]` ensures all default method bodies are `const`
= note: adding a non-const method body in the future would be a breaking change
error: aborting due to 3 previous errors
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0277`.

View file

@ -1,87 +1,32 @@
error: const `impl` for trait `Drop` which is not marked with `#[const_trait]`
--> $DIR/const-drop-fail.rs:19:12
error[E0277]: the trait bound `NonTrivialDrop: const Destruct` is not satisfied
--> $DIR/const-drop-fail.rs:27:23
|
LL | impl const Drop for ConstImplWithDropGlue {
| ^^^^
LL | const _: () = check($exp);
| ^^^^^^^^^^^
...
LL | / check_all! {
LL | | NonTrivialDrop,
LL | | ConstImplWithDropGlue(NonTrivialDrop),
LL | | }
| |_- in this macro invocation
|
= note: marking a trait with `#[const_trait]` ensures all default method bodies are `const`
= note: adding a non-const method body in the future would be a breaking change
= note: this error originates in the macro `check_all` (in Nightly builds, run with -Z macro-backtrace for more info)
error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/const-drop-fail.rs:23:19
error[E0277]: the trait bound `NonTrivialDrop: const Destruct` is not satisfied
--> $DIR/const-drop-fail.rs:27:23
|
LL | const fn check<T: ~const Destruct>(_: T) {}
| ^^^^^^
error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/const-drop-fail.rs:23:19
|
LL | const fn check<T: ~const Destruct>(_: T) {}
| ^^^^^^
LL | const _: () = check($exp);
| ^^^^^^^^^^^
...
LL | / check_all! {
LL | | NonTrivialDrop,
LL | | ConstImplWithDropGlue(NonTrivialDrop),
LL | | }
| |_- in this macro invocation
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error[E0493]: destructor of `T` cannot be evaluated at compile-time
--> $DIR/const-drop-fail.rs:23:36
|
LL | const fn check<T: ~const Destruct>(_: T) {}
| ^ - value is dropped here
| |
| the destructor for this type cannot be evaluated in constant functions
error[E0080]: evaluation of constant value failed
--> $SRC_DIR/core/src/ptr/mod.rs:LL:COL
|
= note: calling non-const function `<NonTrivialDrop as Drop>::drop`
|
note: inside `std::ptr::drop_in_place::<NonTrivialDrop> - shim(Some(NonTrivialDrop))`
--> $SRC_DIR/core/src/ptr/mod.rs:LL:COL
note: inside `check::<NonTrivialDrop>`
--> $DIR/const-drop-fail.rs:23:43
|
LL | const fn check<T: ~const Destruct>(_: T) {}
| ^
note: inside `_`
--> $DIR/const-drop-fail.rs:27:23
|
LL | const _: () = check($exp);
| ^^^^^^^^^^^
...
LL | / check_all! {
LL | | NonTrivialDrop,
LL | | ConstImplWithDropGlue(NonTrivialDrop),
LL | | }
| |_- in this macro invocation
= note: this error originates in the macro `check_all` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0080]: evaluation of constant value failed
--> $SRC_DIR/core/src/ptr/mod.rs:LL:COL
|
= note: calling non-const function `<NonTrivialDrop as Drop>::drop`
|
note: inside `std::ptr::drop_in_place::<NonTrivialDrop> - shim(Some(NonTrivialDrop))`
--> $SRC_DIR/core/src/ptr/mod.rs:LL:COL
note: inside `std::ptr::drop_in_place::<ConstImplWithDropGlue> - shim(Some(ConstImplWithDropGlue))`
--> $SRC_DIR/core/src/ptr/mod.rs:LL:COL
note: inside `check::<ConstImplWithDropGlue>`
--> $DIR/const-drop-fail.rs:23:43
|
LL | const fn check<T: ~const Destruct>(_: T) {}
| ^
note: inside `_`
--> $DIR/const-drop-fail.rs:27:23
|
LL | const _: () = check($exp);
| ^^^^^^^^^^^
...
LL | / check_all! {
LL | | NonTrivialDrop,
LL | | ConstImplWithDropGlue(NonTrivialDrop),
LL | | }
| |_- in this macro invocation
= note: this error originates in the macro `check_all` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to 2 previous errors
error: aborting due to 6 previous errors
Some errors have detailed explanations: E0080, E0493.
For more information about an error, try `rustc --explain E0080`.
For more information about this error, try `rustc --explain E0277`.

View file

@ -1,6 +1,6 @@
//@ known-bug: #110395
//@ compile-flags: -Znext-solver
//@ revisions: stock precise
#![feature(const_trait_impl, const_destruct)]
#![cfg_attr(precise, feature(const_precise_live_drops))]
@ -25,6 +25,8 @@ const fn check<T: ~const Destruct>(_: T) {}
macro_rules! check_all {
($($exp:expr),*$(,)?) => {$(
const _: () = check($exp);
//~^ ERROR the trait bound `NonTrivialDrop: const Destruct` is not satisfied
//~| ERROR the trait bound `NonTrivialDrop: const Destruct` is not satisfied
)*};
}

View file

@ -1,34 +1,32 @@
error: const `impl` for trait `Drop` which is not marked with `#[const_trait]`
--> $DIR/const-drop-fail.rs:19:12
error[E0277]: the trait bound `NonTrivialDrop: const Destruct` is not satisfied
--> $DIR/const-drop-fail.rs:27:23
|
LL | impl const Drop for ConstImplWithDropGlue {
| ^^^^
LL | const _: () = check($exp);
| ^^^^^^^^^^^
...
LL | / check_all! {
LL | | NonTrivialDrop,
LL | | ConstImplWithDropGlue(NonTrivialDrop),
LL | | }
| |_- in this macro invocation
|
= note: marking a trait with `#[const_trait]` ensures all default method bodies are `const`
= note: adding a non-const method body in the future would be a breaking change
= note: this error originates in the macro `check_all` (in Nightly builds, run with -Z macro-backtrace for more info)
error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/const-drop-fail.rs:23:19
error[E0277]: the trait bound `NonTrivialDrop: const Destruct` is not satisfied
--> $DIR/const-drop-fail.rs:27:23
|
LL | const fn check<T: ~const Destruct>(_: T) {}
| ^^^^^^
error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/const-drop-fail.rs:23:19
|
LL | const fn check<T: ~const Destruct>(_: T) {}
| ^^^^^^
LL | const _: () = check($exp);
| ^^^^^^^^^^^
...
LL | / check_all! {
LL | | NonTrivialDrop,
LL | | ConstImplWithDropGlue(NonTrivialDrop),
LL | | }
| |_- in this macro invocation
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
= note: this error originates in the macro `check_all` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0493]: destructor of `T` cannot be evaluated at compile-time
--> $DIR/const-drop-fail.rs:23:36
|
LL | const fn check<T: ~const Destruct>(_: T) {}
| ^ - value is dropped here
| |
| the destructor for this type cannot be evaluated in constant functions
error: aborting due to 2 previous errors
error: aborting due to 4 previous errors
For more information about this error, try `rustc --explain E0493`.
For more information about this error, try `rustc --explain E0277`.

View file

@ -1,100 +0,0 @@
error: const `impl` for trait `Drop` which is not marked with `#[const_trait]`
--> $DIR/const-drop.rs:12:16
|
LL | impl<'a> const Drop for S<'a> {
| ^^^^
|
= note: marking a trait with `#[const_trait]` ensures all default method bodies are `const`
= note: adding a non-const method body in the future would be a breaking change
error: const `impl` for trait `Drop` which is not marked with `#[const_trait]`
--> $DIR/const-drop.rs:46:16
|
LL | impl const Drop for ConstDrop {
| ^^^^
|
= note: marking a trait with `#[const_trait]` ensures all default method bodies are `const`
= note: adding a non-const method body in the future would be a breaking change
error: const `impl` for trait `Drop` which is not marked with `#[const_trait]`
--> $DIR/const-drop.rs:67:37
|
LL | impl<T: ~const SomeTrait> const Drop for ConstDropWithBound<T> {
| ^^^^
|
= note: marking a trait with `#[const_trait]` ensures all default method bodies are `const`
= note: adding a non-const method body in the future would be a breaking change
error: const `impl` for trait `Drop` which is not marked with `#[const_trait]`
--> $DIR/const-drop.rs:75:30
|
LL | impl<T: SomeTrait> const Drop for ConstDropWithNonconstBound<T> {
| ^^^^
|
= note: marking a trait with `#[const_trait]` ensures all default method bodies are `const`
= note: adding a non-const method body in the future would be a breaking change
error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/const-drop.rs:18:15
|
LL | const fn a<T: ~const Destruct>(_: T) {}
| ^^^^^^
error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/const-drop.rs:18:15
|
LL | const fn a<T: ~const Destruct>(_: T) {}
| ^^^^^^
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error[E0277]: the trait bound `T: const SomeTrait` is not satisfied
--> $DIR/const-drop.rs:67:46
|
LL | impl<T: ~const SomeTrait> const Drop for ConstDropWithBound<T> {
| ^^^^^^^^^^^^^^^^^^^^^
|
note: required by a bound in `t::ConstDropWithBound`
--> $DIR/const-drop.rs:65:38
|
LL | pub struct ConstDropWithBound<T: const SomeTrait>(pub core::marker::PhantomData<T>);
| ^^^^^ required by this bound in `ConstDropWithBound`
error[E0277]: the trait bound `T: const SomeTrait` is not satisfied
--> $DIR/const-drop.rs:68:22
|
LL | fn drop(&mut self) {
| ^^^^
|
note: required by a bound in `t::ConstDropWithBound`
--> $DIR/const-drop.rs:65:38
|
LL | pub struct ConstDropWithBound<T: const SomeTrait>(pub core::marker::PhantomData<T>);
| ^^^^^ required by this bound in `ConstDropWithBound`
error[E0493]: destructor of `S<'_>` cannot be evaluated at compile-time
--> $DIR/const-drop.rs:23:13
|
LL | let _ = S(&mut c);
| ^^^^^^^^^- value is dropped here
| |
| the destructor for this type cannot be evaluated in constant functions
error[E0493]: destructor of `T` cannot be evaluated at compile-time
--> $DIR/const-drop.rs:18:32
|
LL | const fn a<T: ~const Destruct>(_: T) {}
| ^ - value is dropped here
| |
| the destructor for this type cannot be evaluated in constant functions
error[E0277]: the trait bound `T: ~const SomeTrait` is not satisfied
--> $DIR/const-drop.rs:69:13
|
LL | T::foo();
| ^^^^^^^^
error: aborting due to 11 previous errors
Some errors have detailed explanations: E0277, E0493.
For more information about an error, try `rustc --explain E0277`.

View file

@ -1,6 +1,7 @@
// FIXME run-pass
//@ known-bug: #110395
//@ run-pass
//@ compile-flags: -Znext-solver
//@ revisions: stock precise
#![feature(const_trait_impl, const_destruct)]
#![feature(never_type)]
#![cfg_attr(precise, feature(const_precise_live_drops))]
@ -64,7 +65,7 @@ mod t {
pub struct ConstDropWithBound<T: const SomeTrait>(pub core::marker::PhantomData<T>);
impl<T: ~const SomeTrait> const Drop for ConstDropWithBound<T> {
impl<T: const SomeTrait> const Drop for ConstDropWithBound<T> {
fn drop(&mut self) {
T::foo();
}

View file

@ -1,100 +0,0 @@
error: const `impl` for trait `Drop` which is not marked with `#[const_trait]`
--> $DIR/const-drop.rs:12:16
|
LL | impl<'a> const Drop for S<'a> {
| ^^^^
|
= note: marking a trait with `#[const_trait]` ensures all default method bodies are `const`
= note: adding a non-const method body in the future would be a breaking change
error: const `impl` for trait `Drop` which is not marked with `#[const_trait]`
--> $DIR/const-drop.rs:46:16
|
LL | impl const Drop for ConstDrop {
| ^^^^
|
= note: marking a trait with `#[const_trait]` ensures all default method bodies are `const`
= note: adding a non-const method body in the future would be a breaking change
error: const `impl` for trait `Drop` which is not marked with `#[const_trait]`
--> $DIR/const-drop.rs:67:37
|
LL | impl<T: ~const SomeTrait> const Drop for ConstDropWithBound<T> {
| ^^^^
|
= note: marking a trait with `#[const_trait]` ensures all default method bodies are `const`
= note: adding a non-const method body in the future would be a breaking change
error: const `impl` for trait `Drop` which is not marked with `#[const_trait]`
--> $DIR/const-drop.rs:75:30
|
LL | impl<T: SomeTrait> const Drop for ConstDropWithNonconstBound<T> {
| ^^^^
|
= note: marking a trait with `#[const_trait]` ensures all default method bodies are `const`
= note: adding a non-const method body in the future would be a breaking change
error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/const-drop.rs:18:15
|
LL | const fn a<T: ~const Destruct>(_: T) {}
| ^^^^^^
error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/const-drop.rs:18:15
|
LL | const fn a<T: ~const Destruct>(_: T) {}
| ^^^^^^
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error[E0277]: the trait bound `T: const SomeTrait` is not satisfied
--> $DIR/const-drop.rs:67:46
|
LL | impl<T: ~const SomeTrait> const Drop for ConstDropWithBound<T> {
| ^^^^^^^^^^^^^^^^^^^^^
|
note: required by a bound in `t::ConstDropWithBound`
--> $DIR/const-drop.rs:65:38
|
LL | pub struct ConstDropWithBound<T: const SomeTrait>(pub core::marker::PhantomData<T>);
| ^^^^^ required by this bound in `ConstDropWithBound`
error[E0277]: the trait bound `T: const SomeTrait` is not satisfied
--> $DIR/const-drop.rs:68:22
|
LL | fn drop(&mut self) {
| ^^^^
|
note: required by a bound in `t::ConstDropWithBound`
--> $DIR/const-drop.rs:65:38
|
LL | pub struct ConstDropWithBound<T: const SomeTrait>(pub core::marker::PhantomData<T>);
| ^^^^^ required by this bound in `ConstDropWithBound`
error[E0493]: destructor of `S<'_>` cannot be evaluated at compile-time
--> $DIR/const-drop.rs:23:13
|
LL | let _ = S(&mut c);
| ^^^^^^^^^- value is dropped here
| |
| the destructor for this type cannot be evaluated in constant functions
error[E0493]: destructor of `T` cannot be evaluated at compile-time
--> $DIR/const-drop.rs:18:32
|
LL | const fn a<T: ~const Destruct>(_: T) {}
| ^ - value is dropped here
| |
| the destructor for this type cannot be evaluated in constant functions
error[E0277]: the trait bound `T: ~const SomeTrait` is not satisfied
--> $DIR/const-drop.rs:69:13
|
LL | T::foo();
| ^^^^^^^^
error: aborting due to 11 previous errors
Some errors have detailed explanations: E0277, E0493.
For more information about an error, try `rustc --explain E0277`.

View file

@ -1,7 +1,4 @@
// Regression test for #92111.
//
//@ known-bug: #110395
// FIXME check-pass
//@ check-pass
#![feature(const_trait_impl, const_destruct)]

View file

@ -1,25 +0,0 @@
error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/issue-92111.rs:20:15
|
LL | const fn a<T: ~const Destruct>(t: T) {}
| ^^^^^^
error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/issue-92111.rs:20:15
|
LL | const fn a<T: ~const Destruct>(t: T) {}
| ^^^^^^
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error[E0493]: destructor of `T` cannot be evaluated at compile-time
--> $DIR/issue-92111.rs:20:32
|
LL | const fn a<T: ~const Destruct>(t: T) {}
| ^ - value is dropped here
| |
| the destructor for this type cannot be evaluated in constant functions
error: aborting due to 3 previous errors
For more information about this error, try `rustc --explain E0493`.