Skip to content

Commit 5641481

Browse files
committed
Auto merge of #89629 - GuillaumeGomez:rollup-s4r8me6, r=GuillaumeGomez
Rollup of 7 pull requests Successful merges: - #89298 (Issue 89193 - Fix ICE when using `usize` and `isize` with SIMD gathers ) - #89461 (Add `deref_into_dyn_supertrait` lint.) - #89477 (Move items related to computing diffs to a separate file) - #89559 (RustWrapper: adapt for LLVM API change) - #89585 (Emit item no type error even if type inference fails) - #89596 (Make cfg imply doc(cfg)) - #89615 (Add InferCtxt::with_opaque_type_inference to get_body_with_borrowck_facts) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 0157cc9 + 0fbb011 commit 5641481

File tree

45 files changed

+730
-193
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+730
-193
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4454,6 +4454,7 @@ dependencies = [
44544454
"rustc_hir",
44554455
"rustc_index",
44564456
"rustc_infer",
4457+
"rustc_lint_defs",
44574458
"rustc_macros",
44584459
"rustc_middle",
44594460
"rustc_parse_format",

compiler/rustc_ast_passes/src/feature_gate.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,7 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
279279

280280
gate_doc!(
281281
cfg => doc_cfg
282+
cfg_hide => doc_cfg_hide
282283
masked => doc_masked
283284
notable_trait => doc_notable_trait
284285
keyword => doc_keyword

compiler/rustc_borrowck/src/consumers.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ pub fn get_body_with_borrowck_facts<'tcx>(
3131
def: ty::WithOptConstParam<LocalDefId>,
3232
) -> BodyWithBorrowckFacts<'tcx> {
3333
let (input_body, promoted) = tcx.mir_promoted(def);
34-
tcx.infer_ctxt().enter(|infcx| {
34+
tcx.infer_ctxt().with_opaque_type_inference(def.did).enter(|infcx| {
3535
let input_body: &Body<'_> = &input_body.borrow();
3636
let promoted: &IndexVec<_, _> = &promoted.borrow();
3737
*super::do_mir_borrowck(&infcx, input_body, promoted, true).1.unwrap()

compiler/rustc_codegen_llvm/src/intrinsic.rs

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use rustc_middle::ty::{self, Ty};
2020
use rustc_middle::{bug, span_bug};
2121
use rustc_span::{sym, symbol::kw, Span, Symbol};
2222
use rustc_target::abi::{self, HasDataLayout, Primitive};
23-
use rustc_target::spec::PanicStrategy;
23+
use rustc_target::spec::{HasTargetSpec, PanicStrategy};
2424

2525
use std::cmp::Ordering;
2626
use std::iter;
@@ -1190,11 +1190,28 @@ fn generic_simd_intrinsic(
11901190
// FIXME: use:
11911191
// https://github.com/llvm-mirror/llvm/blob/master/include/llvm/IR/Function.h#L182
11921192
// https://github.com/llvm-mirror/llvm/blob/master/include/llvm/IR/Intrinsics.h#L81
1193-
fn llvm_vector_str(elem_ty: Ty<'_>, vec_len: u64, no_pointers: usize) -> String {
1193+
fn llvm_vector_str(
1194+
elem_ty: Ty<'_>,
1195+
vec_len: u64,
1196+
no_pointers: usize,
1197+
bx: &Builder<'a, 'll, 'tcx>,
1198+
) -> String {
11941199
let p0s: String = "p0".repeat(no_pointers);
11951200
match *elem_ty.kind() {
1196-
ty::Int(v) => format!("v{}{}i{}", vec_len, p0s, v.bit_width().unwrap()),
1197-
ty::Uint(v) => format!("v{}{}i{}", vec_len, p0s, v.bit_width().unwrap()),
1201+
ty::Int(v) => format!(
1202+
"v{}{}i{}",
1203+
vec_len,
1204+
p0s,
1205+
// Normalize to prevent crash if v: IntTy::Isize
1206+
v.normalize(bx.target_spec().pointer_width).bit_width().unwrap()
1207+
),
1208+
ty::Uint(v) => format!(
1209+
"v{}{}i{}",
1210+
vec_len,
1211+
p0s,
1212+
// Normalize to prevent crash if v: UIntTy::Usize
1213+
v.normalize(bx.target_spec().pointer_width).bit_width().unwrap()
1214+
),
11981215
ty::Float(v) => format!("v{}{}f{}", vec_len, p0s, v.bit_width()),
11991216
_ => unreachable!(),
12001217
}
@@ -1330,11 +1347,11 @@ fn generic_simd_intrinsic(
13301347

13311348
// Type of the vector of pointers:
13321349
let llvm_pointer_vec_ty = llvm_vector_ty(bx, underlying_ty, in_len, pointer_count);
1333-
let llvm_pointer_vec_str = llvm_vector_str(underlying_ty, in_len, pointer_count);
1350+
let llvm_pointer_vec_str = llvm_vector_str(underlying_ty, in_len, pointer_count, bx);
13341351

13351352
// Type of the vector of elements:
13361353
let llvm_elem_vec_ty = llvm_vector_ty(bx, underlying_ty, in_len, pointer_count - 1);
1337-
let llvm_elem_vec_str = llvm_vector_str(underlying_ty, in_len, pointer_count - 1);
1354+
let llvm_elem_vec_str = llvm_vector_str(underlying_ty, in_len, pointer_count - 1, bx);
13381355

13391356
let llvm_intrinsic =
13401357
format!("llvm.masked.gather.{}.{}", llvm_elem_vec_str, llvm_pointer_vec_str);
@@ -1458,11 +1475,11 @@ fn generic_simd_intrinsic(
14581475

14591476
// Type of the vector of pointers:
14601477
let llvm_pointer_vec_ty = llvm_vector_ty(bx, underlying_ty, in_len, pointer_count);
1461-
let llvm_pointer_vec_str = llvm_vector_str(underlying_ty, in_len, pointer_count);
1478+
let llvm_pointer_vec_str = llvm_vector_str(underlying_ty, in_len, pointer_count, bx);
14621479

14631480
// Type of the vector of elements:
14641481
let llvm_elem_vec_ty = llvm_vector_ty(bx, underlying_ty, in_len, pointer_count - 1);
1465-
let llvm_elem_vec_str = llvm_vector_str(underlying_ty, in_len, pointer_count - 1);
1482+
let llvm_elem_vec_str = llvm_vector_str(underlying_ty, in_len, pointer_count - 1, bx);
14661483

14671484
let llvm_intrinsic =
14681485
format!("llvm.masked.scatter.{}.{}", llvm_elem_vec_str, llvm_pointer_vec_str);

compiler/rustc_feature/src/active.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -675,6 +675,9 @@ declare_features! (
675675
/// Allows `#[track_caller]` on closures and generators.
676676
(active, closure_track_caller, "1.57.0", Some(87417), None),
677677

678+
/// Allows `#[doc(cfg_hide(...))]`.
679+
(active, doc_cfg_hide, "1.57.0", Some(43781), None),
680+
678681
// -------------------------------------------------------------------------
679682
// feature-group-end: actual feature gates
680683
// -------------------------------------------------------------------------

compiler/rustc_lint_defs/src/builtin.rs

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3051,6 +3051,7 @@ declare_lint_pass! {
30513051
BREAK_WITH_LABEL_AND_LOOP,
30523052
UNUSED_ATTRIBUTES,
30533053
NON_EXHAUSTIVE_OMITTED_PATTERNS,
3054+
DEREF_INTO_DYN_SUPERTRAIT,
30543055
]
30553056
}
30563057

@@ -3512,3 +3513,48 @@ declare_lint! {
35123513
Allow,
35133514
"detect when patterns of types marked `non_exhaustive` are missed",
35143515
}
3516+
3517+
declare_lint! {
3518+
/// The `deref_into_dyn_supertrait` lint is output whenever there is a use of the
3519+
/// `Deref` implementation with a `dyn SuperTrait` type as `Output`.
3520+
///
3521+
/// These implementations will become shadowed when the `trait_upcasting` feature is stablized.
3522+
/// The `deref` functions will no longer be called implicitly, so there might be behavior change.
3523+
///
3524+
/// ### Example
3525+
///
3526+
/// ```rust,compile_fail
3527+
/// #![deny(deref_into_dyn_supertrait)]
3528+
/// #![allow(dead_code)]
3529+
///
3530+
/// use core::ops::Deref;
3531+
///
3532+
/// trait A {}
3533+
/// trait B: A {}
3534+
/// impl<'a> Deref for dyn 'a + B {
3535+
/// type Target = dyn A;
3536+
/// fn deref(&self) -> &Self::Target {
3537+
/// todo!()
3538+
/// }
3539+
/// }
3540+
///
3541+
/// fn take_a(_: &dyn A) { }
3542+
///
3543+
/// fn take_b(b: &dyn B) {
3544+
/// take_a(b);
3545+
/// }
3546+
/// ```
3547+
///
3548+
/// {{produces}}
3549+
///
3550+
/// ### Explanation
3551+
///
3552+
/// The dyn upcasting coercion feature adds new coercion rules, taking priority
3553+
/// over certain other coercion rules, which will cause some behavior change.
3554+
pub DEREF_INTO_DYN_SUPERTRAIT,
3555+
Warn,
3556+
"`Deref` implementation usage with a supertrait trait object for output might be shadowed in the future",
3557+
@future_incompatible = FutureIncompatibleInfo {
3558+
reference: "issue #89460 <https://github.com/rust-lang/rust/issues/89460>",
3559+
};
3560+
}

compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,11 @@ static LLVM_THREAD_LOCAL char *LastError;
5454
//
5555
// Notably it exits the process with code 101, unlike LLVM's default of 1.
5656
static void FatalErrorHandler(void *UserData,
57+
#if LLVM_VERSION_LT(14, 0)
5758
const std::string& Reason,
59+
#else
60+
const char* Reason,
61+
#endif
5862
bool GenCrashDiag) {
5963
// Do the same thing that the default error handler does.
6064
std::cerr << "LLVM ERROR: " << Reason << std::endl;

compiler/rustc_passes/src/check_attr.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -938,6 +938,7 @@ impl CheckAttrVisitor<'tcx> {
938938
// plugins: removed, but rustdoc warns about it itself
939939
sym::alias
940940
| sym::cfg
941+
| sym::cfg_hide
941942
| sym::hidden
942943
| sym::html_favicon_url
943944
| sym::html_logo_url

compiler/rustc_span/src/symbol.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,7 @@ symbols! {
399399
cfg_attr_multi,
400400
cfg_doctest,
401401
cfg_eval,
402+
cfg_hide,
402403
cfg_panic,
403404
cfg_sanitize,
404405
cfg_target_abi,
@@ -547,6 +548,7 @@ symbols! {
547548
doc,
548549
doc_alias,
549550
doc_cfg,
551+
doc_cfg_hide,
550552
doc_keyword,
551553
doc_masked,
552554
doc_notable_trait,

compiler/rustc_trait_selection/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ rustc_errors = { path = "../rustc_errors" }
1717
rustc_hir = { path = "../rustc_hir" }
1818
rustc_index = { path = "../rustc_index" }
1919
rustc_infer = { path = "../rustc_infer" }
20+
rustc_lint_defs = { path = "../rustc_lint_defs" }
2021
rustc_macros = { path = "../rustc_macros" }
2122
rustc_query_system = { path = "../rustc_query_system" }
2223
rustc_session = { path = "../rustc_session" }

0 commit comments

Comments
 (0)