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 5 pull requests #96548

Merged
merged 11 commits into from
Apr 29, 2022
Merged
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
23 changes: 23 additions & 0 deletions compiler/rustc_codegen_ssa/src/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1700,6 +1700,29 @@ fn add_linked_symbol_object(
// We handle the name decoration of COFF targets in `symbol_export.rs`, so disable the
// default mangler in `object` crate.
file.set_mangling(object::write::Mangling::None);

// Add feature flags to the object file. On MSVC this is optional but LLD will complain if
// not present.
let mut feature = 0;

if file.architecture() == object::Architecture::I386 {
// Indicate that all SEH handlers are registered in .sxdata section.
// We don't have generate any code, so we don't need .sxdata section but LLD still
// expects us to set this bit (see #96498).
// Reference: https://docs.microsoft.com/en-us/windows/win32/debug/pe-format
feature |= 1;
}

file.add_symbol(object::write::Symbol {
name: "@feat.00".into(),
value: feature,
size: 0,
kind: object::SymbolKind::Data,
scope: object::SymbolScope::Compilation,
weak: false,
section: object::write::SymbolSection::Absolute,
flags: object::SymbolFlags::None,
});
}

for (sym, kind) in symbols.iter() {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_target/src/spec/wasm64_unknown_unknown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ pub fn target() -> Target {
Target {
llvm_target: "wasm64-unknown-unknown".into(),
pointer_width: 64,
data_layout: "e-m:e-p:64:64-i64:64-n32:64-S128-ni:1:10:20".into(),
data_layout: "e-m:e-p:64:64-p10:8:8-p20:8:8-i64:64-n32:64-S128-ni:1:10:20".into(),
arch: "wasm64".into(),
options,
}
Expand Down
6 changes: 6 additions & 0 deletions compiler/rustc_typeck/src/check/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,12 @@ pub(super) fn check_fn<'a, 'tcx>(
DUMMY_SP,
param_env,
));
// HACK(oli-obk): we rewrite the declared return type, too, so that we don't end up inferring all
// unconstrained RPIT to have `()` as their hidden type. This would happen because further down we
// compare the ret_coercion with declared_ret_ty, and anything uninferred would be inferred to the
// opaque type itself. That again would cause writeback to assume we have a recursive call site
// and do the sadly stabilized fallback to `()`.
let declared_ret_ty = ret_ty;
fcx.ret_coercion = Some(RefCell::new(CoerceMany::new(ret_ty)));
fcx.ret_type_span = Some(decl.output.span());

Expand Down
3 changes: 2 additions & 1 deletion library/alloc/tests/c_str.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use std::borrow::Cow::{Borrowed, Owned};
use std::ffi::{c_char, CStr};
use std::ffi::CStr;
use std::os::raw::c_char;

#[test]
fn to_str() {
Expand Down
2 changes: 1 addition & 1 deletion library/std/src/collections/hash/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ use crate::sys;
/// ]);
/// ```
///
/// `HashMap` implements an [`Entry API`](#method.entry), which allows
/// `HashMap` implements an [`Entry` API](#method.entry), which allows
/// for complex methods of getting, setting, updating and removing keys and
/// their values:
///
Expand Down
9 changes: 0 additions & 9 deletions library/std/src/ffi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,15 +171,6 @@ pub use self::os_str::{OsStr, OsString};
#[stable(feature = "core_c_void", since = "1.30.0")]
pub use core::ffi::c_void;

#[unstable(feature = "core_ffi_c", issue = "94501")]
pub use core::ffi::{
c_char, c_double, c_float, c_int, c_long, c_longlong, c_schar, c_short, c_uchar, c_uint,
c_ulong, c_ulonglong, c_ushort,
};

#[unstable(feature = "c_size_t", issue = "88345")]
pub use core::ffi::{c_ptrdiff_t, c_size_t, c_ssize_t};

#[unstable(
feature = "c_variadic",
reason = "the `c_variadic` feature has not been properly tested on \
Expand Down
1 change: 0 additions & 1 deletion library/std/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,6 @@
// Only for re-exporting:
#![feature(assert_matches)]
#![feature(async_iterator)]
#![feature(c_size_t)]
#![feature(c_variadic)]
#![feature(cfg_accessible)]
#![feature(cfg_eval)]
Expand Down
8 changes: 8 additions & 0 deletions src/test/run-make/issue-96498/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# only-windows
# needs-rust-lld

-include ../../run-make-fulldeps/tools.mk

# Ensure that LLD can link
all:
$(RUSTC) -C linker=rust-lld foo.rs
4 changes: 4 additions & 0 deletions src/test/run-make/issue-96498/foo.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#![crate_type = "cdylib"]

#[no_mangle]
extern "C" fn foo() {}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ fn bar() -> impl Bar {

fn baz() -> impl Bar<Item = i32> {
//~^ ERROR type mismatch resolving `<impl Bar as Foo>::Item == i32`
//~| ERROR type mismatch resolving `<impl Bar as Foo>::Item == i32`
bar()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,6 @@ help: consider constraining the associated type `<impl Bar as Foo>::Item` to `i3
LL | fn bar() -> impl Bar<Item = i32> {
| ++++++++++++

error[E0271]: type mismatch resolving `<impl Bar as Foo>::Item == i32`
--> $DIR/impl-trait-return-missing-constraint.rs:25:34
|
LL | fn bar() -> impl Bar {
| -------- the expected opaque type
...
LL | fn baz() -> impl Bar<Item = i32> {
| __________________________________^
LL | |
LL | |
LL | | bar()
LL | | }
| |_^ expected associated type, found `i32`
|
= note: expected associated type `<impl Bar as Foo>::Item`
found type `i32`
= help: consider constraining the associated type `<impl Bar as Foo>::Item` to `i32` or calling a method that returns `<impl Bar as Foo>::Item`
= note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html
help: consider constraining the associated type `<impl Bar as Foo>::Item` to `i32`
|
LL | fn bar() -> impl Bar<Item = i32> {
| ++++++++++++

error: aborting due to 2 previous errors
error: aborting due to previous error

For more information about this error, try `rustc --explain E0271`.
1 change: 0 additions & 1 deletion src/test/ui/conservative_impl_trait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

fn will_ice(something: &u32) -> impl Iterator<Item = &u32> {
//~^ ERROR `()` is not an iterator
//~| ERROR `()` is not an iterator
}

fn main() {}
14 changes: 1 addition & 13 deletions src/test/ui/conservative_impl_trait.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,6 @@ LL | fn will_ice(something: &u32) -> impl Iterator<Item = &u32> {
|
= help: the trait `Iterator` is not implemented for `()`

error[E0277]: `()` is not an iterator
--> $DIR/conservative_impl_trait.rs:3:60
|
LL | fn will_ice(something: &u32) -> impl Iterator<Item = &u32> {
| ____________________________________________________________^
LL | |
LL | |
LL | | }
| |_^ `()` is not an iterator
|
= help: the trait `Iterator` is not implemented for `()`

error: aborting due to 2 previous errors
error: aborting due to previous error

For more information about this error, try `rustc --explain E0277`.
3 changes: 0 additions & 3 deletions src/test/ui/const-generics/defaults/rp_impl_trait_fail.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ impl<const N: u32> Trait for Uwu<N> {}

fn rawr() -> impl Trait {
//~^ error: the trait bound `Uwu<10_u32, 12_u32>: Trait` is not satisfied
//~| error: the trait bound `Uwu<10_u32, 12_u32>: Trait` is not satisfied
Uwu::<10, 12>
}

Expand All @@ -17,13 +16,11 @@ impl Traitor<1, 2> for u64 {}

fn uwu<const N: u8>() -> impl Traitor<N> {
//~^ error: the trait bound `u32: Traitor<N, N>` is not satisfied
//~| error: the trait bound `u32: Traitor<N, N>` is not satisfied
1_u32
}

fn owo() -> impl Traitor {
//~^ error: the trait bound `u64: Traitor<1_u8, 1_u8>` is not satisfied
//~| error: the trait bound `u64: Traitor<1_u8, 1_u8>` is not satisfied
1_u64
}

Expand Down
49 changes: 3 additions & 46 deletions src/test/ui/const-generics/defaults/rp_impl_trait_fail.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,8 @@ LL | fn rawr() -> impl Trait {
|
= help: the trait `Trait` is implemented for `Uwu<N>`

error[E0277]: the trait bound `Uwu<10_u32, 12_u32>: Trait` is not satisfied
--> $DIR/rp_impl_trait_fail.rs:6:25
|
LL | fn rawr() -> impl Trait {
| _________________________^
LL | |
LL | |
LL | | Uwu::<10, 12>
LL | | }
| |_^ the trait `Trait` is not implemented for `Uwu<10_u32, 12_u32>`
|
= help: the trait `Trait` is implemented for `Uwu<N>`

error[E0277]: the trait bound `u32: Traitor<N, N>` is not satisfied
--> $DIR/rp_impl_trait_fail.rs:18:26
--> $DIR/rp_impl_trait_fail.rs:17:26
|
LL | fn uwu<const N: u8>() -> impl Traitor<N> {
| ^^^^^^^^^^^^^^^ the trait `Traitor<N, N>` is not implemented for `u32`
Expand All @@ -29,23 +16,8 @@ LL | fn uwu<const N: u8>() -> impl Traitor<N> {
<u32 as Traitor<N, 2_u8>>
<u64 as Traitor<1_u8, 2_u8>>

error[E0277]: the trait bound `u32: Traitor<N, N>` is not satisfied
--> $DIR/rp_impl_trait_fail.rs:18:42
|
LL | fn uwu<const N: u8>() -> impl Traitor<N> {
| __________________________________________^
LL | |
LL | |
LL | | 1_u32
LL | | }
| |_^ the trait `Traitor<N, N>` is not implemented for `u32`
|
= help: the following other types implement trait `Traitor<N, M>`:
<u32 as Traitor<N, 2_u8>>
<u64 as Traitor<1_u8, 2_u8>>

error[E0277]: the trait bound `u64: Traitor<1_u8, 1_u8>` is not satisfied
--> $DIR/rp_impl_trait_fail.rs:24:13
--> $DIR/rp_impl_trait_fail.rs:22:13
|
LL | fn owo() -> impl Traitor {
| ^^^^^^^^^^^^ the trait `Traitor<1_u8, 1_u8>` is not implemented for `u64`
Expand All @@ -54,21 +26,6 @@ LL | fn owo() -> impl Traitor {
<u32 as Traitor<N, 2_u8>>
<u64 as Traitor<1_u8, 2_u8>>

error[E0277]: the trait bound `u64: Traitor<1_u8, 1_u8>` is not satisfied
--> $DIR/rp_impl_trait_fail.rs:24:26
|
LL | fn owo() -> impl Traitor {
| __________________________^
LL | |
LL | |
LL | | 1_u64
LL | | }
| |_^ the trait `Traitor<1_u8, 1_u8>` is not implemented for `u64`
|
= help: the following other types implement trait `Traitor<N, M>`:
<u32 as Traitor<N, 2_u8>>
<u64 as Traitor<1_u8, 2_u8>>

error: aborting due to 6 previous errors
error: aborting due to 3 previous errors

For more information about this error, try `rustc --explain E0277`.
3 changes: 0 additions & 3 deletions src/test/ui/generator/issue-88653.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,10 @@ use std::ops::Generator;

fn foo(bar: bool) -> impl Generator<(bool,)> {
//~^ ERROR: type mismatch in generator arguments [E0631]
//~| ERROR: type mismatch in generator arguments [E0631]
//~| NOTE: expected signature of `fn((bool,)) -> _`
//~| NOTE: expected signature of `fn((bool,)) -> _`
//~| NOTE: in this expansion of desugaring of `impl Trait`
|bar| {
//~^ NOTE: found signature of `fn(bool) -> _`
//~| NOTE: found signature of `fn(bool) -> _`
if bar {
yield bar;
}
Expand Down
18 changes: 1 addition & 17 deletions src/test/ui/generator/issue-88653.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,6 @@ LL | fn foo(bar: bool) -> impl Generator<(bool,)> {
LL | |bar| {
| ----- found signature of `fn(bool) -> _`

error[E0631]: type mismatch in generator arguments
--> $DIR/issue-88653.rs:8:46
|
LL | fn foo(bar: bool) -> impl Generator<(bool,)> {
| ______________________________________________^
LL | |
LL | |
LL | |
... |
LL | | |bar| {
| | ----- found signature of `fn(bool) -> _`
... |
LL | | }
LL | | }
| |_^ expected signature of `fn((bool,)) -> _`

error: aborting due to 2 previous errors
error: aborting due to previous error

For more information about this error, try `rustc --explain E0631`.
1 change: 0 additions & 1 deletion src/test/ui/generator/type-mismatch-signature-deduction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use std::ops::Generator;

fn foo() -> impl Generator<Return = i32> {
//~^ ERROR type mismatch
//~| ERROR type mismatch
|| {
if false {
return Ok(6);
Expand Down
24 changes: 4 additions & 20 deletions src/test/ui/generator/type-mismatch-signature-deduction.stderr
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
error[E0308]: mismatched types
--> $DIR/type-mismatch-signature-deduction.rs:15:9
--> $DIR/type-mismatch-signature-deduction.rs:14:9
|
LL | 5
| ^ expected enum `Result`, found integer
|
= note: expected type `Result<{integer}, _>`
found type `{integer}`
note: return type inferred to be `Result<{integer}, _>` here
--> $DIR/type-mismatch-signature-deduction.rs:10:20
--> $DIR/type-mismatch-signature-deduction.rs:9:20
|
LL | return Ok(6);
| ^^^^^

error[E0271]: type mismatch resolving `<[generator@$DIR/type-mismatch-signature-deduction.rs:8:5: 16:6] as Generator>::Return == i32`
error[E0271]: type mismatch resolving `<[generator@$DIR/type-mismatch-signature-deduction.rs:7:5: 15:6] as Generator>::Return == i32`
--> $DIR/type-mismatch-signature-deduction.rs:5:13
|
LL | fn foo() -> impl Generator<Return = i32> {
Expand All @@ -21,23 +21,7 @@ LL | fn foo() -> impl Generator<Return = i32> {
= note: expected enum `Result<{integer}, _>`
found type `i32`

error[E0271]: type mismatch resolving `<[generator@$DIR/type-mismatch-signature-deduction.rs:8:5: 16:6] as Generator>::Return == i32`
--> $DIR/type-mismatch-signature-deduction.rs:5:42
|
LL | fn foo() -> impl Generator<Return = i32> {
| __________________________________________^
LL | |
LL | |
LL | | || {
... |
LL | | }
LL | | }
| |_^ expected enum `Result`, found `i32`
|
= note: expected enum `Result<{integer}, _>`
found type `i32`

error: aborting due to 3 previous errors
error: aborting due to 2 previous errors

Some errors have detailed explanations: E0271, E0308.
For more information about an error, try `rustc --explain E0271`.
2 changes: 0 additions & 2 deletions src/test/ui/impl-trait/bound-normalization-fail.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ mod impl_trait {
/// `T::Assoc` can't be normalized any further here.
fn foo_fail<T: Trait>() -> impl FooLike<Output = T::Assoc> {
//~^ ERROR: type mismatch
//~| ERROR: type mismatch
Foo(())
}
}
Expand All @@ -42,7 +41,6 @@ mod lifetimes {
fn foo2_fail<'a, T: Trait<'a>>() -> impl FooLike<Output = T::Assoc> {
//~^ ERROR `impl Trait` return type cannot contain a projection or `Self` that references lifetimes from a parent scope
//~| ERROR: type mismatch
//~| ERROR: type mismatch
Foo(())
}
}
Expand Down
Loading