Auto merge of #139552 - matthiaskrgr:rollup-b194mk8, r=matthiaskrgr

Rollup of 10 pull requests

Successful merges:

 - #139494 (Restrict some queries by def-kind more)
 - #139496 (Revert r-a changes of rust-lang/rust#139455)
 - #139506 (add missing word in doc comment (part 2))
 - #139515 (Improve presentation of closure signature mismatch from `Fn` trait goal)
 - #139520 (compiletest maintenance: sort deps and drop dep on `anyhow`)
 - #139523 (Rustc dev guide subtree update)
 - #139526 (Fix deprecation note for std::intrinsics)
 - #139528 (compiletest: Remove the `--logfile` flag)
 - #139541 (Instantiate higher-ranked transmute goal w/ placeholders before emitting sub-obligations)
 - #139547 (Update library tracking issue template to set S-tracking-unimplemented)

r? `@ghost`
`@rustbot` modify labels: rollup
This commit is contained in:
bors 2025-04-09 05:39:18 +00:00
commit 97c966bb40
37 changed files with 207 additions and 113 deletions

View file

@ -2,7 +2,7 @@
name: Library Tracking Issue
about: A tracking issue for an unstable library feature.
title: Tracking Issue for XXX
labels: C-tracking-issue, T-libs-api
labels: C-tracking-issue, T-libs-api, S-tracking-unimplemented
---
<!--
Thank you for creating a tracking issue!
@ -49,6 +49,8 @@ For larger features, more steps might be involved.
If the feature is changed later, please add those PRs here as well.
-->
(Remember to update the `S-tracking-*` label when checking boxes.)
- [ ] Implementation: #...
- [ ] Final comment period (FCP)[^1]
- [ ] Stabilization PR

View file

@ -718,7 +718,6 @@ name = "compiletest"
version = "0.0.0"
dependencies = [
"anstyle-svg",
"anyhow",
"build_helper",
"colored",
"diff",

View file

@ -647,9 +647,9 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
#[rustc_lint_diagnostics]
pub fn note_expected_found(
&mut self,
expected_label: &dyn fmt::Display,
expected_label: &str,
expected: DiagStyledString,
found_label: &dyn fmt::Display,
found_label: &str,
found: DiagStyledString,
) -> &mut Self {
self.note_expected_found_extra(
@ -665,9 +665,9 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
#[rustc_lint_diagnostics]
pub fn note_expected_found_extra(
&mut self,
expected_label: &dyn fmt::Display,
expected_label: &str,
expected: DiagStyledString,
found_label: &dyn fmt::Display,
found_label: &str,
found: DiagStyledString,
expected_extra: DiagStyledString,
found_extra: DiagStyledString,

View file

@ -14,6 +14,7 @@
//! At present, however, we do run collection across all items in the
//! crate as a kind of pass. This should eventually be factored away.
use std::assert_matches::assert_matches;
use std::cell::Cell;
use std::iter;
use std::ops::Bound;
@ -1344,7 +1345,8 @@ fn fn_sig(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::EarlyBinder<'_, ty::PolyFn
compute_sig_of_foreign_fn_decl(tcx, def_id, sig.decl, abi, sig.header.safety())
}
Ctor(data) | Variant(hir::Variant { data, .. }) if data.ctor().is_some() => {
Ctor(data) => {
assert_matches!(data.ctor(), Some(_));
let adt_def_id = tcx.hir_get_parent_item(hir_id).def_id.to_def_id();
let ty = tcx.type_of(adt_def_id).instantiate_identity();
let inputs = data.fields().iter().map(|f| tcx.type_of(f.def_id).instantiate_identity());

View file

@ -44,13 +44,13 @@ fn variances_of(tcx: TyCtxt<'_>, item_def_id: LocalDefId) -> &[ty::Variance] {
return &[];
}
match tcx.def_kind(item_def_id) {
let kind = tcx.def_kind(item_def_id);
match kind {
DefKind::Fn
| DefKind::AssocFn
| DefKind::Enum
| DefKind::Struct
| DefKind::Union
| DefKind::Variant
| DefKind::Ctor(..) => {
// These are inferred.
let crate_map = tcx.crate_variances(());
@ -89,7 +89,11 @@ fn variances_of(tcx: TyCtxt<'_>, item_def_id: LocalDefId) -> &[ty::Variance] {
}
// Variance not relevant.
span_bug!(tcx.def_span(item_def_id), "asked to compute variance for wrong kind of item");
span_bug!(
tcx.def_span(item_def_id),
"asked to compute variance for {}",
kind.descr(item_def_id.to_def_id())
);
}
#[derive(Debug, Copy, Clone)]

View file

@ -513,7 +513,7 @@ impl Subdiagnostic for BuiltinClashingExternSub<'_> {
expected_str.push(self.expected.fn_sig(self.tcx).to_string(), false);
let mut found_str = DiagStyledString::new();
found_str.push(self.found.fn_sig(self.tcx).to_string(), true);
diag.note_expected_found(&"", expected_str, &"", found_str);
diag.note_expected_found("", expected_str, "", found_str);
}
}

View file

@ -1099,7 +1099,6 @@ fn should_encode_variances<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId, def_kind: Def
DefKind::Struct
| DefKind::Union
| DefKind::Enum
| DefKind::Variant
| DefKind::OpaqueTy
| DefKind::Fn
| DefKind::Ctor(..)
@ -1109,6 +1108,7 @@ fn should_encode_variances<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId, def_kind: Def
matches!(tcx.opt_rpitit_info(def_id), Some(ty::ImplTraitInTraitData::Trait { .. }))
}
DefKind::Mod
| DefKind::Variant
| DefKind::Field
| DefKind::AssocConst
| DefKind::TyParam

View file

@ -967,7 +967,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
format!("...so that the {}", sup_trace.cause.as_requirement_str()),
);
err.note_expected_found(&"", sup_expected, &"", sup_found);
err.note_expected_found("", sup_expected, "", sup_found);
return if sub_region.is_error() | sup_region.is_error() {
err.delay_as_bug()
} else {

View file

@ -2,6 +2,7 @@ use core::ops::ControlFlow;
use std::borrow::Cow;
use std::path::PathBuf;
use rustc_abi::ExternAbi;
use rustc_ast::TraitObjectSyntax;
use rustc_data_structures::fx::FxHashMap;
use rustc_data_structures::unord::UnordSet;
@ -2799,32 +2800,57 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
}
// Note any argument mismatches
let given_ty = params.skip_binder();
let ty::Tuple(given) = *params.skip_binder().kind() else {
return;
};
let expected_ty = trait_pred.skip_binder().trait_ref.args.type_at(1);
if let ty::Tuple(given) = given_ty.kind()
&& let ty::Tuple(expected) = expected_ty.kind()
{
if expected.len() != given.len() {
// Note number of types that were expected and given
err.note(
format!(
"expected a closure taking {} argument{}, but one taking {} argument{} was given",
given.len(),
pluralize!(given.len()),
expected.len(),
pluralize!(expected.len()),
)
);
} else if !self.same_type_modulo_infer(given_ty, expected_ty) {
// Print type mismatch
let (expected_args, given_args) = self.cmp(given_ty, expected_ty);
err.note_expected_found(
&"a closure with arguments",
expected_args,
&"a closure with arguments",
given_args,
);
}
let ty::Tuple(expected) = *expected_ty.kind() else {
return;
};
if expected.len() != given.len() {
// Note number of types that were expected and given
err.note(format!(
"expected a closure taking {} argument{}, but one taking {} argument{} was given",
given.len(),
pluralize!(given.len()),
expected.len(),
pluralize!(expected.len()),
));
return;
}
let given_ty = Ty::new_fn_ptr(
self.tcx,
params.rebind(self.tcx.mk_fn_sig(
given,
self.tcx.types.unit,
false,
hir::Safety::Safe,
ExternAbi::Rust,
)),
);
let expected_ty = Ty::new_fn_ptr(
self.tcx,
trait_pred.rebind(self.tcx.mk_fn_sig(
expected,
self.tcx.types.unit,
false,
hir::Safety::Safe,
ExternAbi::Rust,
)),
);
if !self.same_type_modulo_infer(given_ty, expected_ty) {
// Print type mismatch
let (expected_args, given_args) = self.cmp(expected_ty, given_ty);
err.note_expected_found(
"a closure with signature",
expected_args,
"a closure with signature",
given_args,
);
}
}

View file

@ -415,7 +415,7 @@ impl Subdiagnostic for RegionOriginNote<'_> {
label_or_note(span, fluent::trait_selection_subtype);
diag.arg("requirement", requirement);
diag.note_expected_found(&"", expected, &"", found);
diag.note_expected_found("", expected, "", found);
}
RegionOriginNote::WithRequirement { span, requirement, expected_found: None } => {
// FIXME: this really should be handled at some earlier stage. Our

View file

@ -317,7 +317,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
obligation.cause.clone(),
obligation.recursion_depth + 1,
obligation.param_env,
obligation.predicate.rebind(trait_ref),
trait_ref,
)
};
@ -343,7 +343,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
obligation.cause.clone(),
obligation.recursion_depth + 1,
obligation.param_env,
obligation.predicate.rebind(outlives),
outlives,
)
};
@ -404,7 +404,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
}
}
let predicate = obligation.predicate.skip_binder();
let predicate = self.infcx.enter_forall_and_leak_universe(obligation.predicate);
let mut assume = predicate.trait_ref.args.const_at(2);
// FIXME(mgca): We should shallowly normalize this.

View file

@ -4,9 +4,9 @@ use rustc_data_structures::fx::FxHashMap;
use rustc_hir as hir;
use rustc_hir::def::DefKind;
use rustc_hir::def_id::LocalDefId;
use rustc_middle::bug;
use rustc_middle::query::Providers;
use rustc_middle::ty::{self, Ty, TyCtxt, fold_regions};
use rustc_middle::{bug, span_bug};
use rustc_span::Span;
pub(crate) fn provide(providers: &mut Providers) {
@ -21,7 +21,8 @@ pub(crate) fn provide(providers: &mut Providers) {
}
fn assumed_wf_types<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> &'tcx [(Ty<'tcx>, Span)] {
match tcx.def_kind(def_id) {
let kind = tcx.def_kind(def_id);
match kind {
DefKind::Fn => {
let sig = tcx.fn_sig(def_id).instantiate_identity();
let liberated_sig = tcx.liberate_late_bound_regions(def_id.to_def_id(), sig);
@ -121,32 +122,38 @@ fn assumed_wf_types<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> &'tcx [(Ty<'
}
}
DefKind::AssocConst | DefKind::AssocTy => tcx.assumed_wf_types(tcx.local_parent(def_id)),
DefKind::OpaqueTy => bug!("implied bounds are not defined for opaques"),
DefKind::Mod
DefKind::Static { .. }
| DefKind::Const
| DefKind::AnonConst
| DefKind::InlineConst
| DefKind::Struct
| DefKind::Union
| DefKind::Enum
| DefKind::Variant
| DefKind::Trait
| DefKind::TyAlias
| DefKind::ForeignTy
| DefKind::TraitAlias
| DefKind::TyAlias => ty::List::empty(),
DefKind::OpaqueTy
| DefKind::Mod
| DefKind::Variant
| DefKind::ForeignTy
| DefKind::TyParam
| DefKind::Const
| DefKind::ConstParam
| DefKind::Static { .. }
| DefKind::Ctor(_, _)
| DefKind::Macro(_)
| DefKind::ExternCrate
| DefKind::Use
| DefKind::ForeignMod
| DefKind::AnonConst
| DefKind::InlineConst
| DefKind::Field
| DefKind::LifetimeParam
| DefKind::GlobalAsm
| DefKind::Closure
| DefKind::SyntheticCoroutineBody => ty::List::empty(),
| DefKind::SyntheticCoroutineBody => {
span_bug!(
tcx.def_span(def_id),
"`assumed_wf_types` not defined for {} `{def_id:?}`",
kind.descr(def_id.to_def_id())
);
}
}
}

View file

@ -3,10 +3,10 @@ use rustc_hir::def::DefKind;
use rustc_hir::def_id::LocalDefId;
use rustc_hir::intravisit;
use rustc_hir::intravisit::Visitor;
use rustc_middle::bug;
use rustc_middle::query::Providers;
use rustc_middle::ty::util::{CheckRegions, NotUniqueParam};
use rustc_middle::ty::{self, Ty, TyCtxt, TypeSuperVisitable, TypeVisitable, TypeVisitor};
use rustc_middle::{bug, span_bug};
use rustc_span::Span;
use tracing::{instrument, trace};
@ -320,9 +320,12 @@ fn opaque_types_defined_by<'tcx>(
| DefKind::AnonConst => {
collector.collect_taits_declared_in_body();
}
// Closures and coroutines are type checked with their parent
DefKind::Closure | DefKind::InlineConst => {
collector.opaques.extend(tcx.opaque_types_defined_by(tcx.local_parent(item)));
}
DefKind::AssocTy | DefKind::TyAlias | DefKind::GlobalAsm => {}
DefKind::OpaqueTy
| DefKind::TyAlias
| DefKind::AssocTy
| DefKind::Mod
| DefKind::Struct
| DefKind::Union
@ -340,12 +343,13 @@ fn opaque_types_defined_by<'tcx>(
| DefKind::ForeignMod
| DefKind::Field
| DefKind::LifetimeParam
| DefKind::GlobalAsm
| DefKind::Impl { .. }
| DefKind::SyntheticCoroutineBody => {}
// Closures and coroutines are type checked with their parent
DefKind::Closure | DefKind::InlineConst => {
collector.opaques.extend(tcx.opaque_types_defined_by(tcx.local_parent(item)));
| DefKind::SyntheticCoroutineBody => {
span_bug!(
tcx.def_span(item),
"`opaque_types_defined_by` not defined for {} `{item:?}`",
kind.descr(item.to_def_id())
);
}
}
tcx.mk_local_def_ids(&collector.opaques)

View file

@ -116,7 +116,7 @@ pub fn walk_types<'tcx, V: SpannedTypeVisitor<'tcx>>(
"{kind:?} has not seen any uses of `walk_types` yet, ping oli-obk if you'd like any help"
)
}
// These don't have any types.
// These don't have any types, but are visited during privacy checking.
| DefKind::ExternCrate
| DefKind::ForeignMod
| DefKind::ForeignTy

View file

@ -3720,7 +3720,7 @@ pub const fn ptr_metadata<P: ptr::Pointee<Metadata = M> + ?Sized, M>(ptr: *const
/// [`Vec::append`]: ../../std/vec/struct.Vec.html#method.append
#[doc(alias = "memcpy")]
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_allowed_through_unstable_modules = "import this function via `std::mem` instead"]
#[rustc_allowed_through_unstable_modules = "import this function via `std::ptr` instead"]
#[rustc_const_stable(feature = "const_intrinsic_copy", since = "1.83.0")]
#[inline(always)]
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
@ -3823,7 +3823,7 @@ pub const unsafe fn copy_nonoverlapping<T>(src: *const T, dst: *mut T, count: us
/// ```
#[doc(alias = "memmove")]
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_allowed_through_unstable_modules = "import this function via `std::mem` instead"]
#[rustc_allowed_through_unstable_modules = "import this function via `std::ptr` instead"]
#[rustc_const_stable(feature = "const_intrinsic_copy", since = "1.83.0")]
#[inline(always)]
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
@ -3903,7 +3903,7 @@ pub const unsafe fn copy<T>(src: *const T, dst: *mut T, count: usize) {
/// ```
#[doc(alias = "memset")]
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_allowed_through_unstable_modules = "import this function via `std::mem` instead"]
#[rustc_allowed_through_unstable_modules = "import this function via `std::ptr` instead"]
#[rustc_const_stable(feature = "const_ptr_write", since = "1.83.0")]
#[inline(always)]
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces

View file

@ -189,7 +189,7 @@ pub enum GccCiMode {
///
/// Note that this structure is not decoded directly into, but rather it is
/// filled out from the decoded forms of the structs below. For documentation
/// each field, see the corresponding fields in
/// on each field, see the corresponding fields in
/// `bootstrap.example.toml`.
#[derive(Default, Clone)]
pub struct Config {

View file

@ -1,6 +1,6 @@
[book]
title = "Rust Compiler Development Guide"
author = "The Rust Project Developers"
authors = ["The Rust Project Developers"]
description = "A guide to developing the Rust compiler (rustc)"
[build]

View file

@ -1 +1 @@
ae9173d7dd4a31806c950c90dcc331f1508b4d17
25a615bf829b9f6d6f22da537e3851043f92e5f2

View file

@ -110,7 +110,7 @@ See [`compute_hir_hash`] for where the hash is actually computed.
[SVH]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_data_structures/svh/struct.Svh.html
[incremental compilation]: ../queries/incremental-compilation.md
[`compute_hir_hash`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_ast_lowering/struct.LoweringContext.html#method.compute_hir_hash
[`compute_hir_hash`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_ast_lowering/fn.compute_hir_hash.html
### Stable Crate Id

View file

@ -90,7 +90,9 @@ does is call the `main()` that's in this crate's `lib.rs`, though.)
are in `tests/rustdoc-gui`. These use a [NodeJS tool called
browser-UI-test](https://github.com/GuillaumeGomez/browser-UI-test/) that uses
puppeteer to run tests in a headless browser and check rendering and
interactivity.
interactivity. For information on how to write this form of test,
see [`tests/rustdoc-gui/README.md`][rustdoc-gui-readme]
as well as [the description of the `.goml` format][goml-script]
* Additionally, JavaScript type annotations are written using [TypeScript-flavored JSDoc]
comments and an external d.ts file. The code itself is plain, valid JavaScript; we only
use tsc as a linter.
@ -100,6 +102,8 @@ does is call the `main()` that's in this crate's `lib.rs`, though.)
[These tests have several extra directives available to them](./rustdoc-internals/rustdoc-test-suite.md).
[TypeScript-flavored JSDoc]: https://www.typescriptlang.org/docs/handbook/jsdoc-supported-types.html
[rustdoc-gui-readme]: https://github.com/rust-lang/rust/blob/master/tests/rustdoc-gui/README.md
[goml-script]: https://github.com/GuillaumeGomez/browser-UI-test/blob/master/goml-script.md
## Constraints

View file

@ -6,7 +6,8 @@
FIXME(jieyouxu) completely revise this chapter.
-->
Directives are special comments that tell compiletest how to build and interpret a test. They must appear before the Rust source in the test. They may also appear in `rmake.rs` [run-make tests](compiletest.md#run-make-tests).
Directives are special comments that tell compiletest how to build and interpret a test.
They may also appear in `rmake.rs` [run-make tests](compiletest.md#run-make-tests).
They are normally put after the short comment that explains the point of this
test. Compiletest test suites use `//@` to signal that a comment is a directive.

View file

@ -335,8 +335,9 @@ But for strict testing, try to use the `ERROR` annotation as much as possible,
including `//~?` annotations for diagnostics without span.
For compile time diagnostics `error-pattern` should very rarely be necessary.
Per-line annotations (`//~`) are still checked in tests using `error-pattern`,
to opt out of these checks in exceptional cases use `//@ compile-flags: --error-format=human`.
Per-line annotations (`//~`) are still checked in tests using `error-pattern`.
To opt out of these checks, use `//@ compile-flags: --error-format=human`.
Do that only in exceptional cases.
### Error levels

View file

@ -7,25 +7,26 @@ edition = "2021"
doctest = false
[dependencies]
# tidy-alphabetical-start
anstyle-svg = "0.1.3"
build_helper = { path = "../../build_helper" }
colored = "2"
diff = "0.1.10"
unified-diff = "0.2.1"
getopts = "0.2"
glob = "0.3.0"
home = "0.5.5"
indexmap = "2.0.0"
miropt-test-tools = { path = "../miropt-test-tools" }
build_helper = { path = "../../build_helper" }
tracing = "0.1"
tracing-subscriber = { version = "0.3.3", default-features = false, features = ["ansi", "env-filter", "fmt", "parking_lot", "smallvec"] }
regex = "1.0"
rustfix = "0.8.1"
semver = { version = "1.0.23", features = ["serde"] }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
rustfix = "0.8.1"
tracing = "0.1"
tracing-subscriber = { version = "0.3.3", default-features = false, features = ["ansi", "env-filter", "fmt", "parking_lot", "smallvec"] }
unified-diff = "0.2.1"
walkdir = "2"
glob = "0.3.0"
anyhow = "1"
home = "0.5.5"
# tidy-alphabetical-end
[target.'cfg(unix)'.dependencies]
libc = "0.2"

View file

@ -275,9 +275,6 @@ pub struct Config {
/// Explicitly enable or disable running.
pub run: Option<bool>,
/// Write out a parseable log of tests that were run
pub logfile: Option<PathBuf>,
/// A command line to prefix program execution with,
/// for running under valgrind for example.
///

View file

@ -138,7 +138,7 @@ fn test_opts(config: &Config) -> test::TestOpts {
filter_exact: config.filter_exact,
run_ignored: if config.run_ignored { test::RunIgnored::Yes } else { test::RunIgnored::No },
format: config.format.to_libtest(),
logfile: config.logfile.clone(),
logfile: None,
run_tests: true,
bench_benchmarks: true,
nocapture: config.nocapture,

View file

@ -139,7 +139,6 @@ pub fn parse_config(args: Vec<String>) -> Config {
.optflag("", "quiet", "print one character per test instead of one line")
.optopt("", "color", "coloring: auto, always, never", "WHEN")
.optflag("", "json", "emit json output instead of plaintext output")
.optopt("", "logfile", "file to log test execution to", "FILE")
.optopt("", "target", "the target to build for", "TARGET")
.optopt("", "host", "the host to build for", "HOST")
.optopt("", "cdb", "path to CDB to use for CDB debuginfo tests", "PATH")
@ -378,7 +377,6 @@ pub fn parse_config(args: Vec<String>) -> Config {
"never" => Some(false),
_ => panic!("unknown `--run` option `{}` given", mode),
}),
logfile: matches.opt_str("logfile").map(|s| PathBuf::from(&s)),
runner: matches.opt_str("runner"),
host_rustcflags: matches.opt_strs("host-rustcflags"),
target_rustcflags: matches.opt_strs("target-rustcflags"),

View file

@ -10,7 +10,6 @@ use std::process::{Child, Command, ExitStatus, Output, Stdio};
use std::sync::Arc;
use std::{env, iter, str};
use anyhow::Context;
use colored::Colorize;
use regex::{Captures, Regex};
use tracing::*;
@ -143,11 +142,11 @@ pub fn run(config: Arc<Config>, testpaths: &TestPaths, revision: Option<&str>) {
}
let cx = TestCx { config: &config, props: &props, testpaths, revision };
create_dir_all(&cx.output_base_dir())
.with_context(|| {
format!("failed to create output base directory {}", cx.output_base_dir().display())
})
.unwrap();
if let Err(e) = create_dir_all(&cx.output_base_dir()) {
panic!("failed to create output base directory {}: {e}", cx.output_base_dir().display());
}
if props.incremental {
cx.init_incremental_test();
}

View file

@ -400,6 +400,7 @@ pub enum FnAbi {
Rust,
RustCall,
RustCold,
RustIntrinsic,
Stdcall,
StdcallUnwind,
System,
@ -456,6 +457,7 @@ impl FnAbi {
s if *s == sym::riscv_dash_interrupt_dash_s => FnAbi::RiscvInterruptS,
s if *s == sym::rust_dash_call => FnAbi::RustCall,
s if *s == sym::rust_dash_cold => FnAbi::RustCold,
s if *s == sym::rust_dash_intrinsic => FnAbi::RustIntrinsic,
s if *s == sym::Rust => FnAbi::Rust,
s if *s == sym::stdcall_dash_unwind => FnAbi::StdcallUnwind,
s if *s == sym::stdcall => FnAbi::Stdcall,
@ -498,6 +500,7 @@ impl FnAbi {
FnAbi::Rust => "Rust",
FnAbi::RustCall => "rust-call",
FnAbi::RustCold => "rust-cold",
FnAbi::RustIntrinsic => "rust-intrinsic",
FnAbi::Stdcall => "stdcall",
FnAbi::StdcallUnwind => "stdcall-unwind",
FnAbi::System => "system",

View file

@ -59,7 +59,19 @@ impl Evaluator<'_> {
let function_data = self.db.function_data(def);
let attrs = self.db.attrs(def.into());
let is_intrinsic = attrs.by_key(&sym::rustc_intrinsic).exists();
let is_intrinsic = attrs.by_key(&sym::rustc_intrinsic).exists()
// Keep this around for a bit until extern "rustc-intrinsic" abis are no longer used
|| (match &function_data.abi {
Some(abi) => *abi == sym::rust_dash_intrinsic,
None => match def.lookup(self.db.upcast()).container {
hir_def::ItemContainerId::ExternBlockId(block) => {
let id = block.lookup(self.db.upcast()).id;
id.item_tree(self.db.upcast())[id.value].abi.as_ref()
== Some(&sym::rust_dash_intrinsic)
}
_ => false,
},
});
if is_intrinsic {
return self.exec_intrinsic(

View file

@ -18,6 +18,7 @@ use hir_def::{
TypeOrConstParamId,
};
use hir_expand::name::Name;
use intern::sym;
use rustc_abi::TargetDataLayout;
use rustc_hash::FxHashSet;
use smallvec::{smallvec, SmallVec};
@ -302,13 +303,26 @@ pub fn is_fn_unsafe_to_call(
let loc = func.lookup(db.upcast());
match loc.container {
hir_def::ItemContainerId::ExternBlockId(_block) => {
// Function in an `extern` block are always unsafe to call, except when
// it is marked as `safe`.
if data.is_safe() {
Unsafety::Safe
hir_def::ItemContainerId::ExternBlockId(block) => {
let id = block.lookup(db.upcast()).id;
let is_intrinsic_block =
id.item_tree(db.upcast())[id.value].abi.as_ref() == Some(&sym::rust_dash_intrinsic);
if is_intrinsic_block {
// legacy intrinsics
// extern "rust-intrinsic" intrinsics are unsafe unless they have the rustc_safe_intrinsic attribute
if db.attrs(func.into()).by_key(&sym::rustc_safe_intrinsic).exists() {
Unsafety::Safe
} else {
Unsafety::Unsafe
}
} else {
Unsafety::Unsafe
// Function in an `extern` block are always unsafe to call, except when
// it is marked as `safe`.
if data.is_safe() {
Unsafety::Safe
} else {
Unsafety::Unsafe
}
}
}
_ => Unsafety::Safe,

View file

@ -36,6 +36,7 @@ const SUPPORTED_CALLING_CONVENTIONS: &[&str] = &[
"wasm",
"system",
"system-unwind",
"rust-intrinsic",
"rust-call",
"unadjusted",
];

View file

@ -125,6 +125,7 @@ define_symbols! {
riscv_dash_interrupt_dash_s = "riscv-interrupt-s",
rust_dash_call = "rust-call",
rust_dash_cold = "rust-cold",
rust_dash_intrinsic = "rust-intrinsic",
stdcall_dash_unwind = "stdcall-unwind",
system_dash_unwind = "system-unwind",
sysv64_dash_unwind = "sysv64-unwind",

View file

@ -6,8 +6,8 @@ LL | call(f, ());
| |
| required by a bound introduced by this call
|
= note: expected a closure with arguments `((),)`
found a closure with arguments `(<_ as ATC<'a>>::Type,)`
= note: expected a closure with signature `for<'a> fn(<_ as ATC<'a>>::Type)`
found a closure with signature `fn(())`
note: this is a known limitation of the trait solver that will be lifted in the future
--> $DIR/issue-62529-3.rs:25:14
|

View file

@ -6,8 +6,8 @@ LL | real_dispatch(f)
| |
| required by a bound introduced by this call
|
= note: expected a closure with arguments `(&mut UIView<'a, _>,)`
found a closure with arguments `(&mut UIView<'_, _>,)`
= note: expected a closure with signature `for<'a, 'b> fn(&'a mut UIView<'b, _>)`
found a closure with signature `fn(&mut UIView<'a, _>)`
note: required by a bound in `real_dispatch`
--> $DIR/issue-100690.rs:8:8
|

View file

@ -7,8 +7,8 @@ LL | let _ = (-10..=10).find(|x: i32| x.signum() == 0);
| required by a bound introduced by this call
|
= help: the trait `for<'a> FnMut(&'a <std::ops::RangeInclusive<{integer}> as Iterator>::Item)` is not implemented for closure `{closure@$DIR/closure-arg-type-mismatch-issue-45727.rs:6:29: 6:37}`
= note: expected a closure with arguments `(i32,)`
found a closure with arguments `(&<std::ops::RangeInclusive<{integer}> as Iterator>::Item,)`
= note: expected a closure with signature `for<'a> fn(&'a <std::ops::RangeInclusive<{integer}> as Iterator>::Item)`
found a closure with signature `fn(i32)`
note: required by a bound in `find`
--> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
@ -27,8 +27,8 @@ LL | let _ = (-10..=10).find(|x: &&&i32| x.signum() == 0);
| required by a bound introduced by this call
|
= help: the trait `for<'a> FnMut(&'a <std::ops::RangeInclusive<{integer}> as Iterator>::Item)` is not implemented for closure `{closure@$DIR/closure-arg-type-mismatch-issue-45727.rs:9:29: 9:40}`
= note: expected a closure with arguments `(&&&i32,)`
found a closure with arguments `(&<std::ops::RangeInclusive<{integer}> as Iterator>::Item,)`
= note: expected a closure with signature `for<'a> fn(&'a <std::ops::RangeInclusive<{integer}> as Iterator>::Item)`
found a closure with signature `fn(&&&i32)`
note: required by a bound in `find`
--> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL

View file

@ -6,8 +6,8 @@ LL | take(f)
| |
| required by a bound introduced by this call
|
= note: expected a closure with arguments `(u32,)`
found a closure with arguments `(i32,)`
= note: expected a closure with signature `fn(i32)`
found a closure with signature `fn(u32)`
note: required by a bound in `take`
--> $DIR/mismatch-fn-trait.rs:1:18
|
@ -68,8 +68,8 @@ LL | take(f)
| required by a bound introduced by this call
|
= note: `impl FnOnce(u32)` implements `FnOnce`, but it must implement `FnMut`, which is more general
= note: expected a closure with arguments `(u32,)`
found a closure with arguments `(i32,)`
= note: expected a closure with signature `fn(i32)`
found a closure with signature `fn(u32)`
note: required by a bound in `take`
--> $DIR/mismatch-fn-trait.rs:1:18
|

View file

@ -0,0 +1,18 @@
// Ensure we don't ICE when transmuting higher-ranked types via a
// higher-ranked transmute goal.
//@ check-pass
#![feature(transmutability)]
use std::mem::TransmuteFrom;
pub fn transmute()
where
for<'a> &'a &'a i32: TransmuteFrom<&'a &'a u32>,
{
}
fn main() {
transmute();
}