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 6 pull requests #84791

Closed
wants to merge 14 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -666,9 +666,9 @@ dependencies = [

[[package]]
name = "compiler_builtins"
version = "0.1.39"
version = "0.1.41"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3748f82c7d366a0b4950257d19db685d4958d2fa27c6d164a3f069fec42b748b"
checksum = "68448b4c6cee41f17bef42cbdad2fde55d05b91a6116c3a517e5389fb742758d"
dependencies = [
"cc",
"rustc-std-workspace-core",
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_middle/src/mir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1340,7 +1340,7 @@ impl<O> AssertKind<O> {
}

/// Format the message arguments for the `assert(cond, msg..)` terminator in MIR printing.
fn fmt_assert_args<W: Write>(&self, f: &mut W) -> fmt::Result
pub fn fmt_assert_args<W: Write>(&self, f: &mut W) -> fmt::Result
where
O: Debug,
{
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_session/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -816,7 +816,7 @@ fn default_configuration(sess: &Session) -> CrateConfig {
ret.reserve(6); // the minimum number of insertions
// Target bindings.
ret.insert((sym::target_os, Some(Symbol::intern(os))));
if let Some(ref fam) = sess.target.os_family {
for fam in &sess.target.families {
ret.insert((sym::target_family, Some(Symbol::intern(fam))));
if fam == "windows" {
ret.insert((sym::windows, None));
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_target/src/spec/apple_base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub fn opts(os: &str) -> TargetOptions {
function_sections: false,
dynamic_linking: true,
executables: true,
os_family: Some("unix".to_string()),
families: vec!["unix".to_string()],
is_like_osx: true,
dwarf_version: Some(2),
has_rpath: true,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_target/src/spec/dragonfly_base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ pub fn opts() -> TargetOptions {
os: "dragonfly".to_string(),
dynamic_linking: true,
executables: true,
os_family: Some("unix".to_string()),
families: vec!["unix".to_string()],
linker_is_gnu: true,
has_rpath: true,
position_independent_executables: true,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_target/src/spec/freebsd_base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ pub fn opts() -> TargetOptions {
os: "freebsd".to_string(),
dynamic_linking: true,
executables: true,
os_family: Some("unix".to_string()),
families: vec!["unix".to_string()],
linker_is_gnu: true,
has_rpath: true,
position_independent_executables: true,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_target/src/spec/fuchsia_base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pub fn opts() -> TargetOptions {
linker: Some("rust-lld".to_owned()),
dynamic_linking: true,
executables: true,
os_family: Some("unix".to_string()),
families: vec!["unix".to_string()],
is_like_fuchsia: true,
linker_is_gnu: true,
pre_link_args,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_target/src/spec/haiku_base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ pub fn opts() -> TargetOptions {
os: "haiku".to_string(),
dynamic_linking: true,
executables: true,
os_family: Some("unix".to_string()),
families: vec!["unix".to_string()],
relro_level: RelroLevel::Full,
linker_is_gnu: true,
..Default::default()
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_target/src/spec/illumos_base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub fn opts() -> TargetOptions {
dynamic_linking: true,
executables: true,
has_rpath: true,
os_family: Some("unix".to_string()),
families: vec!["unix".to_string()],
is_like_solaris: true,
limit_rdylib_exports: false, // Linker doesn't support this
eliminate_frame_pointer: false,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_target/src/spec/l4re_base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub fn opts() -> TargetOptions {
executables: true,
panic_strategy: PanicStrategy::Abort,
linker: Some("ld".to_string()),
os_family: Some("unix".to_string()),
families: vec!["unix".to_string()],
..Default::default()
}
}
2 changes: 1 addition & 1 deletion compiler/rustc_target/src/spec/linux_base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ pub fn opts() -> TargetOptions {
os: "linux".to_string(),
dynamic_linking: true,
executables: true,
os_family: Some("unix".to_string()),
families: vec!["unix".to_string()],
linker_is_gnu: true,
has_rpath: true,
position_independent_executables: true,
Expand Down
32 changes: 19 additions & 13 deletions compiler/rustc_target/src/spec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1042,8 +1042,12 @@ pub struct TargetOptions {
pub staticlib_prefix: String,
/// String to append to the name of every static library. Defaults to ".a".
pub staticlib_suffix: String,
/// OS family to use for conditional compilation. Valid options: "unix", "windows".
pub os_family: Option<String>,
/// Values of the `target_family` cfg set for this target.
///
/// Common options are: "unix", "windows". Defaults to no families.
///
/// See https://doc.rust-lang.org/reference/conditional-compilation.html#target_family
pub families: Vec<String>,
/// Whether the target toolchain's ABI supports returning small structs as an integer.
pub abi_return_struct_as_int: bool,
/// Whether the target toolchain is like macOS's. Only useful for compiling against iOS/macOS,
Expand Down Expand Up @@ -1293,7 +1297,7 @@ impl Default for TargetOptions {
exe_suffix: String::new(),
staticlib_prefix: "lib".to_string(),
staticlib_suffix: ".a".to_string(),
os_family: None,
families: Vec::new(),
abi_return_struct_as_int: false,
is_like_osx: false,
is_like_solaris: false,
Expand Down Expand Up @@ -1605,14 +1609,6 @@ impl Target {
.map(|s| s.to_string() );
}
} );
($key_name:ident = $json_name:expr, optional) => ( {
let name = $json_name;
if let Some(o) = obj.find(name) {
base.$key_name = o
.as_string()
.map(|s| s.to_string() );
}
} );
($key_name:ident, LldFlavor) => ( {
let name = (stringify!($key_name)).replace("_", "-");
obj.find(&name[..]).and_then(|o| o.as_string().and_then(|s| {
Expand Down Expand Up @@ -1759,6 +1755,16 @@ impl Target {
Some(Ok(()))
})).unwrap_or(Ok(()))
} );
($key_name:ident, TargetFamilies) => ( {
let value = obj.find("target-family");
if let Some(v) = value.and_then(Json::as_array) {
base.$key_name = v.iter()
.map(|a| a.as_string().unwrap().to_string())
.collect();
} else if let Some(v) = value.and_then(Json::as_string) {
base.$key_name = vec![v.to_string()];
}
} );
}

if let Some(s) = obj.find("target-endian").and_then(Json::as_string) {
Expand Down Expand Up @@ -1802,7 +1808,7 @@ impl Target {
key!(exe_suffix);
key!(staticlib_prefix);
key!(staticlib_suffix);
key!(os_family = "target-family", optional);
key!(families, TargetFamilies);
key!(abi_return_struct_as_int, bool);
key!(is_like_osx, bool);
key!(is_like_solaris, bool);
Expand Down Expand Up @@ -2042,7 +2048,7 @@ impl ToJson for Target {
target_option_val!(exe_suffix);
target_option_val!(staticlib_prefix);
target_option_val!(staticlib_suffix);
target_option_val!(os_family, "target-family");
target_option_val!(families, "target-family");
target_option_val!(abi_return_struct_as_int);
target_option_val!(is_like_osx);
target_option_val!(is_like_solaris);
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_target/src/spec/netbsd_base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ pub fn opts() -> TargetOptions {
os: "netbsd".to_string(),
dynamic_linking: true,
executables: true,
os_family: Some("unix".to_string()),
families: vec!["unix".to_string()],
linker_is_gnu: true,
no_default_libraries: false,
has_rpath: true,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_target/src/spec/openbsd_base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ pub fn opts() -> TargetOptions {
os: "openbsd".to_string(),
dynamic_linking: true,
executables: true,
os_family: Some("unix".to_string()),
families: vec!["unix".to_string()],
linker_is_gnu: true,
has_rpath: true,
abi_return_struct_as_int: true,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_target/src/spec/redox_base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ pub fn opts() -> TargetOptions {
env: "relibc".to_string(),
dynamic_linking: true,
executables: true,
os_family: Some("unix".to_string()),
families: vec!["unix".to_string()],
linker_is_gnu: true,
has_rpath: true,
position_independent_executables: true,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_target/src/spec/solaris_base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ pub fn opts() -> TargetOptions {
dynamic_linking: true,
executables: true,
has_rpath: true,
os_family: Some("unix".to_string()),
families: vec!["unix".to_string()],
is_like_solaris: true,
limit_rdylib_exports: false, // Linker doesn't support this
eh_frame_header: false,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_target/src/spec/vxworks_base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ pub fn opts() -> TargetOptions {
exe_suffix: ".vxe".to_string(),
dynamic_linking: true,
executables: true,
os_family: Some("unix".to_string()),
families: vec!["unix".to_string()],
linker_is_gnu: true,
has_rpath: true,
has_elf_tls: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ pub fn target() -> Target {
is_like_emscripten: true,
panic_strategy: PanicStrategy::Unwind,
post_link_args,
os_family: Some("unix".to_string()),
families: vec!["unix".to_string()],
..options
};
Target {
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_target/src/spec/wasm_base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ pub fn options() -> TargetOptions {

TargetOptions {
is_like_wasm: true,
families: vec!["wasm".to_string()],

// we allow dynamic linking, but only cdylibs. Basically we allow a
// final library artifact that exports some symbols (a wasm module) but
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_target/src/spec/windows_gnu_base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ pub fn opts() -> TargetOptions {
dll_prefix: String::new(),
dll_suffix: ".dll".to_string(),
exe_suffix: ".exe".to_string(),
os_family: Some("windows".to_string()),
families: vec!["windows".to_string()],
is_like_windows: true,
allows_weak_linkage: false,
pre_link_args,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_target/src/spec/windows_msvc_base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub fn opts() -> TargetOptions {
exe_suffix: ".exe".to_string(),
staticlib_prefix: String::new(),
staticlib_suffix: ".lib".to_string(),
os_family: Some("windows".to_string()),
families: vec!["windows".to_string()],
crt_static_allows_dylibs: true,
crt_static_respected: true,
requires_uwtable: true,
Expand Down
6 changes: 2 additions & 4 deletions compiler/rustc_typeck/src/astconv/generics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -278,9 +278,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
// another. This is an error. However, if we already know that
// the arguments don't match up with the parameters, we won't issue
// an additional error, as the user already knows what's wrong.
if arg_count.correct.is_ok()
&& arg_count.explicit_late_bound == ExplicitLateBound::No
{
if arg_count.correct.is_ok() {
// We're going to iterate over the parameters to sort them out, and
// show that order to the user as a possible order for the parameters
let mut param_types_present = defs
Expand Down Expand Up @@ -462,7 +460,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
}

if silent {
return false;
return true;
}

if provided > expected_max {
Expand Down
16 changes: 10 additions & 6 deletions compiler/rustc_typeck/src/check/fn_ctxt/_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1282,6 +1282,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {

let mut infer_args_for_err = FxHashSet::default();

let mut explicit_late_bound = ExplicitLateBound::No;
for &PathSeg(def_id, index) in &path_segs {
let seg = &segments[index];
let generics = tcx.generics_of(def_id);
Expand All @@ -1290,17 +1291,20 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
// parameter internally, but we don't allow users to specify the
// parameter's value explicitly, so we have to do some error-
// checking here.
if let GenericArgCountResult {
correct: Err(GenericArgCountMismatch { reported: Some(_), .. }),
..
} = <dyn AstConv<'_>>::check_generic_arg_count_for_call(
let arg_count = <dyn AstConv<'_>>::check_generic_arg_count_for_call(
tcx,
span,
def_id,
&generics,
seg,
IsMethodCall::No,
) {
);

if let ExplicitLateBound::Yes = arg_count.explicit_late_bound {
explicit_late_bound = ExplicitLateBound::Yes;
}

if let Err(GenericArgCountMismatch { reported: Some(_), .. }) = arg_count.correct {
infer_args_for_err.insert(index);
self.set_tainted_by_errors(); // See issue #53251.
}
Expand Down Expand Up @@ -1357,7 +1361,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
let ty = tcx.type_of(def_id);

let arg_count = GenericArgCountResult {
explicit_late_bound: ExplicitLateBound::No,
explicit_late_bound,
correct: if infer_args_for_err.is_empty() {
Ok(())
} else {
Expand Down
2 changes: 1 addition & 1 deletion library/core/src/hint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ pub fn spin_loop() {
#[cfg(target_arch = "aarch64")]
{
// SAFETY: the `cfg` attr ensures that we only execute this on aarch64 targets.
unsafe { crate::arch::aarch64::__yield() };
unsafe { crate::arch::aarch64::__isb(crate::arch::aarch64::SY) };
}
#[cfg(target_arch = "arm")]
{
Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/cfg/cfg-family.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// run-pass
// build-pass
// pretty-expanded FIXME #23616
// ignore-wasm32-bare no target_family
// ignore-wasm32-bare no bare family
// ignore-sgx

#[cfg(windows)]
Expand Down
7 changes: 5 additions & 2 deletions src/test/ui/cfg/cfg-target-family.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// run-pass
// ignore-wasm32-bare no target_family
// build-pass
// ignore-sgx

// pretty-expanded FIXME #23616
Expand All @@ -11,3 +10,7 @@ pub fn main() {
#[cfg(target_family = "unix")]
pub fn main() {
}

#[cfg(target_family="wasm")]
pub fn main() {
}
17 changes: 17 additions & 0 deletions src/test/ui/const-generics/issues/issue-83466.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// regression test for #83466- tests that generic arg mismatch errors between
// consts and types are not supressed when there are explicit late bound lifetimes

struct S;
impl S {
fn func<'a, U>(self) -> U {
todo!()
}
}
fn dont_crash<'a, U>() {
S.func::<'a, 10_u32>()
//~^ WARNING cannot specify lifetime arguments explicitly if late bound lifetime parameters are present
//~^^ WARNING this was previously accepted by
//~^^^ ERROR constant provided when a type was expected [E0747]
}

fn main() {}
22 changes: 22 additions & 0 deletions src/test/ui/const-generics/issues/issue-83466.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
warning: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present
--> $DIR/issue-83466.rs:11:14
|
LL | fn func<'a, U>(self) -> U {
| -- the late bound lifetime parameter is introduced here
...
LL | S.func::<'a, 10_u32>()
| ^^
|
= note: `#[warn(late_bound_lifetime_arguments)]` on by default
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #42868 <https://github.com/rust-lang/rust/issues/42868>

error[E0747]: constant provided when a type was expected
--> $DIR/issue-83466.rs:11:18
|
LL | S.func::<'a, 10_u32>()
| ^^^^^^

error: aborting due to previous error; 1 warning emitted

For more information about this error, try `rustc --explain E0747`.
Loading