1
Fork 0

Auto merge of #109497 - matthiaskrgr:rollup-6txuxm0, r=matthiaskrgr

Rollup of 10 pull requests

Successful merges:

 - #109373 (Set LLVM `LLVM_UNREACHABLE_OPTIMIZE` to `OFF`)
 - #109392 (Custom MIR: Allow optional RET type annotation)
 - #109394 (adapt tests/codegen/vec-shrink-panik for LLVM 17)
 - #109412 (rustdoc: Add GUI test for "Auto-hide item contents for large items" setting)
 - #109452 (Ignore the vendor directory for tidy tests.)
 - #109457 (Remove comment about reusing rib allocations)
 - #109461 (rustdoc: remove redundant `.content` prefix from span/a colors)
 - #109477 (`HirId` to `LocalDefId` cleanup)
 - #109489 (More general captures)
 - #109494 (Do not feed param_env for RPITITs impl side)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
This commit is contained in:
bors 2023-03-22 21:35:02 +00:00
commit 8859fde21f
21 changed files with 153 additions and 54 deletions

View file

@ -424,7 +424,7 @@ pub(crate) fn global_llvm_features(sess: &Session, diagnostics: bool) -> Vec<Str
.filter_map(|s| { .filter_map(|s| {
let enable_disable = match s.chars().next() { let enable_disable = match s.chars().next() {
None => return None, None => return None,
Some(c @ '+' | c @ '-') => c, Some(c @ ('+' | '-')) => c,
Some(_) => { Some(_) => {
if diagnostics { if diagnostics {
sess.emit_warning(UnknownCTargetFeaturePrefix { feature: s }); sess.emit_warning(UnknownCTargetFeaturePrefix { feature: s });

View file

@ -1208,7 +1208,7 @@ fn infer_return_ty_for_fn_sig<'tcx>(
fn_sig, fn_sig,
Applicability::MachineApplicable, Applicability::MachineApplicable,
); );
} else if let Some(sugg) = suggest_impl_trait(tcx, ret_ty, ty.span, hir_id, def_id) { } else if let Some(sugg) = suggest_impl_trait(tcx, ret_ty, ty.span, def_id) {
diag.span_suggestion( diag.span_suggestion(
ty.span, ty.span,
"replace with an appropriate return type", "replace with an appropriate return type",
@ -1240,12 +1240,10 @@ fn infer_return_ty_for_fn_sig<'tcx>(
} }
} }
// FIXME(vincenzopalazzo): remove the hir item when the refactoring is stable
fn suggest_impl_trait<'tcx>( fn suggest_impl_trait<'tcx>(
tcx: TyCtxt<'tcx>, tcx: TyCtxt<'tcx>,
ret_ty: Ty<'tcx>, ret_ty: Ty<'tcx>,
span: Span, span: Span,
_hir_id: hir::HirId,
def_id: LocalDefId, def_id: LocalDefId,
) -> Option<String> { ) -> Option<String> {
let format_as_assoc: fn(_, _, _, _, _) -> _ = let format_as_assoc: fn(_, _, _, _, _) -> _ =

View file

@ -231,7 +231,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
let ty = ensure_sufficient_stack(|| match &expr.kind { let ty = ensure_sufficient_stack(|| match &expr.kind {
hir::ExprKind::Path( hir::ExprKind::Path(
qpath @ hir::QPath::Resolved(..) | qpath @ hir::QPath::TypeRelative(..), qpath @ (hir::QPath::Resolved(..) | hir::QPath::TypeRelative(..)),
) => self.check_expr_path(qpath, expr, args), ) => self.check_expr_path(qpath, expr, args),
_ => self.check_expr_kind(expr, expected), _ => self.check_expr_kind(expr, expected),
}); });

View file

@ -165,8 +165,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
&self, &self,
ty: Ty<'tcx>, ty: Ty<'tcx>,
) -> Option<(DefIdOrName, Ty<'tcx>, Vec<Ty<'tcx>>)> { ) -> Option<(DefIdOrName, Ty<'tcx>, Vec<Ty<'tcx>>)> {
let body_hir_id = self.tcx.hir().local_def_id_to_hir_id(self.body_id); self.err_ctxt().extract_callable_info(self.body_id, self.param_env, ty)
self.err_ctxt().extract_callable_info(body_hir_id, self.param_env, ty)
} }
pub fn suggest_two_fn_call( pub fn suggest_two_fn_call(

View file

@ -2525,7 +2525,7 @@ impl<'tcx> TyCtxt<'tcx> {
ident ident
} }
// FIXME(vincenzoapalzzo): move the HirId to a LocalDefId // FIXME(vincenzopalazzo): move the HirId to a LocalDefId
pub fn adjust_ident_and_get_scope( pub fn adjust_ident_and_get_scope(
self, self,
mut ident: Ident, mut ident: Ident,

View file

@ -590,7 +590,6 @@ struct LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
parent_scope: ParentScope<'a>, parent_scope: ParentScope<'a>,
/// The current set of local scopes for types and values. /// The current set of local scopes for types and values.
/// FIXME #4948: Reuse ribs to avoid allocation.
ribs: PerNS<Vec<Rib<'a>>>, ribs: PerNS<Vec<Rib<'a>>>,
/// Previous poped `rib`, only used for diagnostic. /// Previous poped `rib`, only used for diagnostic.

View file

@ -703,7 +703,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
PathResult::NonModule(path_res) if let Some(res) = path_res.full_res() => { PathResult::NonModule(path_res) if let Some(res) = path_res.full_res() => {
check_consistency(self, &path, path_span, kind, initial_res, res) check_consistency(self, &path, path_span, kind, initial_res, res)
} }
path_res @ PathResult::NonModule(..) | path_res @ PathResult::Failed { .. } => { path_res @ (PathResult::NonModule(..) | PathResult::Failed { .. }) => {
let mut suggestion = None; let mut suggestion = None;
let (span, label) = if let PathResult::Failed { span, label, .. } = path_res { let (span, label) = if let PathResult::Failed { span, label, .. } = path_res {
// try to suggest if it's not a macro, maybe a function // try to suggest if it's not a macro, maybe a function

View file

@ -212,7 +212,7 @@ pub trait TypeErrCtxtExt<'tcx> {
fn extract_callable_info( fn extract_callable_info(
&self, &self,
hir_id: HirId, body_id: LocalDefId,
param_env: ty::ParamEnv<'tcx>, param_env: ty::ParamEnv<'tcx>,
found: Ty<'tcx>, found: Ty<'tcx>,
) -> Option<(DefIdOrName, Ty<'tcx>, Vec<Ty<'tcx>>)>; ) -> Option<(DefIdOrName, Ty<'tcx>, Vec<Ty<'tcx>>)>;
@ -909,9 +909,8 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
trait_pred.self_ty(), trait_pred.self_ty(),
); );
let body_hir_id = self.tcx.hir().local_def_id_to_hir_id(obligation.cause.body_id);
let Some((def_id_or_name, output, inputs)) = self.extract_callable_info( let Some((def_id_or_name, output, inputs)) = self.extract_callable_info(
body_hir_id, obligation.cause.body_id,
obligation.param_env, obligation.param_env,
self_ty, self_ty,
) else { return false; }; ) else { return false; };
@ -1113,10 +1112,9 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
/// Extracts information about a callable type for diagnostics. This is a /// Extracts information about a callable type for diagnostics. This is a
/// heuristic -- it doesn't necessarily mean that a type is always callable, /// heuristic -- it doesn't necessarily mean that a type is always callable,
/// because the callable type must also be well-formed to be called. /// because the callable type must also be well-formed to be called.
// FIXME(vincenzopalazzo): move the HirId to a LocalDefId
fn extract_callable_info( fn extract_callable_info(
&self, &self,
hir_id: HirId, body_id: LocalDefId,
param_env: ty::ParamEnv<'tcx>, param_env: ty::ParamEnv<'tcx>,
found: Ty<'tcx>, found: Ty<'tcx>,
) -> Option<(DefIdOrName, Ty<'tcx>, Vec<Ty<'tcx>>)> { ) -> Option<(DefIdOrName, Ty<'tcx>, Vec<Ty<'tcx>>)> {
@ -1168,7 +1166,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
}) })
} }
ty::Param(param) => { ty::Param(param) => {
let generics = self.tcx.generics_of(hir_id.owner.to_def_id()); let generics = self.tcx.generics_of(body_id);
let name = if generics.count() > param.index as usize let name = if generics.count() > param.index as usize
&& let def = generics.param_at(param.index as usize, self.tcx) && let def = generics.param_at(param.index as usize, self.tcx)
&& matches!(def.kind, ty::GenericParamDefKind::Type { .. }) && matches!(def.kind, ty::GenericParamDefKind::Type { .. })

View file

@ -386,10 +386,6 @@ fn associated_type_for_impl_trait_in_impl(
opt_rpitit_info: Some(ImplTraitInTraitData::Impl { fn_def_id: impl_fn_def_id.to_def_id() }), opt_rpitit_info: Some(ImplTraitInTraitData::Impl { fn_def_id: impl_fn_def_id.to_def_id() }),
}); });
// Copy param_env of the containing function. The synthesized associated type doesn't have
// extra predicates to assume.
impl_assoc_ty.param_env(tcx.param_env(impl_fn_def_id));
// Copy visility of the containing function. // Copy visility of the containing function.
impl_assoc_ty.visibility(tcx.visibility(impl_fn_def_id)); impl_assoc_ty.visibility(tcx.visibility(impl_fn_def_id));

View file

@ -130,7 +130,9 @@ fn param_env(tcx: TyCtxt<'_>, def_id: DefId) -> ty::ParamEnv<'_> {
// FIXME(-Zlower-impl-trait-in-trait-to-assoc-ty): I don't like this, we should // FIXME(-Zlower-impl-trait-in-trait-to-assoc-ty): I don't like this, we should
// at least be making sure that the generics in RPITITs and their parent fn don't // at least be making sure that the generics in RPITITs and their parent fn don't
// get out of alignment, or else we do actually need to substitute these predicates. // get out of alignment, or else we do actually need to substitute these predicates.
if let Some(ImplTraitInTraitData::Trait { fn_def_id, .. }) = tcx.opt_rpitit_info(def_id) { if let Some(ImplTraitInTraitData::Trait { fn_def_id, .. })
| Some(ImplTraitInTraitData::Impl { fn_def_id, .. }) = tcx.opt_rpitit_info(def_id)
{
predicates = tcx.predicates_of(fn_def_id).instantiate_identity(tcx).predicates; predicates = tcx.predicates_of(fn_def_id).instantiate_identity(tcx).predicates;
} }

View file

@ -49,6 +49,8 @@
//! //!
//! The input to the [`mir!`] macro is: //! The input to the [`mir!`] macro is:
//! //!
//! - An optional return type annotation in the form of `type RET = ...;`. This may be required
//! if the compiler cannot infer the type of RET.
//! - A possibly empty list of local declarations. Locals can also be declared inline on //! - A possibly empty list of local declarations. Locals can also be declared inline on
//! assignments via `let`. Type inference generally works. Shadowing does not. //! assignments via `let`. Type inference generally works. Shadowing does not.
//! - A list of basic blocks. The first of these is the start block and is where execution begins. //! - A list of basic blocks. The first of these is the start block and is where execution begins.
@ -124,6 +126,18 @@
//! } //! }
//! ) //! )
//! } //! }
//!
//! #[custom_mir(dialect = "runtime", phase = "optimized")]
//! fn annotated_return_type() -> (i32, bool) {
//! mir!(
//! type RET = (i32, bool);
//! {
//! RET.0 = 1;
//! RET.1 = true;
//! Return()
//! }
//! )
//! }
//! ``` //! ```
//! //!
//! We can also set off compilation failures that happen in sufficiently late stages of the //! We can also set off compilation failures that happen in sufficiently late stages of the
@ -342,6 +356,7 @@ define!(
#[rustc_macro_transparency = "transparent"] #[rustc_macro_transparency = "transparent"]
pub macro mir { pub macro mir {
( (
$(type RET = $ret_ty:ty ;)?
$(let $local_decl:ident $(: $local_decl_ty:ty)? ;)* $(let $local_decl:ident $(: $local_decl_ty:ty)? ;)*
{ {
@ -362,7 +377,7 @@ pub macro mir {
{ {
// Now all locals // Now all locals
#[allow(non_snake_case)] #[allow(non_snake_case)]
let RET; let RET $(: $ret_ty)?;
$( $(
let $local_decl $(: $local_decl_ty)? ; let $local_decl $(: $local_decl_ty)? ;
)* )*

View file

@ -1,4 +1,4 @@
Change this file to make users of the `download-ci-llvm` configuration download Change this file to make users of the `download-ci-llvm` configuration download
a new version of LLVM from CI, even if the LLVM submodule hasnt changed. a new version of LLVM from CI, even if the LLVM submodule hasnt changed.
Last change is for: https://github.com/rust-lang/rust/pull/104748 Last change is for: https://github.com/rust-lang/rust/pull/109373

View file

@ -309,6 +309,7 @@ impl Step for Llvm {
cfg.out_dir(&out_dir) cfg.out_dir(&out_dir)
.profile(profile) .profile(profile)
.define("LLVM_ENABLE_ASSERTIONS", assertions) .define("LLVM_ENABLE_ASSERTIONS", assertions)
.define("LLVM_UNREACHABLE_OPTIMIZE", "OFF")
.define("LLVM_ENABLE_PLUGINS", plugins) .define("LLVM_ENABLE_PLUGINS", plugins)
.define("LLVM_TARGETS_TO_BUILD", llvm_targets) .define("LLVM_TARGETS_TO_BUILD", llvm_targets)
.define("LLVM_EXPERIMENTAL_TARGETS_TO_BUILD", llvm_exp_targets) .define("LLVM_EXPERIMENTAL_TARGETS_TO_BUILD", llvm_exp_targets)

View file

@ -217,7 +217,7 @@ ul.all-items {
a.anchor, a.anchor,
.small-section-header a, .small-section-header a,
#source-sidebar a, #source-sidebar a,
pre.rust a, .rust a,
.sidebar h2 a, .sidebar h2 a,
.sidebar h3 a, .sidebar h3 a,
.mobile-topbar h2 a, .mobile-topbar h2 a,
@ -228,43 +228,43 @@ h1 a,
color: var(--main-color); color: var(--main-color);
} }
.content span.enum, .content a.enum, span.enum, a.enum,
.content span.struct, .content a.struct, span.struct, a.struct,
.content span.union, .content a.union, span.union, a.union,
.content span.primitive, .content a.primitive, span.primitive, a.primitive,
.content span.type, .content a.type, span.type, a.type,
.content span.foreigntype, .content a.foreigntype { span.foreigntype, a.foreigntype {
color: var(--type-link-color); color: var(--type-link-color);
} }
.content span.trait, .content a.trait, span.trait, a.trait,
.content span.traitalias, .content a.traitalias { span.traitalias, a.traitalias {
color: var(--trait-link-color); color: var(--trait-link-color);
} }
.content span.associatedtype, .content a.associatedtype, span.associatedtype, a.associatedtype,
.content span.constant, .content a.constant, span.constant, a.constant,
.content span.static, .content a.static { span.static, a.static {
color: var(--assoc-item-link-color); color: var(--assoc-item-link-color);
} }
.content span.fn, .content a.fn, span.fn, a.fn,
.content span.method, .content a.method, span.method, a.method,
.content span.tymethod, .content a.tymethod { span.tymethod, a.tymethod {
color: var(--function-link-color); color: var(--function-link-color);
} }
.content span.attr, .content a.attr, span.attr, a.attr,
.content span.derive, .content a.derive, span.derive, a.derive,
.content span.macro, .content a.macro { span.macro, a.macro {
color: var(--macro-link-color); color: var(--macro-link-color);
} }
.content span.mod, .content a.mod { span.mod, a.mod {
color: var(--mod-link-color); color: var(--mod-link-color);
} }
.content span.keyword, .content a.keyword { span.keyword, a.keyword {
color: var(--keyword-link-color); color: var(--keyword-link-color);
} }
@ -713,7 +713,7 @@ h2.small-section-header > .anchor {
} }
.main-heading a:hover, .main-heading a:hover,
.example-wrap > pre.rust a:hover, .example-wrap > .rust a:hover,
.all-items a:hover, .all-items a:hover,
.docblock a:not(.test-arrow):not(.scrape-help):not(.tooltip):hover, .docblock a:not(.test-arrow):not(.scrape-help):not(.tooltip):hover,
.docblock-short a:not(.test-arrow):not(.scrape-help):not(.tooltip):hover, .docblock-short a:not(.test-arrow):not(.scrape-help):not(.tooltip):hover,

View file

@ -29,6 +29,7 @@ pub fn filter_dirs(path: &Path) -> bool {
// Filter RLS output directories // Filter RLS output directories
"target/rls", "target/rls",
"src/bootstrap/target", "src/bootstrap/target",
"vendor",
]; ];
skip.iter().any(|p| path.ends_with(p)) skip.iter().any(|p| path.ends_with(p))
} }

View file

@ -1,3 +1,8 @@
// revisions: old new
// LLVM 17 realizes double panic is not possible and doesn't generate calls
// to panic_cannot_unwind.
// [old]ignore-llvm-version: 17 - 99
// [new]min-llvm-version: 17
// compile-flags: -O // compile-flags: -O
// ignore-debug: the debug assertions get in the way // ignore-debug: the debug assertions get in the way
#![crate_type = "lib"] #![crate_type = "lib"]
@ -18,11 +23,11 @@ pub fn shrink_to_fit(vec: &mut Vec<u32>) {
pub fn issue71861(vec: Vec<u32>) -> Box<[u32]> { pub fn issue71861(vec: Vec<u32>) -> Box<[u32]> {
// CHECK-NOT: panic // CHECK-NOT: panic
// Call to panic_cannot_unwind in case of double-panic is expected, // Call to panic_cannot_unwind in case of double-panic is expected
// but other panics are not. // on LLVM 16 and older, but other panics are not.
// CHECK: cleanup // CHECK: cleanup
// CHECK-NEXT: ; call core::panicking::panic_cannot_unwind // old-NEXT: ; call core::panicking::panic_cannot_unwind
// CHECK-NEXT: panic_cannot_unwind // old-NEXT: panic_cannot_unwind
// CHECK-NOT: panic // CHECK-NOT: panic
vec.into_boxed_slice() vec.into_boxed_slice()
@ -34,14 +39,14 @@ pub fn issue75636<'a>(iter: &[&'a str]) -> Box<[&'a str]> {
// CHECK-NOT: panic // CHECK-NOT: panic
// Call to panic_cannot_unwind in case of double-panic is expected, // Call to panic_cannot_unwind in case of double-panic is expected,
// but other panics are not. // on LLVM 16 and older, but other panics are not.
// CHECK: cleanup // CHECK: cleanup
// CHECK-NEXT: ; call core::panicking::panic_cannot_unwind // old-NEXT: ; call core::panicking::panic_cannot_unwind
// CHECK-NEXT: panic_cannot_unwind // old-NEXT: panic_cannot_unwind
// CHECK-NOT: panic // CHECK-NOT: panic
iter.iter().copied().collect() iter.iter().copied().collect()
} }
// CHECK: ; core::panicking::panic_cannot_unwind // old: ; core::panicking::panic_cannot_unwind
// CHECK: declare void @{{.*}}panic_cannot_unwind // old: declare void @{{.*}}panic_cannot_unwind

View file

@ -0,0 +1,21 @@
#![feature(custom_mir, core_intrinsics)]
extern crate core;
use core::intrinsics::mir::*;
// EMIT_MIR composite_return.tuple.built.after.mir
#[custom_mir(dialect = "runtime", phase = "optimized")]
fn tuple() -> (i32, bool) {
mir!(
type RET = (i32, bool);
{
RET.0 = 1;
RET.1 = true;
Return()
}
)
}
fn main() {
assert_eq!(tuple(), (1, true));
}

View file

@ -0,0 +1,11 @@
// MIR for `tuple` after built
fn tuple() -> (i32, bool) {
let mut _0: (i32, bool); // return place in scope 0 at $DIR/composite_return.rs:+0:15: +0:26
bb0: {
(_0.0: i32) = const 1_i32; // scope 0 at $DIR/composite_return.rs:+4:13: +4:22
(_0.1: bool) = const true; // scope 0 at $DIR/composite_return.rs:+5:13: +5:25
return; // scope 0 at $DIR/composite_return.rs:+6:13: +6:21
}
}

View file

@ -0,0 +1,51 @@
// This test ensures that the "Auto-hide item contents for large items" setting is working as
// expected.
// We need to disable this check because `implementors/test_docs/trait.Iterator.js` doesn't exist.
fail-on-request-error: false
define-function: (
"check-setting",
(storage_value, setting_attribute_value, toggle_attribute_value),
block {
assert-local-storage: {"rustdoc-auto-hide-large-items": |storage_value|}
click: "#settings-menu"
wait-for: "#settings"
assert-property: ("#auto-hide-large-items", {"checked": |setting_attribute_value|})
assert-attribute: (".item-decl .type-contents-toggle", {"open": |toggle_attribute_value|})
}
)
goto: "file://" + |DOC_PATH| + "/lib2/scroll_traits/trait.Iterator.html"
// We check that the setting is enabled by default and is working.
call-function: ("check-setting", {
"storage_value": null,
"setting_attribute_value": "true",
"toggle_attribute_value": null,
})
// Now we change its value.
click: "#auto-hide-large-items"
assert-local-storage: {"rustdoc-auto-hide-large-items": "false"}
// We check that the changes were applied as expected.
reload:
call-function: ("check-setting", {
"storage_value": "false",
"setting_attribute_value": "false",
"toggle_attribute_value": "",
})
// And now we re-enable the setting.
click: "#auto-hide-large-items"
assert-local-storage: {"rustdoc-auto-hide-large-items": "true"}
// And we check everything is back the way it was before.
reload:
call-function: ("check-setting", {
"storage_value": "true",
"setting_attribute_value": "true",
"toggle_attribute_value": null,
})

View file

@ -1,5 +1,7 @@
// edition:2021 // edition:2021
// check-pass // check-pass
// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty
// revisions: current next
#![feature(async_fn_in_trait)] #![feature(async_fn_in_trait)]
#![allow(incomplete_features)] #![allow(incomplete_features)]