Skip to content

Rollup of 14 pull requests #89002

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 34 commits into from
Closed
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
4e76c38
Fix ICE in `improper_ctypes_definitions` lint with all-ZST transparen…
FabianWolff Jul 27, 2021
b82ec36
Recover from `Foo(a: 1, b: 2)`
estebank Sep 7, 2021
a4a22f0
Doc comments
bjorn3 Aug 31, 2021
58000ed
Move get_tools_search_paths from FileSearch to Session
bjorn3 Aug 31, 2021
d7ef0b3
Use Lrc instead of Option to avoid duplication of a SearchPath
bjorn3 Sep 1, 2021
3feddf7
Add `ConstraintCategory::Usage` for handling aggregate construction
Aaron1011 Sep 6, 2021
6b7f916
Document the closure arguments for `reduce`.
lefth Sep 14, 2021
ffc623a
review comment: move recovery code to its own function
estebank Sep 14, 2021
4840f67
Add chown functions to std::os::unix::fs to change the owner and grou…
joshtriplett Sep 15, 2021
870a132
[aarch64] add target feature outline-atomics
Apr 5, 2021
9762116
Move object safety suggestions to the end of the error
estebank Sep 12, 2021
ef44452
chore(rustc_expand): fix typo in comment
notriddle Sep 15, 2021
cc7929b
docs(std): add docs for cof_from_cstr impls
notriddle Sep 15, 2021
c39d759
Disable RemoveZsts in generators to avoid query cycles
tmiasko Sep 15, 2021
1b0186e
Move some tests to more reasonable directories
c410-f3r Sep 15, 2021
09745a6
Update clobber_abi list to include k[1-7] regs
Sep 15, 2021
4e61d11
Update the backtrace crate
hargoniX Sep 15, 2021
4fd39dd
Make rustc_mir_dataflow::framework::graphviz and rustc_mir_transform:…
willcrichton Sep 15, 2021
47104a3
Allow call to get_body_with_borrowck_facts without -Z polonius
willcrichton Sep 15, 2021
862d89e
Add tracking issue for unix_chown
joshtriplett Sep 15, 2021
4e5ad6e
Rollup merge of #83655 - sebpop:arm64-outline-atomics, r=joshtriplett
Manishearth Sep 16, 2021
4078cbf
Rollup merge of #87529 - FabianWolff:issue-87496, r=nikomatsakis
Manishearth Sep 16, 2021
800baa0
Rollup merge of #88708 - Aaron1011:aggregate-usage, r=oli-obk
Manishearth Sep 16, 2021
8684a4d
Rollup merge of #88729 - estebank:struct-literal-using-parens, r=oli-obk
Manishearth Sep 16, 2021
e21b367
Rollup merge of #88751 - bjorn3:move_filesearch, r=oli-obk
Manishearth Sep 16, 2021
63cfeba
Rollup merge of #88883 - c410-f3r:tests, r=petrochenkov
Manishearth Sep 16, 2021
3d945d2
Rollup merge of #88892 - estebank:trait-objects, r=petrochenkov
Manishearth Sep 16, 2021
ce9af0e
Rollup merge of #88928 - lefth:master, r=Mark-Simulacrum
Manishearth Sep 16, 2021
0717c3b
Rollup merge of #88953 - joshtriplett:chown, r=dtolnay
Manishearth Sep 16, 2021
34aaf54
Rollup merge of #88976 - notriddle:notriddle/cow-from-cstr-docs, r=Ma…
Manishearth Sep 16, 2021
f7a6ae6
Rollup merge of #88979 - tmiasko:no-remove-zsts-in-generators, r=oli-obk
Manishearth Sep 16, 2021
4fcc533
Rollup merge of #88983 - willcrichton:allow-single-polonius-call, r=e…
Manishearth Sep 16, 2021
d122790
Rollup merge of #88985 - Commeownist:patch-1, r=Amanieu
Manishearth Sep 16, 2021
3dd0e34
Rollup merge of #88986 - hargoniX:master, r=Mark-Simulacrum
Manishearth Sep 16, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions compiler/rustc_borrowck/src/consumers.rs
Original file line number Diff line number Diff line change
@@ -14,16 +14,16 @@ pub use super::{
};

/// This function computes Polonius facts for the given body. It makes a copy of
/// the body because it needs to regenerate the region identifiers.
/// the body because it needs to regenerate the region identifiers. This function
/// should never be invoked during a typical compilation session due to performance
/// issues with Polonius.
///
/// Note:
/// * This function will panic if the required body was already stolen. This
/// can, for example, happen when requesting a body of a `const` function
/// because they are evaluated during typechecking. The panic can be avoided
/// by overriding the `mir_borrowck` query. You can find a complete example
/// that shows how to do this at `src/test/run-make/obtain-borrowck/`.
/// * This function will also panic if computation of Polonius facts
/// (`-Zpolonius` flag) is not enabled.
///
/// * Polonius is highly unstable, so expect regular changes in its signature or other details.
pub fn get_body_with_borrowck_facts<'tcx>(
1 change: 1 addition & 0 deletions compiler/rustc_borrowck/src/diagnostics/region_errors.rs
Original file line number Diff line number Diff line change
@@ -40,6 +40,7 @@ impl ConstraintDescription for ConstraintCategory {
ConstraintCategory::CopyBound => "copying this value ",
ConstraintCategory::OpaqueType => "opaque type ",
ConstraintCategory::ClosureUpvar(_) => "closure capture ",
ConstraintCategory::Usage => "this usage ",
ConstraintCategory::Boring
| ConstraintCategory::BoringNoLocation
| ConstraintCategory::Internal => "",
8 changes: 3 additions & 5 deletions compiler/rustc_borrowck/src/lib.rs
Original file line number Diff line number Diff line change
@@ -154,11 +154,6 @@ fn do_mir_borrowck<'a, 'tcx>(

debug!("do_mir_borrowck(def = {:?})", def);

assert!(
!return_body_with_facts || infcx.tcx.sess.opts.debugging_opts.polonius,
"borrowck facts can be requested only when Polonius is enabled"
);

let tcx = infcx.tcx;
let param_env = tcx.param_env(def.did);
let id = tcx.hir().local_def_id_to_hir_id(def.did);
@@ -235,6 +230,8 @@ fn do_mir_borrowck<'a, 'tcx>(
let borrow_set =
Rc::new(BorrowSet::build(tcx, body, locals_are_invalidated_at_exit, &mdpe.move_data));

let use_polonius = return_body_with_facts || infcx.tcx.sess.opts.debugging_opts.polonius;

// Compute non-lexical lifetimes.
let nll::NllOutput {
regioncx,
@@ -254,6 +251,7 @@ fn do_mir_borrowck<'a, 'tcx>(
&mdpe.move_data,
&borrow_set,
&upvars,
use_polonius,
);

// Dump MIR results into a file, if that is enabled. This let us
6 changes: 4 additions & 2 deletions compiler/rustc_borrowck/src/nll.rs
Original file line number Diff line number Diff line change
@@ -164,8 +164,10 @@ pub(crate) fn compute_regions<'cx, 'tcx>(
move_data: &MoveData<'tcx>,
borrow_set: &BorrowSet<'tcx>,
upvars: &[Upvar<'tcx>],
use_polonius: bool,
) -> NllOutput<'tcx> {
let mut all_facts = AllFacts::enabled(infcx.tcx).then_some(AllFacts::default());
let mut all_facts =
(use_polonius || AllFacts::enabled(infcx.tcx)).then_some(AllFacts::default());

let universal_regions = Rc::new(universal_regions);

@@ -281,7 +283,7 @@ pub(crate) fn compute_regions<'cx, 'tcx>(
all_facts.write_to_dir(dir_path, location_table).unwrap();
}

if infcx.tcx.sess.opts.debugging_opts.polonius {
if use_polonius {
let algorithm =
env::var("POLONIUS_ALGORITHM").unwrap_or_else(|_| String::from("Hybrid"));
let algorithm = Algorithm::from_str(&algorithm).unwrap();
13 changes: 13 additions & 0 deletions compiler/rustc_borrowck/src/type_check/mod.rs
Original file line number Diff line number Diff line change
@@ -1388,11 +1388,24 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
ConstraintCategory::Return(ReturnConstraint::Normal)
}
}
Some(l)
if matches!(
body.local_decls[l].local_info,
Some(box LocalInfo::AggregateTemp)
) =>
{
ConstraintCategory::Usage
}
Some(l) if !body.local_decls[l].is_user_variable() => {
ConstraintCategory::Boring
}
_ => ConstraintCategory::Assignment,
};
debug!(
"assignment category: {:?} {:?}",
category,
place.as_local().map(|l| &body.local_decls[l])
);

let place_ty = place.ty(body, tcx).ty;
let place_ty = self.normalize(place_ty, location);
8 changes: 3 additions & 5 deletions compiler/rustc_codegen_ssa/src/back/link.rs
Original file line number Diff line number Diff line change
@@ -637,7 +637,7 @@ fn link_dwarf_object<'a>(sess: &'a Session, executable_out_filename: &Path) {
cmd.arg("-o");
cmd.arg(&dwp_out_filename);

let mut new_path = sess.host_filesearch(PathKind::All).get_tools_search_paths(false);
let mut new_path = sess.get_tools_search_paths(false);
if let Some(path) = env::var_os("PATH") {
new_path.extend(env::split_paths(&path));
}
@@ -2555,8 +2555,7 @@ fn add_gcc_ld_path(cmd: &mut dyn Linker, sess: &Session, flavor: LinkerFlavor) {
match ld_impl {
LdImpl::Lld => {
if sess.target.lld_flavor == LldFlavor::Ld64 {
let tools_path =
sess.host_filesearch(PathKind::All).get_tools_search_paths(false);
let tools_path = sess.get_tools_search_paths(false);
let ld64_exe = tools_path
.into_iter()
.map(|p| p.join("gcc-ld"))
@@ -2571,8 +2570,7 @@ fn add_gcc_ld_path(cmd: &mut dyn Linker, sess: &Session, flavor: LinkerFlavor) {
arg
});
} else {
let tools_path =
sess.host_filesearch(PathKind::All).get_tools_search_paths(false);
let tools_path = sess.get_tools_search_paths(false);
let lld_path = tools_path
.into_iter()
.map(|p| p.join("gcc-ld"))
3 changes: 1 addition & 2 deletions compiler/rustc_codegen_ssa/src/back/linker.rs
Original file line number Diff line number Diff line change
@@ -15,7 +15,6 @@ use rustc_middle::middle::dependency_format::Linkage;
use rustc_middle::ty::TyCtxt;
use rustc_serialize::{json, Encoder};
use rustc_session::config::{self, CrateType, DebugInfo, LinkerPluginLto, Lto, OptLevel, Strip};
use rustc_session::search_paths::PathKind;
use rustc_session::Session;
use rustc_span::symbol::Symbol;
use rustc_target::spec::{LinkOutputKind, LinkerFlavor, LldFlavor};
@@ -101,7 +100,7 @@ pub fn get_linker<'a>(

// The compiler's sysroot often has some bundled tools, so add it to the
// PATH for the child.
let mut new_path = sess.host_filesearch(PathKind::All).get_tools_search_paths(self_contained);
let mut new_path = sess.get_tools_search_paths(self_contained);
let mut msvc_changed_path = false;
if sess.target.is_like_msvc {
if let Some(ref tool) = msvc_tool {
5 changes: 1 addition & 4 deletions compiler/rustc_driver/src/lib.rs
Original file line number Diff line number Diff line change
@@ -677,10 +677,7 @@ impl RustcDefaultCalls {
println!("{}", targets.join("\n"));
}
Sysroot => println!("{}", sess.sysroot.display()),
TargetLibdir => println!(
"{}",
sess.target_tlib_path.as_ref().unwrap_or(&sess.host_tlib_path).dir.display()
),
TargetLibdir => println!("{}", sess.target_tlib_path.dir.display()),
TargetSpec => println!("{}", sess.target.to_json().pretty()),
FileNames | CrateName => {
let input = input.unwrap_or_else(|| {
2 changes: 1 addition & 1 deletion compiler/rustc_expand/src/mbe/quoted.rs
Original file line number Diff line number Diff line change
@@ -72,7 +72,7 @@ pub(super) fn parse(
// this with just `span.edition()`. A
// `SyntaxContext::root()` from the current crate will
// have the edition of the current crate, and a
// `SyntaxxContext::root()` from a foreign crate will
// `SyntaxContext::root()` from a foreign crate will
// have the edition of that crate (which we manually
// retrieve via the `edition` parameter).
if span.ctxt() == SyntaxContext::root() {
12 changes: 8 additions & 4 deletions compiler/rustc_infer/src/traits/error_reporting/mod.rs
Original file line number Diff line number Diff line change
@@ -83,10 +83,6 @@ pub fn report_object_safety_error(
messages.push(msg.clone());
}
}
if trait_span.is_some() {
// Only provide the help if its a local trait, otherwise it's not actionable.
violation.solution(&mut err);
}
}
}
let has_multi_span = !multi_span.is_empty();
@@ -104,5 +100,13 @@ pub fn report_object_safety_error(
to be resolvable dynamically; for more information visit \
<https://doc.rust-lang.org/reference/items/traits.html#object-safety>",
);
if trait_span.is_some() {
let mut reported_violations: Vec<_> = reported_violations.into_iter().collect();
reported_violations.sort();
for violation in reported_violations {
// Only provide the help if its a local trait, otherwise it's not actionable.
violation.solution(&mut err);
}
}
err
}
10 changes: 8 additions & 2 deletions compiler/rustc_lint/src/types.rs
Original file line number Diff line number Diff line change
@@ -851,12 +851,18 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
use FfiResult::*;

if def.repr.transparent() {
// Can assume that only one field is not a ZST, so only check
// Can assume that at most one field is not a ZST, so only check
// that field's type for FFI-safety.
if let Some(field) = transparent_newtype_field(self.cx.tcx, variant) {
self.check_field_type_for_ffi(cache, field, substs)
} else {
bug!("malformed transparent type");
// All fields are ZSTs; this means that the type should behave
// like (), which is FFI-unsafe
FfiUnsafe {
ty,
reason: "this struct contains only zero-sized fields".into(),
help: None,
}
}
} else {
// We can't completely trust repr(C) markings; make sure the fields are
3 changes: 3 additions & 0 deletions compiler/rustc_middle/src/mir/mod.rs
Original file line number Diff line number Diff line change
@@ -992,6 +992,9 @@ pub enum LocalInfo<'tcx> {
StaticRef { def_id: DefId, is_thread_local: bool },
/// A temporary created that references the const with the given `DefId`
ConstRef { def_id: DefId },
/// A temporary created during the creation of an aggregate
/// (e.g. a temporary for `foo` in `MyStruct { my_field: foo }`)
AggregateTemp,
}

impl<'tcx> LocalDecl<'tcx> {
8 changes: 3 additions & 5 deletions compiler/rustc_middle/src/mir/query.rs
Original file line number Diff line number Diff line change
@@ -332,17 +332,15 @@ pub enum ConstraintCategory {
CopyBound,
SizedBound,
Assignment,
/// A constraint that came from a usage of a variable (e.g. in an ADT expression
/// like `Foo { field: my_val }`)
Usage,
OpaqueType,
ClosureUpvar(hir::HirId),

/// A "boring" constraint (caused by the given location) is one that
/// the user probably doesn't want to see described in diagnostics,
/// because it is kind of an artifact of the type system setup.
/// Example: `x = Foo { field: y }` technically creates
/// intermediate regions representing the "type of `Foo { field: y
/// }`", and data flows from `y` into those variables, but they
/// are not very interesting. The assignment into `x` on the other
/// hand might be.
Boring,
// Boring and applicable everywhere.
BoringNoLocation,
4 changes: 2 additions & 2 deletions compiler/rustc_middle/src/traits/mod.rs
Original file line number Diff line number Diff line change
@@ -730,7 +730,7 @@ pub struct ImplSourceTraitAliasData<'tcx, N> {
pub nested: Vec<N>,
}

#[derive(Clone, Debug, PartialEq, Eq, Hash, HashStable)]
#[derive(Clone, Debug, PartialEq, Eq, Hash, HashStable, PartialOrd, Ord)]
pub enum ObjectSafetyViolation {
/// `Self: Sized` declared on the trait.
SizedSelf(SmallVec<[Span; 1]>),
@@ -879,7 +879,7 @@ impl ObjectSafetyViolation {
}

/// Reasons a method might not be object-safe.
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, HashStable)]
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, HashStable, PartialOrd, Ord)]
pub enum MethodViolationCode {
/// e.g., `fn foo()`
StaticMethod(Option<(&'static str, Span)>, Span, bool /* has args */),
17 changes: 13 additions & 4 deletions compiler/rustc_mir_build/src/build/expr/as_operand.rs
Original file line number Diff line number Diff line change
@@ -20,7 +20,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
expr: &Expr<'tcx>,
) -> BlockAnd<Operand<'tcx>> {
let local_scope = self.local_scope();
self.as_operand(block, Some(local_scope), expr)
self.as_operand(block, Some(local_scope), expr, None)
}

/// Returns an operand suitable for use until the end of the current scope expression and
@@ -85,6 +85,11 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
/// temporary `tmp = x`, so that we capture the value of `x` at
/// this time.
///
/// If we end up needing to create a temporary, then we will use
/// `local_info` as its `LocalInfo`, unless `as_temporary`
/// has already assigned it a non-`None` `LocalInfo`.
/// Normally, you should use `None` for `local_info`
///
/// The operand is known to be live until the end of `scope`.
///
/// Like `as_local_call_operand`, except that the argument will
@@ -94,15 +99,16 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
mut block: BasicBlock,
scope: Option<region::Scope>,
expr: &Expr<'tcx>,
local_info: Option<Box<LocalInfo<'tcx>>>,
) -> BlockAnd<Operand<'tcx>> {
debug!("as_operand(block={:?}, expr={:?})", block, expr);
debug!("as_operand(block={:?}, expr={:?} local_info={:?})", block, expr, local_info);
let this = self;

if let ExprKind::Scope { region_scope, lint_level, value } = expr.kind {
let source_info = this.source_info(expr.span);
let region_scope = (region_scope, source_info);
return this.in_scope(region_scope, lint_level, |this| {
this.as_operand(block, scope, &this.thir[value])
this.as_operand(block, scope, &this.thir[value], local_info)
});
}

@@ -115,6 +121,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
}
Category::Place | Category::Rvalue(..) => {
let operand = unpack!(block = this.as_temp(block, scope, expr, Mutability::Mut));
if this.local_decls[operand].local_info.is_none() {
this.local_decls[operand].local_info = local_info;
}
block.and(Operand::Move(Place::from(operand)))
}
}
@@ -167,6 +176,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
}
}

this.as_operand(block, scope, expr)
this.as_operand(block, scope, expr, None)
}
}
24 changes: 14 additions & 10 deletions compiler/rustc_mir_build/src/build/expr/as_rvalue.rs
Original file line number Diff line number Diff line change
@@ -52,16 +52,16 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
}
ExprKind::Repeat { value, count } => {
let value_operand =
unpack!(block = this.as_operand(block, scope, &this.thir[value]));
unpack!(block = this.as_operand(block, scope, &this.thir[value], None));
block.and(Rvalue::Repeat(value_operand, count))
}
ExprKind::Binary { op, lhs, rhs } => {
let lhs = unpack!(block = this.as_operand(block, scope, &this.thir[lhs]));
let rhs = unpack!(block = this.as_operand(block, scope, &this.thir[rhs]));
let lhs = unpack!(block = this.as_operand(block, scope, &this.thir[lhs], None));
let rhs = unpack!(block = this.as_operand(block, scope, &this.thir[rhs], None));
this.build_binary_op(block, op, expr_span, expr.ty, lhs, rhs)
}
ExprKind::Unary { op, arg } => {
let arg = unpack!(block = this.as_operand(block, scope, &this.thir[arg]));
let arg = unpack!(block = this.as_operand(block, scope, &this.thir[arg], None));
// Check for -MIN on signed integers
if this.check_overflow && op == UnOp::Neg && expr.ty.is_signed() {
let bool_ty = this.tcx.types.bool;
@@ -116,11 +116,13 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
block.and(Rvalue::Use(Operand::Move(Place::from(result))))
}
ExprKind::Cast { source } => {
let source = unpack!(block = this.as_operand(block, scope, &this.thir[source]));
let source =
unpack!(block = this.as_operand(block, scope, &this.thir[source], None));
block.and(Rvalue::Cast(CastKind::Misc, source, expr.ty))
}
ExprKind::Pointer { cast, source } => {
let source = unpack!(block = this.as_operand(block, scope, &this.thir[source]));
let source =
unpack!(block = this.as_operand(block, scope, &this.thir[source], None));
block.and(Rvalue::Cast(CastKind::Pointer(cast), source, expr.ty))
}
ExprKind::Array { ref fields } => {
@@ -155,7 +157,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
let fields: Vec<_> = fields
.into_iter()
.copied()
.map(|f| unpack!(block = this.as_operand(block, scope, &this.thir[f])))
.map(|f| unpack!(block = this.as_operand(block, scope, &this.thir[f], None)))
.collect();

block.and(Rvalue::Aggregate(Box::new(AggregateKind::Array(el_ty)), fields))
@@ -166,7 +168,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
let fields: Vec<_> = fields
.into_iter()
.copied()
.map(|f| unpack!(block = this.as_operand(block, scope, &this.thir[f])))
.map(|f| unpack!(block = this.as_operand(block, scope, &this.thir[f], None)))
.collect();

block.and(Rvalue::Aggregate(Box::new(AggregateKind::Tuple), fields))
@@ -242,7 +244,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
&this.thir[arg],
)
),
_ => unpack!(block = this.as_operand(block, scope, upvar)),
_ => {
unpack!(block = this.as_operand(block, scope, upvar, None))
}
}
}
}
@@ -304,7 +308,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
Category::of(&expr.kind),
Some(Category::Rvalue(RvalueFunc::AsRvalue))
));
let operand = unpack!(block = this.as_operand(block, scope, expr));
let operand = unpack!(block = this.as_operand(block, scope, expr, None));
block.and(Rvalue::Use(operand))
}
}
11 changes: 9 additions & 2 deletions compiler/rustc_mir_build/src/build/expr/into.rs
Original file line number Diff line number Diff line change
@@ -326,10 +326,16 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
let fields_map: FxHashMap<_, _> = fields
.into_iter()
.map(|f| {
let local_info = Box::new(LocalInfo::AggregateTemp);
(
f.name,
unpack!(
block = this.as_operand(block, Some(scope), &this.thir[f.expr])
block = this.as_operand(
block,
Some(scope),
&this.thir[f.expr],
Some(local_info)
)
),
)
})
@@ -508,7 +514,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {

ExprKind::Yield { value } => {
let scope = this.local_scope();
let value = unpack!(block = this.as_operand(block, Some(scope), &this.thir[value]));
let value =
unpack!(block = this.as_operand(block, Some(scope), &this.thir[value], None));
let resume = this.cfg.start_new_block();
this.cfg.terminate(
block,
4 changes: 2 additions & 2 deletions compiler/rustc_mir_dataflow/src/lib.rs
Original file line number Diff line number Diff line change
@@ -28,8 +28,8 @@ pub use self::drop_flag_effects::{
on_lookup_result_bits,
};
pub use self::framework::{
fmt, lattice, visit_results, Analysis, AnalysisDomain, Backward, Direction, Engine, Forward,
GenKill, GenKillAnalysis, JoinSemiLattice, Results, ResultsCursor, ResultsRefCursor,
fmt, graphviz, lattice, visit_results, Analysis, AnalysisDomain, Backward, Direction, Engine,
Forward, GenKill, GenKillAnalysis, JoinSemiLattice, Results, ResultsCursor, ResultsRefCursor,
ResultsVisitable, ResultsVisitor,
};

2 changes: 1 addition & 1 deletion compiler/rustc_mir_transform/src/lib.rs
Original file line number Diff line number Diff line change
@@ -76,7 +76,7 @@ mod unreachable_prop;
use rustc_const_eval::transform::check_consts;
use rustc_const_eval::transform::promote_consts;
use rustc_const_eval::transform::validate;
use rustc_const_eval::transform::MirPass;
pub use rustc_const_eval::transform::MirPass;
use rustc_mir_dataflow::rustc_peek;

pub fn provide(providers: &mut Providers) {
4 changes: 4 additions & 0 deletions compiler/rustc_mir_transform/src/remove_zsts.rs
Original file line number Diff line number Diff line change
@@ -9,6 +9,10 @@ pub struct RemoveZsts;

impl<'tcx> MirPass<'tcx> for RemoveZsts {
fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
// Avoid query cycles (generators require optimized MIR for layout).
if tcx.type_of(body.source.def_id()).is_generator() {
return;
}
let param_env = tcx.param_env(body.source.def_id());
let (basic_blocks, local_decls) = body.basic_blocks_and_local_decls_mut();
for block in basic_blocks.iter_mut() {
101 changes: 91 additions & 10 deletions compiler/rustc_parse/src/parser/expr.rs
Original file line number Diff line number Diff line change
@@ -907,6 +907,12 @@ impl<'a> Parser<'a> {
}
}

fn look_ahead_type_ascription_as_field(&mut self) -> bool {
self.look_ahead(1, |t| t.is_ident())
&& self.look_ahead(2, |t| t == &token::Colon)
&& self.look_ahead(3, |t| t.can_begin_expr())
}

fn parse_dot_suffix_expr(&mut self, lo: Span, base: P<Expr>) -> PResult<'a, P<Expr>> {
match self.token.uninterpolate().kind {
token::Ident(..) => self.parse_dot_suffix(base, lo),
@@ -1056,12 +1062,76 @@ impl<'a> Parser<'a> {

/// Parse a function call expression, `expr(...)`.
fn parse_fn_call_expr(&mut self, lo: Span, fun: P<Expr>) -> P<Expr> {
let seq = self.parse_paren_expr_seq().map(|args| {
let snapshot = if self.token.kind == token::OpenDelim(token::Paren)
&& self.look_ahead_type_ascription_as_field()
{
Some((self.clone(), fun.kind.clone()))
} else {
None
};
let open_paren = self.token.span;

let mut seq = self.parse_paren_expr_seq().map(|args| {
self.mk_expr(lo.to(self.prev_token.span), self.mk_call(fun, args), AttrVec::new())
});
if let Some(expr) =
self.maybe_recover_struct_lit_bad_delims(lo, open_paren, &mut seq, snapshot)
{
return expr;
}
self.recover_seq_parse_error(token::Paren, lo, seq)
}

/// If we encounter a parser state that looks like the user has written a `struct` literal with
/// parentheses instead of braces, recover the parser state and provide suggestions.
fn maybe_recover_struct_lit_bad_delims(
&mut self,
lo: Span,
open_paren: Span,
seq: &mut PResult<'a, P<Expr>>,
snapshot: Option<(Self, ExprKind)>,
) -> Option<P<Expr>> {
match (seq.as_mut(), snapshot) {
(Err(ref mut err), Some((mut snapshot, ExprKind::Path(None, path)))) => {
let name = pprust::path_to_string(&path);
snapshot.bump(); // `(`
match snapshot.parse_struct_fields(path.clone(), false, token::Paren) {
Ok((fields, ..)) if snapshot.eat(&token::CloseDelim(token::Paren)) => {
// We have are certain we have `Enum::Foo(a: 3, b: 4)`, suggest
// `Enum::Foo { a: 3, b: 4 }` or `Enum::Foo(3, 4)`.
*self = snapshot;
let close_paren = self.prev_token.span;
let span = lo.to(self.prev_token.span);
err.cancel();
self.struct_span_err(
span,
"invalid `struct` delimiters or `fn` call arguments",
)
.multipart_suggestion(
&format!("if `{}` is a struct, use braces as delimiters", name),
vec![(open_paren, " { ".to_string()), (close_paren, " }".to_string())],
Applicability::MaybeIncorrect,
)
.multipart_suggestion(
&format!("if `{}` is a function, use the arguments directly", name),
fields
.into_iter()
.map(|field| (field.span.until(field.expr.span), String::new()))
.collect(),
Applicability::MaybeIncorrect,
)
.emit();
return Some(self.mk_expr_err(span));
}
Ok(_) => {}
Err(mut err) => err.emit(),
}
}
_ => {}
}
None
}

/// Parse an indexing expression `expr[...]`.
fn parse_index_expr(&mut self, lo: Span, base: P<Expr>) -> PResult<'a, P<Expr>> {
self.bump(); // `[`
@@ -2374,14 +2444,12 @@ impl<'a> Parser<'a> {
.emit();
}

/// Precondition: already parsed the '{'.
pub(super) fn parse_struct_expr(
pub(super) fn parse_struct_fields(
&mut self,
qself: Option<ast::QSelf>,
pth: ast::Path,
attrs: AttrVec,
recover: bool,
) -> PResult<'a, P<Expr>> {
close_delim: token::DelimToken,
) -> PResult<'a, (Vec<ExprField>, ast::StructRest, bool)> {
let mut fields = Vec::new();
let mut base = ast::StructRest::None;
let mut recover_async = false;
@@ -2393,11 +2461,11 @@ impl<'a> Parser<'a> {
e.note("for more on editions, read https://doc.rust-lang.org/edition-guide");
};

while self.token != token::CloseDelim(token::Brace) {
while self.token != token::CloseDelim(close_delim) {
if self.eat(&token::DotDot) {
let exp_span = self.prev_token.span;
// We permit `.. }` on the left-hand side of a destructuring assignment.
if self.check(&token::CloseDelim(token::Brace)) {
if self.check(&token::CloseDelim(close_delim)) {
self.sess.gated_spans.gate(sym::destructuring_assignment, self.prev_token.span);
base = ast::StructRest::Rest(self.prev_token.span.shrink_to_hi());
break;
@@ -2438,7 +2506,7 @@ impl<'a> Parser<'a> {
}
};

match self.expect_one_of(&[token::Comma], &[token::CloseDelim(token::Brace)]) {
match self.expect_one_of(&[token::Comma], &[token::CloseDelim(close_delim)]) {
Ok(_) => {
if let Some(f) = parsed_field.or(recovery_field) {
// Only include the field if there's no parse error for the field name.
@@ -2469,8 +2537,21 @@ impl<'a> Parser<'a> {
}
}
}
Ok((fields, base, recover_async))
}

let span = pth.span.to(self.token.span);
/// Precondition: already parsed the '{'.
pub(super) fn parse_struct_expr(
&mut self,
qself: Option<ast::QSelf>,
pth: ast::Path,
attrs: AttrVec,
recover: bool,
) -> PResult<'a, P<Expr>> {
let lo = pth.span;
let (fields, base, recover_async) =
self.parse_struct_fields(pth.clone(), recover, token::Brace)?;
let span = lo.to(self.token.span);
self.expect(&token::CloseDelim(token::Brace))?;
let expr = if recover_async {
ExprKind::Err
22 changes: 5 additions & 17 deletions compiler/rustc_session/src/filesearch.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! A module for searching for libraries
pub use self::FileMatch::*;

use std::env;
@@ -14,8 +16,6 @@ pub enum FileMatch {
FileDoesntMatch,
}

// A module for searching for libraries

#[derive(Clone)]
pub struct FileSearch<'a> {
sysroot: &'a Path,
@@ -83,22 +83,10 @@ impl<'a> FileSearch<'a> {
FileSearch { sysroot, triple, search_paths, tlib_path, kind }
}

// Returns just the directories within the search paths.
/// Returns just the directories within the search paths.
pub fn search_path_dirs(&self) -> Vec<PathBuf> {
self.search_paths().map(|sp| sp.dir.to_path_buf()).collect()
}

// Returns a list of directories where target-specific tool binaries are located.
pub fn get_tools_search_paths(&self, self_contained: bool) -> Vec<PathBuf> {
let rustlib_path = rustc_target::target_rustlib_path(self.sysroot, &self.triple);
let p = std::array::IntoIter::new([
Path::new(&self.sysroot),
Path::new(&rustlib_path),
Path::new("bin"),
])
.collect::<PathBuf>();
if self_contained { vec![p.clone(), p.join("self-contained")] } else { vec![p] }
}
}

pub fn make_target_lib_path(sysroot: &Path, target_triple: &str) -> PathBuf {
@@ -107,8 +95,8 @@ pub fn make_target_lib_path(sysroot: &Path, target_triple: &str) -> PathBuf {
.collect::<PathBuf>()
}

// This function checks if sysroot is found using env::args().next(), and if it
// is not found, uses env::current_exe() to imply sysroot.
/// This function checks if sysroot is found using env::args().next(), and if it
/// is not found, uses env::current_exe() to imply sysroot.
pub fn get_or_default_sysroot() -> PathBuf {
// Follow symlinks. If the resolved path is relative, make it absolute.
fn canonicalize(path: PathBuf) -> PathBuf {
22 changes: 11 additions & 11 deletions compiler/rustc_session/src/search_paths.rs
Original file line number Diff line number Diff line change
@@ -9,17 +9,17 @@ pub struct SearchPath {
pub files: Vec<SearchPathFile>,
}

// The obvious implementation of `SearchPath::files` is a `Vec<PathBuf>`. But
// it is searched repeatedly by `find_library_crate`, and the searches involve
// checking the prefix and suffix of the filename of each `PathBuf`. This is
// doable, but very slow, because it involves calls to `file_name` and
// `extension` that are themselves slow.
//
// This type augments the `PathBuf` with an `Option<String>` containing the
// `PathBuf`'s filename. The prefix and suffix checking is much faster on the
// `Option<String>` than the `PathBuf`. (It's an `Option` because
// `Path::file_name` can fail; if that happens then all subsequent checking
// will also fail, which is fine.)
/// The obvious implementation of `SearchPath::files` is a `Vec<PathBuf>`. But
/// it is searched repeatedly by `find_library_crate`, and the searches involve
/// checking the prefix and suffix of the filename of each `PathBuf`. This is
/// doable, but very slow, because it involves calls to `file_name` and
/// `extension` that are themselves slow.
///
/// This type augments the `PathBuf` with an `Option<String>` containing the
/// `PathBuf`'s filename. The prefix and suffix checking is much faster on the
/// `Option<String>` than the `PathBuf`. (It's an `Option` because
/// `Path::file_name` can fail; if that happens then all subsequent checking
/// will also fail, which is fine.)
#[derive(Clone, Debug)]
pub struct SearchPathFile {
pub path: PathBuf,
30 changes: 21 additions & 9 deletions compiler/rustc_session/src/session.rs
Original file line number Diff line number Diff line change
@@ -36,7 +36,7 @@ use std::fmt;
use std::io::Write;
use std::num::NonZeroU32;
use std::ops::{Div, Mul};
use std::path::PathBuf;
use std::path::{Path, PathBuf};
use std::str::FromStr;
use std::sync::Arc;
use std::time::Duration;
@@ -131,9 +131,8 @@ pub struct Session {
pub target: Target,
pub host: Target,
pub opts: config::Options,
pub host_tlib_path: SearchPath,
/// `None` if the host and target are the same.
pub target_tlib_path: Option<SearchPath>,
pub host_tlib_path: Lrc<SearchPath>,
pub target_tlib_path: Lrc<SearchPath>,
pub parse_sess: ParseSess,
pub sysroot: PathBuf,
/// The name of the root source file of the crate, in the local file system.
@@ -787,8 +786,7 @@ impl Session {
&self.sysroot,
self.opts.target_triple.triple(),
&self.opts.search_paths,
// `target_tlib_path == None` means it's the same as `host_tlib_path`.
self.target_tlib_path.as_ref().unwrap_or(&self.host_tlib_path),
&self.target_tlib_path,
kind,
)
}
@@ -802,6 +800,18 @@ impl Session {
)
}

/// Returns a list of directories where target-specific tool binaries are located.
pub fn get_tools_search_paths(&self, self_contained: bool) -> Vec<PathBuf> {
let rustlib_path = rustc_target::target_rustlib_path(&self.sysroot, &config::host_triple());
let p = std::array::IntoIter::new([
Path::new(&self.sysroot),
Path::new(&rustlib_path),
Path::new("bin"),
])
.collect::<PathBuf>();
if self_contained { vec![p.clone(), p.join("self-contained")] } else { vec![p] }
}

pub fn init_incr_comp_session(
&self,
session_dir: PathBuf,
@@ -1245,11 +1255,13 @@ pub fn build_session(

let host_triple = config::host_triple();
let target_triple = sopts.target_triple.triple();
let host_tlib_path = SearchPath::from_sysroot_and_triple(&sysroot, host_triple);
let host_tlib_path = Lrc::new(SearchPath::from_sysroot_and_triple(&sysroot, host_triple));
let target_tlib_path = if host_triple == target_triple {
None
// Use the same `SearchPath` if host and target triple are identical to avoid unnecessary
// rescanning of the target lib path and an unnecessary allocation.
host_tlib_path.clone()
} else {
Some(SearchPath::from_sysroot_and_triple(&sysroot, target_triple))
Lrc::new(SearchPath::from_sysroot_and_triple(&sysroot, target_triple))
};

let file_path_mapping = sopts.file_path_mapping();
Original file line number Diff line number Diff line change
@@ -9,6 +9,7 @@ pub fn target() -> Target {
options: TargetOptions {
mcount: "\u{1}_mcount".to_string(),
max_atomic_width: Some(128),
features: "+outline-atomics".to_string(),
supported_sanitizers: SanitizerSet::ADDRESS
| SanitizerSet::LEAK
| SanitizerSet::MEMORY
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@ use crate::spec::{Target, TargetOptions};
pub fn target() -> Target {
let mut base = super::linux_musl_base::opts();
base.max_atomic_width = Some(128);
base.features = "+outline-atomics".to_string();

Target {
llvm_target: "aarch64-unknown-linux-musl".to_string(),
2 changes: 1 addition & 1 deletion library/backtrace
7 changes: 4 additions & 3 deletions library/core/src/iter/traits/iterator.rs
Original file line number Diff line number Diff line change
@@ -2172,8 +2172,9 @@ pub trait Iterator {
/// If the iterator is empty, returns [`None`]; otherwise, returns the
/// result of the reduction.
///
/// The reducing function is a closure with two arguments: an 'accumulator', and an element.
/// For iterators with at least one element, this is the same as [`fold()`]
/// with the first element of the iterator as the initial value, folding
/// with the first element of the iterator as the initial accumulator value, folding
/// every subsequent element into it.
///
/// [`fold()`]: Iterator::fold
@@ -2187,8 +2188,8 @@ pub trait Iterator {
/// where I: Iterator,
/// I::Item: Ord,
/// {
/// iter.reduce(|a, b| {
/// if a >= b { a } else { b }
/// iter.reduce(|accum, item| {
/// if accum >= item { accum } else { item }
/// })
/// }
/// let a = [10, 20, 5, -23, 0];
3 changes: 3 additions & 0 deletions library/std/src/ffi/c_str.rs
Original file line number Diff line number Diff line change
@@ -915,6 +915,7 @@ impl From<CString> for Box<CStr> {

#[stable(feature = "cow_from_cstr", since = "1.28.0")]
impl<'a> From<CString> for Cow<'a, CStr> {
/// Converts a [`CString`] into an owned [`Cow`] without copying or allocating.
#[inline]
fn from(s: CString) -> Cow<'a, CStr> {
Cow::Owned(s)
@@ -923,6 +924,7 @@ impl<'a> From<CString> for Cow<'a, CStr> {

#[stable(feature = "cow_from_cstr", since = "1.28.0")]
impl<'a> From<&'a CStr> for Cow<'a, CStr> {
/// Converts a [`CStr`] into a borrowed [`Cow`] without copying or allocating.
#[inline]
fn from(s: &'a CStr) -> Cow<'a, CStr> {
Cow::Borrowed(s)
@@ -931,6 +933,7 @@ impl<'a> From<&'a CStr> for Cow<'a, CStr> {

#[stable(feature = "cow_from_cstr", since = "1.28.0")]
impl<'a> From<&'a CString> for Cow<'a, CStr> {
/// Converts a `&`[`CString`] into a borrowed [`Cow`] without copying or allocating.
#[inline]
fn from(s: &'a CString) -> Cow<'a, CStr> {
Cow::Borrowed(s.as_c_str())
70 changes: 70 additions & 0 deletions library/std/src/os/unix/fs.rs
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@
use super::platform::fs::MetadataExt as _;
use crate::fs::{self, OpenOptions, Permissions};
use crate::io;
use crate::os::unix::io::{AsFd, AsRawFd};
use crate::path::Path;
use crate::sys;
use crate::sys_common::{AsInner, AsInnerMut, FromInner};
@@ -924,6 +925,75 @@ impl DirBuilderExt for fs::DirBuilder {
}
}

/// Change the owner and group of the specified path.
///
/// Specifying either the uid or gid as `None` will leave it unchanged.
///
/// Changing the owner typically requires privileges, such as root or a specific capability.
/// Changing the group typically requires either being the owner and a member of the group, or
/// having privileges.
///
/// If called on a symbolic link, this will change the owner and group of the link target. To
/// change the owner and group of the link itself, see [`lchown`].
///
/// # Examples
///
/// ```no_run
/// #![feature(unix_chown)]
/// use std::os::unix::fs;
///
/// fn main() -> std::io::Result<()> {
/// fs::chown("/sandbox", Some(0), Some(0))?;
/// Ok(())
/// }
/// ```
#[unstable(feature = "unix_chown", issue = "88989")]
pub fn chown<P: AsRef<Path>>(dir: P, uid: Option<u32>, gid: Option<u32>) -> io::Result<()> {
sys::fs::chown(dir.as_ref(), uid.unwrap_or(u32::MAX), gid.unwrap_or(u32::MAX))
}

/// Change the owner and group of the file referenced by the specified open file descriptor.
///
/// For semantics and required privileges, see [`chown`].
///
/// # Examples
///
/// ```no_run
/// #![feature(unix_chown)]
/// use std::os::unix::fs;
///
/// fn main() -> std::io::Result<()> {
/// let f = std::fs::File::open("/file")?;
/// fs::fchown(f, Some(0), Some(0))?;
/// Ok(())
/// }
/// ```
#[unstable(feature = "unix_chown", issue = "88989")]
pub fn fchown<F: AsFd>(fd: F, uid: Option<u32>, gid: Option<u32>) -> io::Result<()> {
sys::fs::fchown(fd.as_fd().as_raw_fd(), uid.unwrap_or(u32::MAX), gid.unwrap_or(u32::MAX))
}

/// Change the owner and group of the specified path, without dereferencing symbolic links.
///
/// Identical to [`chown`], except that if called on a symbolic link, this will change the owner
/// and group of the link itself rather than the owner and group of the link target.
///
/// # Examples
///
/// ```no_run
/// #![feature(unix_chown)]
/// use std::os::unix::fs;
///
/// fn main() -> std::io::Result<()> {
/// fs::lchown("/symlink", Some(0), Some(0))?;
/// Ok(())
/// }
/// ```
#[unstable(feature = "unix_chown", issue = "88989")]
pub fn lchown<P: AsRef<Path>>(dir: P, uid: Option<u32>, gid: Option<u32>) -> io::Result<()> {
sys::fs::lchown(dir.as_ref(), uid.unwrap_or(u32::MAX), gid.unwrap_or(u32::MAX))
}

/// Change the root directory of the current process to the specified path.
///
/// This typically requires privileges, such as root or a specific capability.
17 changes: 17 additions & 0 deletions library/std/src/sys/unix/fs.rs
Original file line number Diff line number Diff line change
@@ -1416,6 +1416,23 @@ pub fn copy(from: &Path, to: &Path) -> io::Result<u64> {
Ok(bytes_copied as u64)
}

pub fn chown(path: &Path, uid: u32, gid: u32) -> io::Result<()> {
let path = cstr(path)?;
cvt(unsafe { libc::chown(path.as_ptr(), uid as libc::uid_t, gid as libc::gid_t) })?;
Ok(())
}

pub fn fchown(fd: c_int, uid: u32, gid: u32) -> io::Result<()> {
cvt(unsafe { libc::fchown(fd, uid as libc::uid_t, gid as libc::gid_t) })?;
Ok(())
}

pub fn lchown(path: &Path, uid: u32, gid: u32) -> io::Result<()> {
let path = cstr(path)?;
cvt(unsafe { libc::lchown(path.as_ptr(), uid as libc::uid_t, gid as libc::gid_t) })?;
Ok(())
}

#[cfg(not(any(target_os = "fuchsia", target_os = "vxworks")))]
pub fn chroot(dir: &Path) -> io::Result<()> {
let dir = cstr(dir)?;
6 changes: 3 additions & 3 deletions src/doc/unstable-book/src/library-features/asm.md
Original file line number Diff line number Diff line change
@@ -804,9 +804,9 @@ The following ABIs can be used with `clobber_abi`:

| Architecture | ABI name | Clobbered registers |
| ------------ | -------- | ------------------- |
| x86-32 | `"C"`, `"system"`, `"efiapi"`, `"cdecl"`, `"stdcall"`, `"fastcall"` | `ax`, `cx`, `dx`, `xmm[0-7]`, `mm[0-7]`, `st([0-7])` |
| x86-64 | `"C"`, `"system"` (on Windows), `"efiapi"`, `"win64"` | `ax`, `cx`, `dx`, `r[8-11]`, `xmm[0-31]`, `mm[0-7]`, `st([0-7])` |
| x86-64 | `"C"`, `"system"` (on non-Windows), `"sysv64"` | `ax`, `cx`, `dx`, `si`, `di`, `r[8-11]`, `xmm[0-31]`, `mm[0-7]`, `st([0-7])` |
| x86-32 | `"C"`, `"system"`, `"efiapi"`, `"cdecl"`, `"stdcall"`, `"fastcall"` | `ax`, `cx`, `dx`, `xmm[0-7]`, `mm[0-7]`, `k[1-7]`, `st([0-7])` |
| x86-64 | `"C"`, `"system"` (on Windows), `"efiapi"`, `"win64"` | `ax`, `cx`, `dx`, `r[8-11]`, `xmm[0-31]`, `mm[0-7]`, `k[1-7]`, `st([0-7])` |
| x86-64 | `"C"`, `"system"` (on non-Windows), `"sysv64"` | `ax`, `cx`, `dx`, `si`, `di`, `r[8-11]`, `xmm[0-31]`, `mm[0-7]`, `k[1-7]`, `st([0-7])` |
| AArch64 | `"C"`, `"system"`, `"efiapi"` | `x[0-17]`, `x30`, `v[0-31]`, `p[0-15]`, `ffr` |
| ARM | `"C"`, `"system"`, `"efiapi"`, `"aapcs"` | `r[0-3]`, `r12`, `r14`, `s[0-15]`, `d[0-7]`, `d[16-31]` |
| RISC-V | `"C"`, `"system"`, `"efiapi"` | `x1`, `x[5-7]`, `x[10-17]`, `x[28-31]`, `f[0-7]`, `f[10-17]`, `f[28-31]`, `v[0-31]` |
16 changes: 16 additions & 0 deletions src/test/assembly/asm/aarch64-outline-atomics.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// min-llvm-version: 12.0
// assembly-output: emit-asm
// compile-flags: -O
// compile-flags: --target aarch64-unknown-linux-gnu
// needs-llvm-components: aarch64
// only-aarch64

#![crate_type = "rlib"]

use std::sync::atomic::{AtomicI32, Ordering::*};

pub fn compare_exchange(a: &AtomicI32) {
// On AArch64 LLVM should outline atomic operations.
// CHECK: __aarch64_cas4_relax
let _ = a.compare_exchange(0, 10, Relaxed, Relaxed);
}
1 change: 1 addition & 0 deletions src/test/ui/abi/unsupported.aarch64.stderr
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
'+outline-atomics' is not a recognized feature for this target (ignoring feature)
error[E0570]: `"ptx-kernel"` is not a supported ABI for the current target
--> $DIR/unsupported.rs:26:1
|
Original file line number Diff line number Diff line change
@@ -4,14 +4,14 @@ error[E0038]: the trait `Trait` cannot be made into an object
LL | impl dyn Trait {
| ^^^^^^^^^ `Trait` cannot be made into an object
|
= help: consider moving `N` to another trait
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/associated-const-in-trait.rs:6:11
|
LL | trait Trait {
| ----- this trait cannot be made into an object...
LL | const N: usize;
| ^ ...because it contains this associated `const`
= help: consider moving `N` to another trait

error: aborting due to previous error

2 changes: 1 addition & 1 deletion src/test/ui/associated-item/issue-48027.stderr
Original file line number Diff line number Diff line change
@@ -21,14 +21,14 @@ error[E0038]: the trait `Bar` cannot be made into an object
LL | impl dyn Bar {}
| ^^^^^^^ `Bar` cannot be made into an object
|
= help: consider moving `X` to another trait
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/issue-48027.rs:2:11
|
LL | trait Bar {
| --- this trait cannot be made into an object...
LL | const X: usize;
| ^ ...because it contains this associated `const`
= help: consider moving `X` to another trait

error: aborting due to 2 previous errors

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -4,14 +4,14 @@ error[E0038]: the trait `NotObjectSafe` cannot be made into an object
LL | impl NotObjectSafe for dyn NotObjectSafe { }
| ^^^^^^^^^^^^^^^^^ `NotObjectSafe` cannot be made into an object
|
= help: consider moving `eq` to another trait
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/coherence-impl-trait-for-trait-object-safe.rs:6:43
|
LL | trait NotObjectSafe { fn eq(&self, other: Self); }
| ------------- ^^^^ ...because method `eq` references the `Self` type in this parameter
| |
| this trait cannot be made into an object...
= help: consider moving `eq` to another trait

error: aborting due to previous error

Original file line number Diff line number Diff line change
@@ -4,14 +4,14 @@ error[E0038]: the trait `Foo` cannot be made into an object
LL | fn use_dyn(v: &dyn Foo) {
| ^^^^^^^ `Foo` cannot be made into an object
|
= help: consider moving `test` to another trait
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/object-safety-err-ret.rs:8:23
|
LL | trait Foo {
| --- this trait cannot be made into an object...
LL | fn test(&self) -> [u8; bar::<Self>()];
| ^^^^^^^^^^^^^^^^^^^ ...because method `test` references the `Self` type in its return type
= help: consider moving `test` to another trait

error: aborting due to previous error

File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/test/ui/error-codes/E0038.stderr
Original file line number Diff line number Diff line change
@@ -4,14 +4,14 @@ error[E0038]: the trait `Trait` cannot be made into an object
LL | fn call_foo(x: Box<dyn Trait>) {
| ^^^^^^^^^ `Trait` cannot be made into an object
|
= help: consider moving `foo` to another trait
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/E0038.rs:2:22
|
LL | trait Trait {
| ----- this trait cannot be made into an object...
LL | fn foo(&self) -> Self;
| ^^^^ ...because method `foo` references the `Self` type in its return type
= help: consider moving `foo` to another trait

error: aborting due to previous error

Original file line number Diff line number Diff line change
@@ -40,29 +40,29 @@ error[E0038]: the trait `NonObjectSafe3` cannot be made into an object
LL | fn takes_non_object_safe_box(obj: Box<dyn NonObjectSafe3>) {
| ^^^^^^^^^^^^^^^^^^ `NonObjectSafe3` cannot be made into an object
|
= help: consider moving `foo` to another trait
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/feature-gate-object_safe_for_dispatch.rs:11:8
|
LL | trait NonObjectSafe3 {
| -------------- this trait cannot be made into an object...
LL | fn foo<T>(&self);
| ^^^ ...because method `foo` has generic type parameters
= help: consider moving `foo` to another trait

error[E0038]: the trait `NonObjectSafe4` cannot be made into an object
--> $DIR/feature-gate-object_safe_for_dispatch.rs:31:35
|
LL | fn return_non_object_safe_rc() -> std::rc::Rc<dyn NonObjectSafe4> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `NonObjectSafe4` cannot be made into an object
|
= help: consider moving `foo` to another trait
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/feature-gate-object_safe_for_dispatch.rs:15:22
|
LL | trait NonObjectSafe4 {
| -------------- this trait cannot be made into an object...
LL | fn foo(&self, s: &Self);
| ^^^^^ ...because method `foo` references the `Self` type in this parameter
= help: consider moving `foo` to another trait

error[E0038]: the trait `NonObjectSafe1` cannot be made into an object
--> $DIR/feature-gate-object_safe_for_dispatch.rs:38:16
Original file line number Diff line number Diff line change
@@ -4,14 +4,14 @@ error[E0038]: the trait `Foo` cannot be made into an object
LL | fn f(_arg : Box<dyn for<'a> Foo<A<'a> = &'a ()>>) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `Foo` cannot be made into an object
|
= help: consider moving `A` to another trait
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/gat-in-trait-path.rs:5:10
|
LL | trait Foo {
| --- this trait cannot be made into an object...
LL | type A<'a> where Self: 'a;
| ^ ...because it contains the generic associated type `A`
= help: consider moving `A` to another trait

error: aborting due to previous error

Original file line number Diff line number Diff line change
@@ -4,14 +4,14 @@ error[E0038]: the trait `X` cannot be made into an object
LL | fn _func1<'a>(_x: Box<dyn X<Y<'a>=&'a ()>>) {}
| ^^^^^^^^^^^^^^^^^^^ `X` cannot be made into an object
|
= help: consider moving `Y` to another trait
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/issue-67510-pass.rs:4:10
|
LL | trait X {
| - this trait cannot be made into an object...
LL | type Y<'a>;
| ^ ...because it contains the generic associated type `Y`
= help: consider moving `Y` to another trait

error: aborting due to previous error

4 changes: 2 additions & 2 deletions src/test/ui/generic-associated-types/issue-76535.stderr
Original file line number Diff line number Diff line change
@@ -20,29 +20,29 @@ error[E0038]: the trait `SuperTrait` cannot be made into an object
LL | let sub: Box<dyn SuperTrait<SubType = SubStruct>> = Box::new(SuperStruct::new(0));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `SuperTrait` cannot be made into an object
|
= help: consider moving `SubType` to another trait
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/issue-76535.rs:6:10
|
LL | pub trait SuperTrait {
| ---------- this trait cannot be made into an object...
LL | type SubType<'a>: SubTrait;
| ^^^^^^^ ...because it contains the generic associated type `SubType`
= help: consider moving `SubType` to another trait

error[E0038]: the trait `SuperTrait` cannot be made into an object
--> $DIR/issue-76535.rs:36:57
|
LL | let sub: Box<dyn SuperTrait<SubType = SubStruct>> = Box::new(SuperStruct::new(0));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `SuperTrait` cannot be made into an object
|
= help: consider moving `SubType` to another trait
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/issue-76535.rs:6:10
|
LL | pub trait SuperTrait {
| ---------- this trait cannot be made into an object...
LL | type SubType<'a>: SubTrait;
| ^^^^^^^ ...because it contains the generic associated type `SubType`
= help: consider moving `SubType` to another trait
= note: required because of the requirements on the impl of `CoerceUnsized<Box<dyn SuperTrait<SubType = SubStruct<'_>>>>` for `Box<SuperStruct>`
= note: required by cast to type `Box<dyn SuperTrait<SubType = SubStruct<'_>>>`

2 changes: 1 addition & 1 deletion src/test/ui/generic-associated-types/issue-78671.stderr
Original file line number Diff line number Diff line change
@@ -20,14 +20,14 @@ error[E0038]: the trait `CollectionFamily` cannot be made into an object
LL | Box::new(Family) as &dyn CollectionFamily<Member=usize>
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `CollectionFamily` cannot be made into an object
|
= help: consider moving `Member` to another trait
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/issue-78671.rs:4:10
|
LL | trait CollectionFamily {
| ---------------- this trait cannot be made into an object...
LL | type Member<T>;
| ^^^^^^ ...because it contains the generic associated type `Member`
= help: consider moving `Member` to another trait

error: aborting due to 2 previous errors

4 changes: 2 additions & 2 deletions src/test/ui/generic-associated-types/issue-79422.stderr
Original file line number Diff line number Diff line change
@@ -20,29 +20,29 @@ error[E0038]: the trait `MapLike` cannot be made into an object
LL | as Box<dyn MapLike<u8, u8, VRefCont = dyn RefCont<'_, u8>>>;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `MapLike` cannot be made into an object
|
= help: consider moving `VRefCont` to another trait
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/issue-79422.rs:20:10
|
LL | trait MapLike<K, V> {
| ------- this trait cannot be made into an object...
LL | type VRefCont<'a>: RefCont<'a, V>;
| ^^^^^^^^ ...because it contains the generic associated type `VRefCont`
= help: consider moving `VRefCont` to another trait

error[E0038]: the trait `MapLike` cannot be made into an object
--> $DIR/issue-79422.rs:41:13
|
LL | let m = Box::new(std::collections::BTreeMap::<u8, u8>::new())
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `MapLike` cannot be made into an object
|
= help: consider moving `VRefCont` to another trait
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/issue-79422.rs:20:10
|
LL | trait MapLike<K, V> {
| ------- this trait cannot be made into an object...
LL | type VRefCont<'a>: RefCont<'a, V>;
| ^^^^^^^^ ...because it contains the generic associated type `VRefCont`
= help: consider moving `VRefCont` to another trait
= note: required because of the requirements on the impl of `CoerceUnsized<Box<dyn MapLike<u8, u8, VRefCont = (dyn RefCont<'_, u8> + 'static)>>>` for `Box<BTreeMap<u8, u8>>`
= note: required by cast to type `Box<dyn MapLike<u8, u8, VRefCont = (dyn RefCont<'_, u8> + 'static)>>`

2 changes: 1 addition & 1 deletion src/test/ui/generic-associated-types/trait-objects.stderr
Original file line number Diff line number Diff line change
@@ -4,14 +4,14 @@ error[E0038]: the trait `StreamingIterator` cannot be made into an object
LL | fn min_size(x: &mut dyn for<'a> StreamingIterator<Item<'a> = &'a i32>) -> usize {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `StreamingIterator` cannot be made into an object
|
= help: consider moving `Item` to another trait
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/trait-objects.rs:4:10
|
LL | trait StreamingIterator {
| ----------------- this trait cannot be made into an object...
LL | type Item<'a> where Self: 'a;
| ^^^^ ...because it contains the generic associated type `Item`
= help: consider moving `Item` to another trait

error: aborting due to previous error

File renamed without changes.
2 changes: 1 addition & 1 deletion src/test/ui/issues/issue-18959.stderr
Original file line number Diff line number Diff line change
@@ -4,14 +4,14 @@ error[E0038]: the trait `Bar` cannot be made into an object
LL | fn foo(b: &dyn Bar) {
| ^^^^^^^ `Bar` cannot be made into an object
|
= help: consider moving `foo` to another trait
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/issue-18959.rs:1:20
|
LL | pub trait Foo { fn foo<T>(&self, ext_thing: &T); }
| ^^^ ...because method `foo` has generic type parameters
LL | pub trait Bar: Foo { }
| --- this trait cannot be made into an object...
= help: consider moving `foo` to another trait

error: aborting due to previous error

4 changes: 2 additions & 2 deletions src/test/ui/issues/issue-19538.stderr
Original file line number Diff line number Diff line change
@@ -4,7 +4,6 @@ error[E0038]: the trait `Bar` cannot be made into an object
LL | let test: &mut dyn Bar = &mut thing;
| ^^^^^^^^^^^^ `Bar` cannot be made into an object
|
= help: consider moving `foo` to another trait
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/issue-19538.rs:2:8
|
@@ -13,14 +12,14 @@ LL | fn foo<T>(&self, val: T);
...
LL | trait Bar: Foo { }
| --- this trait cannot be made into an object...
= help: consider moving `foo` to another trait

error[E0038]: the trait `Bar` cannot be made into an object
--> $DIR/issue-19538.rs:17:30
|
LL | let test: &mut dyn Bar = &mut thing;
| ^^^^^^^^^^ `Bar` cannot be made into an object
|
= help: consider moving `foo` to another trait
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/issue-19538.rs:2:8
|
@@ -29,6 +28,7 @@ LL | fn foo<T>(&self, val: T);
...
LL | trait Bar: Foo { }
| --- this trait cannot be made into an object...
= help: consider moving `foo` to another trait
= note: required because of the requirements on the impl of `CoerceUnsized<&mut dyn Bar>` for `&mut Thing`
= note: required by cast to type `&mut dyn Bar`

2 changes: 1 addition & 1 deletion src/test/ui/issues/issue-34255-1.rs
Original file line number Diff line number Diff line change
@@ -6,5 +6,5 @@ enum Test {

fn main() {
Test::Drill(field: 42);
//~^ ERROR expected type, found
//~^ ERROR invalid `struct` delimiters or `fn` call arguments
}
19 changes: 12 additions & 7 deletions src/test/ui/issues/issue-34255-1.stderr
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
error: expected type, found `42`
--> $DIR/issue-34255-1.rs:8:24
error: invalid `struct` delimiters or `fn` call arguments
--> $DIR/issue-34255-1.rs:8:5
|
LL | Test::Drill(field: 42);
| - ^^ expected type
| |
| tried to parse a type due to this type ascription
| ^^^^^^^^^^^^^^^^^^^^^^
|
= note: `#![feature(type_ascription)]` lets you annotate an expression with a type: `<expr>: <type>`
= note: see issue #23416 <https://github.com/rust-lang/rust/issues/23416> for more information
help: if `Test::Drill` is a struct, use braces as delimiters
|
LL | Test::Drill { field: 42 };
| ~ ~
help: if `Test::Drill` is a function, use the arguments directly
|
LL - Test::Drill(field: 42);
LL + Test::Drill(42);
|

error: aborting due to previous error

14 changes: 0 additions & 14 deletions src/test/ui/issues/issue-5791.rs

This file was deleted.

21 changes: 0 additions & 21 deletions src/test/ui/issues/issue-5791.stderr

This file was deleted.

2 changes: 1 addition & 1 deletion src/test/ui/issues/issue-61882-2.stderr
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@ LL | Self(&x);
| ^^
| |
| borrowed value does not live long enough
| requires that `x` is borrowed for `'static`
| this usage requires that `x` is borrowed for `'static`
LL |
LL | }
| - `x` dropped here while still borrowed
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
16 changes: 16 additions & 0 deletions src/test/ui/mir/remove-zsts-query-cycle.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Regression test for #88972. Used to cause a query cycle:
// optimized mir -> remove zsts -> layout of a generator -> optimized mir.
//
// edition:2018
// compile-flags: --crate-type=lib
// build-pass

pub async fn listen() -> Result<(), std::io::Error> {
let f = do_async();
std::mem::forget(f);
Ok(())
}

pub async fn do_async() {
listen().await.unwrap()
}
File renamed without changes.
2 changes: 1 addition & 1 deletion src/test/ui/nll/issue-46036.stderr
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@ LL | let foo = Foo { x: &a };
| ^^
| |
| borrowed value does not live long enough
| requires that `a` is borrowed for `'static`
| this usage requires that `a` is borrowed for `'static`
LL | loop { }
LL | }
| - `a` dropped here while still borrowed
6 changes: 3 additions & 3 deletions src/test/ui/nll/user-annotations/adt-brace-enums.stderr
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@ LL | SomeEnum::SomeVariant::<&'static u32> { t: &c };
| ^^
| |
| borrowed value does not live long enough
| requires that `c` is borrowed for `'static`
| this usage requires that `c` is borrowed for `'static`
LL | }
| - `c` dropped here while still borrowed

@@ -19,7 +19,7 @@ LL | SomeEnum::SomeVariant::<&'a u32> { t: &c };
| ^^
| |
| borrowed value does not live long enough
| requires that `c` is borrowed for `'a`
| this usage requires that `c` is borrowed for `'a`
LL | }
| - `c` dropped here while still borrowed

@@ -33,7 +33,7 @@ LL | SomeEnum::SomeVariant::<&'a u32> { t: &c };
| ^^
| |
| borrowed value does not live long enough
| requires that `c` is borrowed for `'a`
| this usage requires that `c` is borrowed for `'a`
LL | };
| - `c` dropped here while still borrowed

6 changes: 3 additions & 3 deletions src/test/ui/nll/user-annotations/adt-brace-structs.stderr
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@ LL | SomeStruct::<&'static u32> { t: &c };
| ^^
| |
| borrowed value does not live long enough
| requires that `c` is borrowed for `'static`
| this usage requires that `c` is borrowed for `'static`
LL | }
| - `c` dropped here while still borrowed

@@ -19,7 +19,7 @@ LL | SomeStruct::<&'a u32> { t: &c };
| ^^
| |
| borrowed value does not live long enough
| requires that `c` is borrowed for `'a`
| this usage requires that `c` is borrowed for `'a`
LL | }
| - `c` dropped here while still borrowed

@@ -33,7 +33,7 @@ LL | SomeStruct::<&'a u32> { t: &c };
| ^^
| |
| borrowed value does not live long enough
| requires that `c` is borrowed for `'a`
| this usage requires that `c` is borrowed for `'a`
LL | };
| - `c` dropped here while still borrowed

6 changes: 3 additions & 3 deletions src/test/ui/nll/user-annotations/adt-tuple-enums.stderr
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@ LL | SomeEnum::SomeVariant::<&'static u32>(&c);
| ^^
| |
| borrowed value does not live long enough
| requires that `c` is borrowed for `'static`
| this usage requires that `c` is borrowed for `'static`
LL | }
| - `c` dropped here while still borrowed

@@ -19,7 +19,7 @@ LL | SomeEnum::SomeVariant::<&'a u32>(&c);
| ^^
| |
| borrowed value does not live long enough
| requires that `c` is borrowed for `'a`
| this usage requires that `c` is borrowed for `'a`
LL | }
| - `c` dropped here while still borrowed

@@ -33,7 +33,7 @@ LL | SomeEnum::SomeVariant::<&'a u32>(&c);
| ^^
| |
| borrowed value does not live long enough
| requires that `c` is borrowed for `'a`
| this usage requires that `c` is borrowed for `'a`
LL | };
| - `c` dropped here while still borrowed

6 changes: 3 additions & 3 deletions src/test/ui/nll/user-annotations/adt-tuple-struct.stderr
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@ LL | SomeStruct::<&'static u32>(&c);
| ^^
| |
| borrowed value does not live long enough
| requires that `c` is borrowed for `'static`
| this usage requires that `c` is borrowed for `'static`
LL | }
| - `c` dropped here while still borrowed

@@ -19,7 +19,7 @@ LL | SomeStruct::<&'a u32>(&c);
| ^^
| |
| borrowed value does not live long enough
| requires that `c` is borrowed for `'a`
| this usage requires that `c` is borrowed for `'a`
LL | }
| - `c` dropped here while still borrowed

@@ -33,7 +33,7 @@ LL | SomeStruct::<&'a u32>(&c);
| ^^
| |
| borrowed value does not live long enough
| requires that `c` is borrowed for `'a`
| this usage requires that `c` is borrowed for `'a`
LL | };
| - `c` dropped here while still borrowed

2 changes: 1 addition & 1 deletion src/test/ui/nll/where_clauses_in_structs.stderr
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@ LL | fn bar<'a, 'b>(x: Cell<&'a u32>, y: Cell<&'b u32>) {
| |
| lifetime `'a` defined here
LL | Foo { x, y };
| ^ requires that `'a` must outlive `'b`
| ^ this usage requires that `'a` must outlive `'b`
|
= help: consider adding the following bound: `'a: 'b`

Original file line number Diff line number Diff line change
@@ -4,14 +4,14 @@ error[E0038]: the trait `Bar` cannot be made into an object
LL | fn make_bar<T:Bar>(t: &T) -> &dyn Bar {
| ^^^^^^^^ `Bar` cannot be made into an object
|
= help: consider moving `X` to another trait
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/object-safety-associated-consts.rs:9:11
|
LL | trait Bar {
| --- this trait cannot be made into an object...
LL | const X: usize;
| ^ ...because it contains this associated `const`
= help: consider moving `X` to another trait

error: aborting due to previous error

Original file line number Diff line number Diff line change
@@ -4,14 +4,14 @@ error[E0038]: the trait `Bar` cannot be made into an object
LL | t
| ^ `Bar` cannot be made into an object
|
= help: consider moving `X` to another trait
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/object-safety-associated-consts.rs:9:11
|
LL | trait Bar {
| --- this trait cannot be made into an object...
LL | const X: usize;
| ^ ...because it contains this associated `const`
= help: consider moving `X` to another trait
= note: required because of the requirements on the impl of `CoerceUnsized<&dyn Bar>` for `&T`
= note: required by cast to type `&dyn Bar`

4 changes: 2 additions & 2 deletions src/test/ui/object-safety/object-safety-generics.curr.stderr
Original file line number Diff line number Diff line change
@@ -4,29 +4,29 @@ error[E0038]: the trait `Bar` cannot be made into an object
LL | fn make_bar<T:Bar>(t: &T) -> &dyn Bar {
| ^^^^^^^^ `Bar` cannot be made into an object
|
= help: consider moving `bar` to another trait
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/object-safety-generics.rs:10:8
|
LL | trait Bar {
| --- this trait cannot be made into an object...
LL | fn bar<T>(&self, t: T);
| ^^^ ...because method `bar` has generic type parameters
= help: consider moving `bar` to another trait

error[E0038]: the trait `Bar` cannot be made into an object
--> $DIR/object-safety-generics.rs:24:39
|
LL | fn make_bar_explicit<T:Bar>(t: &T) -> &dyn Bar {
| ^^^^^^^^ `Bar` cannot be made into an object
|
= help: consider moving `bar` to another trait
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/object-safety-generics.rs:10:8
|
LL | trait Bar {
| --- this trait cannot be made into an object...
LL | fn bar<T>(&self, t: T);
| ^^^ ...because method `bar` has generic type parameters
= help: consider moving `bar` to another trait

error: aborting due to 2 previous errors

Original file line number Diff line number Diff line change
@@ -4,14 +4,14 @@ error[E0038]: the trait `Bar` cannot be made into an object
LL | t
| ^ `Bar` cannot be made into an object
|
= help: consider moving `bar` to another trait
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/object-safety-generics.rs:10:8
|
LL | trait Bar {
| --- this trait cannot be made into an object...
LL | fn bar<T>(&self, t: T);
| ^^^ ...because method `bar` has generic type parameters
= help: consider moving `bar` to another trait
= note: required because of the requirements on the impl of `CoerceUnsized<&dyn Bar>` for `&T`
= note: required by cast to type `&dyn Bar`

@@ -21,14 +21,14 @@ error[E0038]: the trait `Bar` cannot be made into an object
LL | t as &dyn Bar
| ^ `Bar` cannot be made into an object
|
= help: consider moving `bar` to another trait
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/object-safety-generics.rs:10:8
|
LL | trait Bar {
| --- this trait cannot be made into an object...
LL | fn bar<T>(&self, t: T);
| ^^^ ...because method `bar` has generic type parameters
= help: consider moving `bar` to another trait
= note: required because of the requirements on the impl of `CoerceUnsized<&dyn Bar>` for `&T`
= note: required by cast to type `&dyn Bar`

Original file line number Diff line number Diff line change
@@ -4,29 +4,29 @@ error[E0038]: the trait `Bar` cannot be made into an object
LL | fn make_bar<T:Bar>(t: &T) -> &dyn Bar {
| ^^^^^^^^ `Bar` cannot be made into an object
|
= help: consider moving `bar` to another trait
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/object-safety-mentions-Self.rs:11:22
|
LL | trait Bar {
| --- this trait cannot be made into an object...
LL | fn bar(&self, x: &Self);
| ^^^^^ ...because method `bar` references the `Self` type in this parameter
= help: consider moving `bar` to another trait

error[E0038]: the trait `Baz` cannot be made into an object
--> $DIR/object-safety-mentions-Self.rs:28:30
|
LL | fn make_baz<T:Baz>(t: &T) -> &dyn Baz {
| ^^^^^^^^ `Baz` cannot be made into an object
|
= help: consider moving `baz` to another trait
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/object-safety-mentions-Self.rs:15:22
|
LL | trait Baz {
| --- this trait cannot be made into an object...
LL | fn baz(&self) -> Self;
| ^^^^ ...because method `baz` references the `Self` type in its return type
= help: consider moving `baz` to another trait

error: aborting due to 2 previous errors

Original file line number Diff line number Diff line change
@@ -4,14 +4,14 @@ error[E0038]: the trait `Bar` cannot be made into an object
LL | t
| ^ `Bar` cannot be made into an object
|
= help: consider moving `bar` to another trait
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/object-safety-mentions-Self.rs:11:22
|
LL | trait Bar {
| --- this trait cannot be made into an object...
LL | fn bar(&self, x: &Self);
| ^^^^^ ...because method `bar` references the `Self` type in this parameter
= help: consider moving `bar` to another trait
= note: required because of the requirements on the impl of `CoerceUnsized<&dyn Bar>` for `&T`
= note: required by cast to type `&dyn Bar`

@@ -21,14 +21,14 @@ error[E0038]: the trait `Baz` cannot be made into an object
LL | t
| ^ `Baz` cannot be made into an object
|
= help: consider moving `baz` to another trait
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/object-safety-mentions-Self.rs:15:22
|
LL | trait Baz {
| --- this trait cannot be made into an object...
LL | fn baz(&self) -> Self;
| ^^^^ ...because method `baz` references the `Self` type in its return type
= help: consider moving `baz` to another trait
= note: required because of the requirements on the impl of `CoerceUnsized<&dyn Baz>` for `&T`
= note: required by cast to type `&dyn Baz`

4 changes: 2 additions & 2 deletions src/test/ui/parser/issue-44406.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
macro_rules! foo {
($rest: tt) => {
bar(baz: $rest)
bar(baz: $rest) //~ ERROR invalid `struct` delimiters or `fn` call arguments
}
}

fn main() {
foo!(true); //~ ERROR expected type, found keyword
foo!(true);
//~^ ERROR expected identifier, found keyword
}
20 changes: 14 additions & 6 deletions src/test/ui/parser/issue-44406.stderr
Original file line number Diff line number Diff line change
@@ -9,17 +9,25 @@ help: you can escape reserved keywords to use them as identifiers
LL | foo!(r#true);
| ~~~~~~

error: expected type, found keyword `true`
--> $DIR/issue-44406.rs:8:10
error: invalid `struct` delimiters or `fn` call arguments
--> $DIR/issue-44406.rs:3:9
|
LL | bar(baz: $rest)
| - help: try using a semicolon: `;`
| ^^^^^^^^^^^^^^^
...
LL | foo!(true);
| ^^^^ expected type
| ----------- in this macro invocation
|
= note: this error originates in the macro `foo` (in Nightly builds, run with -Z macro-backtrace for more info)
help: if `bar` is a struct, use braces as delimiters
|
LL | bar { }
| ~
help: if `bar` is a function, use the arguments directly
|
= note: `#![feature(type_ascription)]` lets you annotate an expression with a type: `<expr>: <type>`
= note: see issue #23416 <https://github.com/rust-lang/rust/issues/23416> for more information
LL - bar(baz: $rest)
LL + bar(true);
|

error: aborting due to 2 previous errors

2 changes: 1 addition & 1 deletion src/test/ui/parser/recover-from-bad-variant.rs
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@ enum Enum {

fn main() {
let x = Enum::Foo(a: 3, b: 4);
//~^ ERROR expected type, found `3`
//~^ ERROR invalid `struct` delimiters or `fn` call arguments
match x {
Enum::Foo(a, b) => {}
//~^ ERROR expected tuple struct or tuple variant, found struct variant `Enum::Foo`
19 changes: 12 additions & 7 deletions src/test/ui/parser/recover-from-bad-variant.stderr
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
error: expected type, found `3`
--> $DIR/recover-from-bad-variant.rs:7:26
error: invalid `struct` delimiters or `fn` call arguments
--> $DIR/recover-from-bad-variant.rs:7:13
|
LL | let x = Enum::Foo(a: 3, b: 4);
| - ^ expected type
| |
| tried to parse a type due to this type ascription
| ^^^^^^^^^^^^^^^^^^^^^
|
= note: `#![feature(type_ascription)]` lets you annotate an expression with a type: `<expr>: <type>`
= note: see issue #23416 <https://github.com/rust-lang/rust/issues/23416> for more information
help: if `Enum::Foo` is a struct, use braces as delimiters
|
LL | let x = Enum::Foo { a: 3, b: 4 };
| ~ ~
help: if `Enum::Foo` is a function, use the arguments directly
|
LL - let x = Enum::Foo(a: 3, b: 4);
LL + let x = Enum::Foo(3, 4);
|

error[E0532]: expected tuple struct or tuple variant, found struct variant `Enum::Foo`
--> $DIR/recover-from-bad-variant.rs:10:9
File renamed without changes.
File renamed without changes.
File renamed without changes.
12 changes: 12 additions & 0 deletions src/test/ui/repr/repr-transparent-issue-87496.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Regression test for the ICE described in #87496.

// check-pass

#[repr(transparent)]
struct TransparentCustomZst(());
extern "C" {
fn good17(p: TransparentCustomZst);
//~^ WARNING: `extern` block uses type `TransparentCustomZst`, which is not FFI-safe
}

fn main() {}
16 changes: 16 additions & 0 deletions src/test/ui/repr/repr-transparent-issue-87496.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
warning: `extern` block uses type `TransparentCustomZst`, which is not FFI-safe
--> $DIR/repr-transparent-issue-87496.rs:8:18
|
LL | fn good17(p: TransparentCustomZst);
| ^^^^^^^^^^^^^^^^^^^^ not FFI-safe
|
= note: `#[warn(improper_ctypes)]` on by default
= note: this struct contains only zero-sized fields
note: the type is defined here
--> $DIR/repr-transparent-issue-87496.rs:6:1
|
LL | struct TransparentCustomZst(());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

warning: 1 warning emitted

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -4,8 +4,6 @@ error[E0038]: the trait `Trait` cannot be made into an object
LL | fn bar(x: &dyn Trait) {}
| ^^^^^^^^^ `Trait` cannot be made into an object
|
= help: consider moving `baz` to another trait
= help: consider moving `bat` to another trait
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/object-unsafe-trait-references-self.rs:2:22
|
@@ -15,6 +13,8 @@ LL | fn baz(&self, _: Self) {}
| ^^^^ ...because method `baz` references the `Self` type in this parameter
LL | fn bat(&self) -> Self {}
| ^^^^ ...because method `bat` references the `Self` type in its return type
= help: consider moving `baz` to another trait
= help: consider moving `bat` to another trait

error[E0038]: the trait `Other` cannot be made into an object
--> $DIR/object-unsafe-trait-references-self.rs:10:12
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions src/test/ui/traits/item-privacy.stderr
Original file line number Diff line number Diff line change
@@ -127,9 +127,6 @@ error[E0038]: the trait `assoc_const::C` cannot be made into an object
LL | <dyn C>::A;
| ^^^^^ `assoc_const::C` cannot be made into an object
|
= help: consider moving `C` to another trait
= help: consider moving `B` to another trait
= help: consider moving `A` to another trait
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/item-privacy.rs:25:15
|
@@ -143,6 +140,9 @@ LL | pub trait C: A + B {
| - this trait cannot be made into an object...
LL | const C: u8 = 0;
| ^ ...because it contains this associated `const`
= help: consider moving `C` to another trait
= help: consider moving `A` to another trait
= help: consider moving `B` to another trait

error[E0223]: ambiguous associated type
--> $DIR/item-privacy.rs:115:12
8 changes: 4 additions & 4 deletions src/test/ui/traits/test-2.stderr
Original file line number Diff line number Diff line change
@@ -32,8 +32,6 @@ error[E0038]: the trait `bar` cannot be made into an object
LL | (box 10 as Box<dyn bar>).dup();
| ^^^^^^^^^^^^ `bar` cannot be made into an object
|
= help: consider moving `dup` to another trait
= help: consider moving `blah` to another trait
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/test-2.rs:4:30
|
@@ -42,15 +40,15 @@ LL | trait bar { fn dup(&self) -> Self; fn blah<X>(&self); }
| | |
| | ...because method `dup` references the `Self` type in its return type
| this trait cannot be made into an object...
= help: consider moving `dup` to another trait
= help: consider moving `blah` to another trait

error[E0038]: the trait `bar` cannot be made into an object
--> $DIR/test-2.rs:13:6
|
LL | (box 10 as Box<dyn bar>).dup();
| ^^^^^^ `bar` cannot be made into an object
|
= help: consider moving `dup` to another trait
= help: consider moving `blah` to another trait
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/test-2.rs:4:30
|
@@ -59,6 +57,8 @@ LL | trait bar { fn dup(&self) -> Self; fn blah<X>(&self); }
| | |
| | ...because method `dup` references the `Self` type in its return type
| this trait cannot be made into an object...
= help: consider moving `dup` to another trait
= help: consider moving `blah` to another trait
= note: required because of the requirements on the impl of `CoerceUnsized<Box<dyn bar>>` for `Box<{integer}>`
= note: required by cast to type `Box<dyn bar>`

Original file line number Diff line number Diff line change
@@ -16,14 +16,14 @@ error[E0038]: the trait `MyAdd` cannot be made into an object
LL | let y = x as dyn MyAdd<i32>;
| ^^^^^^^^^^^^^^ `MyAdd` cannot be made into an object
|
= help: consider moving `add` to another trait
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/type-parameter-defaults-referencing-Self-ppaux.rs:6:55
|
LL | trait MyAdd<Rhs=Self> { fn add(&self, other: &Rhs) -> Self; }
| ----- ^^^^ ...because method `add` references the `Self` type in its return type
| |
| this trait cannot be made into an object...
= help: consider moving `add` to another trait

error: aborting due to 2 previous errors

2 changes: 1 addition & 1 deletion src/test/ui/wf/issue-87495.stderr
Original file line number Diff line number Diff line change
@@ -4,14 +4,14 @@ error[E0038]: the trait `T` cannot be made into an object
LL | const CONST: (bool, dyn T);
| ^^^^^ `T` cannot be made into an object
|
= help: consider moving `CONST` to another trait
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/issue-87495.rs:4:11
|
LL | trait T {
| - this trait cannot be made into an object...
LL | const CONST: (bool, dyn T);
| ^^^^^ ...because it contains this associated `const`
= help: consider moving `CONST` to another trait

error: aborting due to previous error

2 changes: 1 addition & 1 deletion src/test/ui/wf/wf-object-safe.stderr
Original file line number Diff line number Diff line change
@@ -4,14 +4,14 @@ error[E0038]: the trait `A` cannot be made into an object
LL | let _x: &dyn A;
| ^^^^^^ `A` cannot be made into an object
|
= help: consider moving `foo` to another trait
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/wf-object-safe.rs:5:23
|
LL | trait A {
| - this trait cannot be made into an object...
LL | fn foo(&self, _x: &Self);
| ^^^^^ ...because method `foo` references the `Self` type in this parameter
= help: consider moving `foo` to another trait

error: aborting due to previous error

4 changes: 2 additions & 2 deletions src/tools/tidy/src/ui_tests.rs
Original file line number Diff line number Diff line change
@@ -7,8 +7,8 @@ use std::path::Path;

const ENTRY_LIMIT: usize = 1000;
// FIXME: The following limits should be reduced eventually.
const ROOT_ENTRY_LIMIT: usize = 1345;
const ISSUES_ENTRY_LIMIT: usize = 2525;
const ROOT_ENTRY_LIMIT: usize = 1330;
const ISSUES_ENTRY_LIMIT: usize = 2488;

fn check_entries(path: &Path, bad: &mut bool) {
let dirs = walkdir::WalkDir::new(&path.join("test/ui"))