Skip to content
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

Rollup of 17 pull requests #106006

Closed
wants to merge 47 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
46f6e39
add assert messages if chunks/windows are length 0
raffimolero Dec 12, 2022
1588944
interpret: add read_machine_[ui]size convenience methods
RalfJung Dec 12, 2022
8b2a7da
Rename `assert_uninit_valid` intrinsic
Noratrieb Dec 12, 2022
7f94389
str.lines() docstring: clarify that line endings are not returned
zacchiro Dec 17, 2022
ee1a905
Fix arch flag on i686-apple-darwin
MarcusCalhoun-Lopez Dec 19, 2022
a213bb3
implement the skeleton of the updated trait solver
lcnr Dec 4, 2022
55c4164
Correct ModFlagBehavior for Aarch64 on LLVM-15
MasterAwesome Dec 20, 2022
750bf36
dedup assembly
lcnr Dec 19, 2022
082ca1e
docs: add long error explanation for error E0472
Ezrashaw Dec 16, 2022
b859b8b
Bump `cfg-if` to `1.0`
ChrisDenton Dec 20, 2022
8b5a96e
Some tracing cleanups
oli-obk Dec 19, 2022
562d846
Make it easier to debug where a region error was created
oli-obk Dec 19, 2022
8b15302
Replace a `find` with a loop to simplify the logic.
oli-obk Dec 19, 2022
e405dab
Some style nits
oli-obk Dec 19, 2022
c9588d5
Hackily fix an opaque type ICE
oli-obk Dec 19, 2022
f1ef038
use `track_caller` to show where the panic is actually from
oli-obk Nov 30, 2022
872a6da
Remove an unused function
oli-obk Oct 6, 2022
c787de3
Fix some `~const` usage in libcore
oli-obk Oct 11, 2022
b0ed631
Some hir cleanups
oli-obk Nov 10, 2022
b2b859b
Some track_caller additions
oli-obk Oct 12, 2022
fedcc73
tracing: make flag checking less noisy
oli-obk Oct 11, 2022
ed61be6
Some ICE debugging aids
oli-obk Sep 21, 2022
168e3da
rustdoc: prevent CSS layout of line numbers shrinking into nothing
notriddle Dec 20, 2022
1c5b53b
Avoid going through the happy path in case of non-fn builtin calls
oli-obk Dec 20, 2022
b29a9e3
rustdoc: simplify section anchor CSS
notriddle Dec 20, 2022
5480ac5
Use `Error` behavior for LLVM versions prior to 15
MasterAwesome Dec 20, 2022
fb89ae4
Remove unused `check-stage2-T-arm-linux-androideabi-H-x86_64-unknown-…
jyn514 Dec 20, 2022
f5e776c
Refer to "Waker" rather than "RawWaker" in `drop` comment
goffrie Dec 20, 2022
5538c92
Fix typo in reading_half_a_pointer.rs
eltociear Dec 21, 2022
6f21ba4
less specific wording
RalfJung Dec 21, 2022
7ce7169
Rollup merge of #105584 - raffimolero:patch-1, r=JohnTitor
fee1-dead Dec 21, 2022
6d12349
Rollup merge of #105602 - RalfJung:read-convenience, r=oli-obk
fee1-dead Dec 21, 2022
944c0f9
Rollup merge of #105613 - Nilstrieb:rename-assert_uninit_valid, r=Ral…
fee1-dead Dec 21, 2022
a6d2e34
Rollup merge of #105661 - lcnr:evaluate-new, r=compiler-errors
fee1-dead Dec 21, 2022
0d92836
Rollup merge of #105791 - Ezrashaw:add-e0472-long-docs, r=GuillaumeGomez
fee1-dead Dec 21, 2022
7bdef9e
Rollup merge of #105824 - zacchiro:patch-1, r=JohnTitor
fee1-dead Dec 21, 2022
a270e40
Rollup merge of #105897 - oli-obk:tait_patterns, r=TaKO8Ki
fee1-dead Dec 21, 2022
0e25271
Rollup merge of #105904 - MarcusCalhoun-Lopez:darwin_arch_i386, r=bjorn3
fee1-dead Dec 21, 2022
a8e3c7f
Rollup merge of #105932 - MasterAwesome:aarch64-bti-llvm-15, r=nikic
fee1-dead Dec 21, 2022
6bc6dcb
Rollup merge of #105949 - ChrisDenton:bump-cfg-if, r=Nilstrieb
fee1-dead Dec 21, 2022
4f90c56
Rollup merge of #105960 - oli-obk:effect_cleanup, r=fee1-dead
fee1-dead Dec 21, 2022
a9047a1
Rollup merge of #105964 - notriddle:notriddle/scraped-example-length,…
fee1-dead Dec 21, 2022
4cfdd16
Rollup merge of #105972 - notriddle:notriddle/anchor, r=GuillaumeGomez
fee1-dead Dec 21, 2022
e20a166
Rollup merge of #105973 - oli-obk:simplify_callee_checks, r=jackh726
fee1-dead Dec 21, 2022
3ca1bb0
Rollup merge of #105976 - jyn514:unused-make-targets, r=Mark-Simulacrum
fee1-dead Dec 21, 2022
200ddcb
Rollup merge of #105980 - goffrie:waker-drop, r=thomcc
fee1-dead Dec 21, 2022
3f51a54
Rollup merge of #105986 - eltociear:patch-18, r=RalfJung
fee1-dead Dec 21, 2022
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
4 changes: 2 additions & 2 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3590,7 +3590,7 @@ version = "0.0.0"
dependencies = [
"arrayvec",
"bitflags",
"cfg-if 0.1.10",
"cfg-if 1.0.0",
"ena",
"indexmap",
"jobserver",
Expand Down Expand Up @@ -4374,7 +4374,7 @@ dependencies = [
name = "rustc_span"
version = "0.0.0"
dependencies = [
"cfg-if 0.1.10",
"cfg-if 1.0.0",
"md-5",
"rustc_arena",
"rustc_data_structures",
Expand Down
24 changes: 21 additions & 3 deletions compiler/rustc_borrowck/src/diagnostics/region_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ use rustc_infer::infer::{
use rustc_middle::hir::place::PlaceBase;
use rustc_middle::mir::{ConstraintCategory, ReturnConstraint};
use rustc_middle::ty::subst::InternalSubsts;
use rustc_middle::ty::Region;
use rustc_middle::ty::TypeVisitor;
use rustc_middle::ty::{self, RegionVid, Ty};
use rustc_middle::ty::{Region, TyCtxt};
use rustc_span::symbol::{kw, Ident};
use rustc_span::Span;
use rustc_span::{Span, DUMMY_SP};

use crate::borrowck_errors;
use crate::session_diagnostics::{
Expand Down Expand Up @@ -70,7 +70,25 @@ impl<'tcx> ConstraintDescription for ConstraintCategory<'tcx> {
///
/// Usually we expect this to either be empty or contain a small number of items, so we can avoid
/// allocation most of the time.
pub(crate) type RegionErrors<'tcx> = Vec<RegionErrorKind<'tcx>>;
pub(crate) struct RegionErrors<'tcx>(Vec<RegionErrorKind<'tcx>>, TyCtxt<'tcx>);

impl<'tcx> RegionErrors<'tcx> {
pub fn new(tcx: TyCtxt<'tcx>) -> Self {
Self(vec![], tcx)
}
#[track_caller]
pub fn push(&mut self, val: impl Into<RegionErrorKind<'tcx>>) {
let val = val.into();
self.1.sess.delay_span_bug(DUMMY_SP, "{val:?}");
self.0.push(val);
}
pub fn is_empty(&self) -> bool {
self.0.is_empty()
}
pub fn into_iter(self) -> impl Iterator<Item = RegionErrorKind<'tcx>> {
self.0.into_iter()
}
}

#[derive(Clone, Debug)]
pub(crate) enum RegionErrorKind<'tcx> {
Expand Down
43 changes: 23 additions & 20 deletions compiler/rustc_borrowck/src/region_infer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
let mir_def_id = body.source.def_id();
self.propagate_constraints(body);

let mut errors_buffer = RegionErrors::new();
let mut errors_buffer = RegionErrors::new(infcx.tcx);

// If this is a closure, we can propagate unsatisfied
// `outlives_requirements` to our creator, so create a vector
Expand Down Expand Up @@ -1647,26 +1647,29 @@ impl<'tcx> RegionInferenceContext<'tcx> {
let longer_fr_scc = self.constraint_sccs.scc(longer_fr);
debug!("check_bound_universal_region: longer_fr_scc={:?}", longer_fr_scc,);

// If we have some bound universal region `'a`, then the only
// elements it can contain is itself -- we don't know anything
// else about it!
let Some(error_element) = ({
self.scc_values.elements_contained_in(longer_fr_scc).find(|element| match element {
RegionElement::Location(_) => true,
RegionElement::RootUniversalRegion(_) => true,
RegionElement::PlaceholderRegion(placeholder1) => placeholder != *placeholder1,
})
}) else {
return;
};
debug!("check_bound_universal_region: error_element = {:?}", error_element);
for error_element in self.scc_values.elements_contained_in(longer_fr_scc) {
match error_element {
RegionElement::Location(_) | RegionElement::RootUniversalRegion(_) => {}
// If we have some bound universal region `'a`, then the only
// elements it can contain is itself -- we don't know anything
// else about it!
RegionElement::PlaceholderRegion(placeholder1) => {
if placeholder == placeholder1 {
continue;
}
}
}

// Find the region that introduced this `error_element`.
errors_buffer.push(RegionErrorKind::BoundUniversalRegionError {
longer_fr,
error_element,
placeholder,
});
errors_buffer.push(RegionErrorKind::BoundUniversalRegionError {
longer_fr,
error_element,
placeholder,
});

// Stop after the first error, it gets too noisy otherwise, and does not provide more information.
break;
}
debug!("check_bound_universal_region: all bounds satisfied");
}

#[instrument(level = "debug", skip(self, infcx, errors_buffer))]
Expand Down
14 changes: 9 additions & 5 deletions compiler/rustc_borrowck/src/type_check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1153,27 +1153,31 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
category: ConstraintCategory<'tcx>,
) -> Fallible<()> {
let annotated_type = self.user_type_annotations[user_ty.base].inferred_ty;
trace!(?annotated_type);
let mut curr_projected_ty = PlaceTy::from_ty(annotated_type);

let tcx = self.infcx.tcx;

for proj in &user_ty.projs {
if let ty::Alias(ty::Opaque, ..) = curr_projected_ty.ty.kind() {
// There is nothing that we can compare here if we go through an opaque type.
// We're always in its defining scope as we can otherwise not project through
// it, so we're constraining it anyways.
return Ok(());
}
let projected_ty = curr_projected_ty.projection_ty_core(
tcx,
self.param_env,
proj,
|this, field, _| {
|this, field, ()| {
let ty = this.field_ty(tcx, field);
self.normalize(ty, locations)
},
|_, _| unreachable!(),
);
curr_projected_ty = projected_ty;
}
debug!(
"user_ty base: {:?} freshened: {:?} projs: {:?} yields: {:?}",
user_ty.base, annotated_type, user_ty.projs, curr_projected_ty
);
trace!(?curr_projected_ty);

let ty = curr_projected_ty.ty;
self.relate_types(ty, v.xform(ty::Variance::Contravariant), a, locations, category)?;
Expand Down
6 changes: 4 additions & 2 deletions compiler/rustc_codegen_cranelift/src/intrinsics/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
let res = CValue::by_val(res, arg.layout());
ret.write_cvalue(fx, res);
}
sym::assert_inhabited | sym::assert_zero_valid | sym::assert_uninit_valid => {
sym::assert_inhabited | sym::assert_zero_valid | sym::assert_mem_uninitialized_valid => {
intrinsic_args!(fx, args => (); intrinsic);

let layout = fx.layout_of(substs.type_at(0));
Expand Down Expand Up @@ -673,7 +673,9 @@ fn codegen_regular_intrinsic_call<'tcx>(
return;
}

if intrinsic == sym::assert_uninit_valid && !fx.tcx.permits_uninit_init(layout) {
if intrinsic == sym::assert_mem_uninitialized_valid
&& !fx.tcx.permits_uninit_init(layout)
{
with_no_trimmed_paths!({
crate::base::codegen_panic(
fx,
Expand Down
14 changes: 10 additions & 4 deletions compiler/rustc_codegen_llvm/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -280,29 +280,35 @@ pub unsafe fn create_module<'ll>(
}

if let Some(BranchProtection { bti, pac_ret }) = sess.opts.unstable_opts.branch_protection {
let behavior = if llvm_version >= (15, 0, 0) {
llvm::LLVMModFlagBehavior::Min
} else {
llvm::LLVMModFlagBehavior::Error
};

if sess.target.arch == "aarch64" {
llvm::LLVMRustAddModuleFlag(
llmod,
llvm::LLVMModFlagBehavior::Error,
behavior,
"branch-target-enforcement\0".as_ptr().cast(),
bti.into(),
);
llvm::LLVMRustAddModuleFlag(
llmod,
llvm::LLVMModFlagBehavior::Error,
behavior,
"sign-return-address\0".as_ptr().cast(),
pac_ret.is_some().into(),
);
let pac_opts = pac_ret.unwrap_or(PacRet { leaf: false, key: PAuthKey::A });
llvm::LLVMRustAddModuleFlag(
llmod,
llvm::LLVMModFlagBehavior::Error,
behavior,
"sign-return-address-all\0".as_ptr().cast(),
pac_opts.leaf.into(),
);
llvm::LLVMRustAddModuleFlag(
llmod,
llvm::LLVMModFlagBehavior::Error,
behavior,
"sign-return-address-with-bkey\0".as_ptr().cast(),
u32::from(pac_opts.key == PAuthKey::B),
);
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_codegen_llvm/src/llvm/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ pub enum LLVMModFlagBehavior {
Append = 5,
AppendUnique = 6,
Max = 7,
Min = 8,
}

// Consts for the LLVM CallConv type, pre-cast to usize.
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_codegen_ssa/src/mir/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -663,12 +663,12 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
enum AssertIntrinsic {
Inhabited,
ZeroValid,
UninitValid,
MemUninitializedValid,
}
let panic_intrinsic = intrinsic.and_then(|i| match i {
sym::assert_inhabited => Some(AssertIntrinsic::Inhabited),
sym::assert_zero_valid => Some(AssertIntrinsic::ZeroValid),
sym::assert_uninit_valid => Some(AssertIntrinsic::UninitValid),
sym::assert_mem_uninitialized_valid => Some(AssertIntrinsic::MemUninitializedValid),
_ => None,
});
if let Some(intrinsic) = panic_intrinsic {
Expand All @@ -679,7 +679,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
let do_panic = match intrinsic {
Inhabited => layout.abi.is_uninhabited(),
ZeroValid => !bx.tcx().permits_zero_init(layout),
UninitValid => !bx.tcx().permits_uninit_init(layout),
MemUninitializedValid => !bx.tcx().permits_uninit_init(layout),
};
Some(if do_panic {
let msg_str = with_no_visible_paths!({
Expand Down
14 changes: 8 additions & 6 deletions compiler/rustc_const_eval/src/interpret/intrinsics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -303,15 +303,15 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
}
sym::offset => {
let ptr = self.read_pointer(&args[0])?;
let offset_count = self.read_scalar(&args[1])?.to_machine_isize(self)?;
let offset_count = self.read_machine_isize(&args[1])?;
let pointee_ty = substs.type_at(0);

let offset_ptr = self.ptr_offset_inbounds(ptr, pointee_ty, offset_count)?;
self.write_pointer(offset_ptr, dest)?;
}
sym::arith_offset => {
let ptr = self.read_pointer(&args[0])?;
let offset_count = self.read_scalar(&args[1])?.to_machine_isize(self)?;
let offset_count = self.read_machine_isize(&args[1])?;
let pointee_ty = substs.type_at(0);

let pointee_size = i64::try_from(self.layout_of(pointee_ty)?.size.bytes()).unwrap();
Expand Down Expand Up @@ -428,7 +428,9 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
sym::transmute => {
self.copy_op(&args[0], dest, /*allow_transmute*/ true)?;
}
sym::assert_inhabited | sym::assert_zero_valid | sym::assert_uninit_valid => {
sym::assert_inhabited
| sym::assert_zero_valid
| sym::assert_mem_uninitialized_valid => {
let ty = instance.substs.type_at(0);
let layout = self.layout_of(ty)?;

Expand Down Expand Up @@ -460,7 +462,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
}
}

if intrinsic_name == sym::assert_uninit_valid {
if intrinsic_name == sym::assert_mem_uninitialized_valid {
let should_panic = !self.tcx.permits_uninit_init(layout);

if should_panic {
Expand Down Expand Up @@ -668,7 +670,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
count: &OpTy<'tcx, <M as Machine<'mir, 'tcx>>::Provenance>,
nonoverlapping: bool,
) -> InterpResult<'tcx> {
let count = self.read_scalar(&count)?.to_machine_usize(self)?;
let count = self.read_machine_usize(&count)?;
let layout = self.layout_of(src.layout.ty.builtin_deref(true).unwrap().ty)?;
let (size, align) = (layout.size, layout.align.abi);
// `checked_mul` enforces a too small bound (the correct one would probably be machine_isize_max),
Expand Down Expand Up @@ -696,7 +698,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {

let dst = self.read_pointer(&dst)?;
let byte = self.read_scalar(&byte)?.to_u8()?;
let count = self.read_scalar(&count)?.to_machine_usize(self)?;
let count = self.read_machine_usize(&count)?;

// `checked_mul` enforces a too small bound (the correct one would probably be machine_isize_max),
// but no actual allocation can be big enough for the difference to be noticeable.
Expand Down
11 changes: 11 additions & 0 deletions compiler/rustc_const_eval/src/interpret/operand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -404,13 +404,24 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
Ok(self.read_immediate(op)?.to_scalar())
}

// Pointer-sized reads are fairly common and need target layout access, so we wrap them in
// convenience functions.

/// Read a pointer from a place.
pub fn read_pointer(
&self,
op: &OpTy<'tcx, M::Provenance>,
) -> InterpResult<'tcx, Pointer<Option<M::Provenance>>> {
self.read_scalar(op)?.to_pointer(self)
}
/// Read a pointer-sized unsigned integer from a place.
pub fn read_machine_usize(&self, op: &OpTy<'tcx, M::Provenance>) -> InterpResult<'tcx, u64> {
self.read_scalar(op)?.to_machine_usize(self)
}
/// Read a pointer-sized signed integer from a place.
pub fn read_machine_isize(&self, op: &OpTy<'tcx, M::Provenance>) -> InterpResult<'tcx, i64> {
self.read_scalar(op)?.to_machine_isize(self)
}

/// Turn the wide MPlace into a string (must already be dereferenced!)
pub fn read_str(&self, mplace: &MPlaceTy<'tcx, M::Provenance>) -> InterpResult<'tcx, &str> {
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_const_eval/src/interpret/projection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ where
Index(local) => {
let layout = self.layout_of(self.tcx.types.usize)?;
let n = self.local_to_op(self.frame(), local, Some(layout))?;
let n = self.read_scalar(&n)?.to_machine_usize(self)?;
let n = self.read_machine_usize(&n)?;
self.place_index(base, n)?
}
ConstantIndex { offset, min_length, from_end } => {
Expand Down Expand Up @@ -392,7 +392,7 @@ where
Index(local) => {
let layout = self.layout_of(self.tcx.types.usize)?;
let n = self.local_to_op(self.frame(), local, Some(layout))?;
let n = self.read_scalar(&n)?.to_machine_usize(self)?;
let n = self.read_machine_usize(&n)?;
self.operand_index(base, n)?
}
ConstantIndex { offset, min_length, from_end } => {
Expand Down
8 changes: 6 additions & 2 deletions compiler/rustc_data_structures/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ edition = "2021"
[dependencies]
arrayvec = { version = "0.7", default-features = false }
bitflags = "1.2.1"
cfg-if = "0.1.2"
cfg-if = "1.0"
ena = "0.14"
indexmap = { version = "1.9.1" }
jobserver_crate = { version = "0.1.13", package = "jobserver" }
Expand All @@ -21,7 +21,11 @@ rustc-hash = "1.1.0"
rustc_index = { path = "../rustc_index", package = "rustc_index" }
rustc_macros = { path = "../rustc_macros" }
rustc_serialize = { path = "../rustc_serialize" }
smallvec = { version = "1.8.1", features = ["const_generics", "union", "may_dangle"] }
smallvec = { version = "1.8.1", features = [
"const_generics",
"union",
"may_dangle",
] }
stable_deref_trait = "1.0.0"
stacker = "0.1.15"
tempfile = "3.2"
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_error_codes/src/error_codes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ E0464: include_str!("./error_codes/E0464.md"),
E0466: include_str!("./error_codes/E0466.md"),
E0468: include_str!("./error_codes/E0468.md"),
E0469: include_str!("./error_codes/E0469.md"),
E0472: include_str!("./error_codes/E0472.md"),
E0477: include_str!("./error_codes/E0477.md"),
E0478: include_str!("./error_codes/E0478.md"),
E0482: include_str!("./error_codes/E0482.md"),
Expand Down Expand Up @@ -599,7 +600,6 @@ E0791: include_str!("./error_codes/E0791.md"),
// E0467, // removed
// E0470, // removed
// E0471, // constant evaluation error (in pattern)
E0472, // llvm_asm! is unsupported on this target
// E0473, // dereference of reference outside its lifetime
// E0474, // captured variable `..` does not outlive the enclosing closure
// E0475, // index of slice outside its lifetime
Expand Down
Loading