Skip to content

Commit

Permalink
Auto merge of rust-lang#123585 - matthiaskrgr:rollup-dexaj7a, r=matth…
Browse files Browse the repository at this point in the history
…iaskrgr

Rollup of 4 pull requests

Successful merges:

 - rust-lang#123410 (Relax framework linking test)
 - rust-lang#123446 (Fix incorrect 'llvm_target' value used on watchOS target)
 - rust-lang#123579 (add some more tests)
 - rust-lang#123581 (Add `f16` and `f128` to rustdoc's `PrimitiveType`)

r? `@ghost`
`@rustbot` modify labels: rollup
  • Loading branch information
bors committed Apr 7, 2024
2 parents 0e3235f + 549d85d commit 8f2c255
Show file tree
Hide file tree
Showing 19 changed files with 279 additions and 6 deletions.
5 changes: 5 additions & 0 deletions compiler/rustc_target/src/spec/base/apple/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,11 @@ fn watchos_deployment_target() -> (u32, u32) {
from_set_deployment_target("WATCHOS_DEPLOYMENT_TARGET").unwrap_or((5, 0))
}

pub fn watchos_llvm_target(arch: Arch) -> String {
let (major, minor) = watchos_deployment_target();
format!("{}-apple-watchos{}.{}.0", arch.target_name(), major, minor)
}

pub fn watchos_sim_llvm_target(arch: Arch) -> String {
let (major, minor) = watchos_deployment_target();
format!("{}-apple-watchos{}.{}.0-simulator", arch.target_name(), major, minor)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
use crate::spec::base::apple::{opts, Arch};
use crate::spec::base::apple::{opts, watchos_llvm_target, Arch};
use crate::spec::{Target, TargetOptions};

pub fn target() -> Target {
let base = opts("watchos", Arch::Arm64_32);
let arch = Arch::Arm64_32;
let base = opts("watchos", arch);
Target {
llvm_target: "arm64_32-apple-watchos".into(),
llvm_target: watchos_llvm_target(arch).into(),
metadata: crate::spec::TargetMetadata {
description: None,
tier: None,
Expand Down
4 changes: 4 additions & 0 deletions src/librustdoc/clean/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1797,8 +1797,10 @@ impl PrimitiveType {
sym::bool => Some(PrimitiveType::Bool),
sym::char => Some(PrimitiveType::Char),
sym::str => Some(PrimitiveType::Str),
sym::f16 => Some(PrimitiveType::F16),
sym::f32 => Some(PrimitiveType::F32),
sym::f64 => Some(PrimitiveType::F64),
sym::f128 => Some(PrimitiveType::F128),
sym::array => Some(PrimitiveType::Array),
sym::slice => Some(PrimitiveType::Slice),
sym::tuple => Some(PrimitiveType::Tuple),
Expand Down Expand Up @@ -1831,8 +1833,10 @@ impl PrimitiveType {
U32 => single(SimplifiedType::Uint(UintTy::U32)),
U64 => single(SimplifiedType::Uint(UintTy::U64)),
U128 => single(SimplifiedType::Uint(UintTy::U128)),
F16 => single(SimplifiedType::Float(FloatTy::F16)),
F32 => single(SimplifiedType::Float(FloatTy::F32)),
F64 => single(SimplifiedType::Float(FloatTy::F64)),
F128 => single(SimplifiedType::Float(FloatTy::F128)),
Str => single(SimplifiedType::Str),
Bool => single(SimplifiedType::Bool),
Char => single(SimplifiedType::Char),
Expand Down
4 changes: 4 additions & 0 deletions src/librustdoc/passes/collect_intra_doc_links.rs
Original file line number Diff line number Diff line change
Expand Up @@ -536,8 +536,10 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> {
I64 => tcx.types.i64,
I128 => tcx.types.i128,
Isize => tcx.types.isize,
F16 => tcx.types.f16,
F32 => tcx.types.f32,
F64 => tcx.types.f64,
F128 => tcx.types.f128,
U8 => tcx.types.u8,
U16 => tcx.types.u16,
U32 => tcx.types.u32,
Expand Down Expand Up @@ -2196,8 +2198,10 @@ fn resolve_primitive(path_str: &str, ns: Namespace) -> Option<Res> {
"u32" => U32,
"u64" => U64,
"u128" => U128,
"f16" => F16,
"f32" => F32,
"f64" => F64,
"f128" => F128,
"char" => Char,
"bool" | "true" | "false" => Bool,
"str" | "&str" => Str,
Expand Down
14 changes: 13 additions & 1 deletion tests/rustdoc/primitive/primitive.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#![crate_name = "foo"]

#![feature(rustc_attrs)]
#![feature(f16)]
#![feature(f128)]

// @has foo/index.html '//h2[@id="primitives"]' 'Primitive Types'
// @has foo/index.html '//a[@href="primitive.i32.html"]' 'i32'
Expand All @@ -13,9 +15,19 @@
// @!has foo/index.html '//span' '🔒'
#[rustc_doc_primitive = "i32"]
/// this is a test!
mod i32{}
mod i32 {}

// @has foo/primitive.bool.html '//section[@id="main-content"]//div[@class="docblock"]//p' 'hello'
#[rustc_doc_primitive = "bool"]
/// hello
mod bool {}

// @has foo/primitive.f16.html '//section[@id="main-content"]//div[@class="docblock"]//p' 'hello'
#[rustc_doc_primitive = "f16"]
/// hello
mod f16 {}

// @has foo/primitive.f128.html '//section[@id="main-content"]//div[@class="docblock"]//p' 'hello'
#[rustc_doc_primitive = "f128"]
/// hello
mod f128 {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// ICE unknown alias DefKind: AnonConst
// issue: rust-lang/rust#116710
#![feature(generic_const_exprs)]
#![allow(incomplete_features)]

struct A<const N: u32 = 1, const M: u32 = u8>;
//~^ ERROR expected value, found builtin type `u8`

trait Trait {}
impl<const N: u32> Trait for A<N> {}

impl<const N: u32> Trait for A<N> {}
//~^ ERROR conflicting implementations of trait `Trait` for type `A<_>`

pub fn main() {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
error[E0423]: expected value, found builtin type `u8`
--> $DIR/unknown-alias-defkind-anonconst-ice-116710.rs:6:43
|
LL | struct A<const N: u32 = 1, const M: u32 = u8>;
| ^^ not a value

error[E0119]: conflicting implementations of trait `Trait` for type `A<_>`
--> $DIR/unknown-alias-defkind-anonconst-ice-116710.rs:12:1
|
LL | impl<const N: u32> Trait for A<N> {}
| --------------------------------- first implementation here
LL |
LL | impl<const N: u32> Trait for A<N> {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `A<_>`

error: aborting due to 2 previous errors

Some errors have detailed explanations: E0119, E0423.
For more information about an error, try `rustc --explain E0119`.
19 changes: 19 additions & 0 deletions tests/ui/generic-const-items/assoc-const-no-infer-ice-115806.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// ICE: assertion failed: !value.has_infer()
// issue: rust-lang/rust#115806
#![feature(associated_const_equality)]
#![allow(incomplete_features)]

pub struct NoPin;

impl<TA> Pins<TA> for NoPin {}

pub trait PinA<PER> {
const A: &'static () = &();
}

pub trait Pins<USART> {}

impl<USART, T> Pins<USART> for T where T: PinA<USART, A = { &() }> {}
//~^ ERROR conflicting implementations of trait `Pins<_>` for type `NoPin`

pub fn main() {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
error[E0119]: conflicting implementations of trait `Pins<_>` for type `NoPin`
--> $DIR/assoc-const-no-infer-ice-115806.rs:16:1
|
LL | impl<TA> Pins<TA> for NoPin {}
| --------------------------- first implementation here
...
LL | impl<USART, T> Pins<USART> for T where T: PinA<USART, A = { &() }> {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `NoPin`
|
= note: downstream crates may implement trait `PinA<_>` for type `NoPin`

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0119`.
42 changes: 42 additions & 0 deletions tests/ui/impl-trait/failed-to-resolve-instance-ice-105488.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// ICE failed to resolve instance for <fn() -> impl MyFnOnce ...
// issue: rust-lang/rust#105488
//@ build-fail
//~^^^ ERROR overflow evaluating the requirement `fn() -> impl MyFnOnce

pub trait MyFnOnce {
type Output;

fn call_my_fn_once(self) -> Self::Output;
}

pub struct WrapFnOnce<F>(F);

impl<F: FnOnce() -> D, D: MyFnOnce> MyFnOnce for WrapFnOnce<F> {
type Output = D::Output;

fn call_my_fn_once(self) -> Self::Output {
D::call_my_fn_once(self.0())
}
}

impl<F: FnOnce() -> D, D: MyFnOnce> MyFnOnce for F {
type Output = D::Output;

fn call_my_fn_once(self) -> Self::Output {
D::call_my_fn_once(self())
}
}

pub fn my_fn_1() -> impl MyFnOnce {
my_fn_2
}

pub fn my_fn_2() -> impl MyFnOnce {
WrapFnOnce(my_fn_1)
}

fn main() {
let v = my_fn_1();

let _ = v.call_my_fn_once();
}
16 changes: 16 additions & 0 deletions tests/ui/impl-trait/failed-to-resolve-instance-ice-105488.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
error[E0275]: overflow evaluating the requirement `fn() -> impl MyFnOnce {my_fn_2}: MyFnOnce`
|
= help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`failed_to_resolve_instance_ice_105488`)
note: required for `WrapFnOnce<fn() -> impl MyFnOnce {my_fn_1}>` to implement `MyFnOnce`
--> $DIR/failed-to-resolve-instance-ice-105488.rs:14:37
|
LL | impl<F: FnOnce() -> D, D: MyFnOnce> MyFnOnce for WrapFnOnce<F> {
| -------- ^^^^^^^^ ^^^^^^^^^^^^^
| |
| unsatisfied trait bound introduced here
= note: 126 redundant requirements hidden
= note: required for `WrapFnOnce<fn() -> impl MyFnOnce {my_fn_1}>` to implement `MyFnOnce`

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0275`.
20 changes: 20 additions & 0 deletions tests/ui/impl-trait/failed-to-resolve-instance-ice-123145.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// ICE failed to resolve instance for ...
// issue: rust-lang/rust#123145
//@ build-fail
//~^^^ ERROR overflow evaluating the requirement `(fn() -> impl Handler

trait Handler {
fn handle(&self) {}
}

impl<H: Handler, F: Fn() -> H> Handler for F {}

impl<L: Handler> Handler for (L,) {}

fn one() -> impl Handler {
(one,)
}

fn main() {
one.handle();
}
15 changes: 15 additions & 0 deletions tests/ui/impl-trait/failed-to-resolve-instance-ice-123145.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
error[E0275]: overflow evaluating the requirement `(fn() -> impl Handler {one},): Handler`
|
note: required for `fn() -> impl Handler {one}` to implement `Handler`
--> $DIR/failed-to-resolve-instance-ice-123145.rs:10:32
|
LL | impl<H: Handler, F: Fn() -> H> Handler for F {}
| ------- ^^^^^^^ ^
| |
| unsatisfied trait bound introduced here
= note: 2 redundant requirements hidden
= note: required for `fn() -> impl Handler {one}` to implement `Handler`

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0275`.
17 changes: 17 additions & 0 deletions tests/ui/layout/base-layout-is-sized-ice-123078.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// ICE !base.layout().is_sized()
// issue: rust-lang/rust#123078

struct S {
a: [u8],
//~^ ERROR the size for values of type `[u8]` cannot be known at compilation time
b: (),
}

const C: S = unsafe { std::mem::transmute(()) };
//~^ ERROR cannot transmute between types of different sizes, or dependently-sized types
const _: [(); {
C;
0
}] = [];

pub fn main() {}
31 changes: 31 additions & 0 deletions tests/ui/layout/base-layout-is-sized-ice-123078.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
error[E0277]: the size for values of type `[u8]` cannot be known at compilation time
--> $DIR/base-layout-is-sized-ice-123078.rs:5:8
|
LL | a: [u8],
| ^^^^ doesn't have a size known at compile-time
|
= help: the trait `Sized` is not implemented for `[u8]`
= note: only the last field of a struct may have a dynamically sized type
= help: change the field's type to have a statically known size
help: borrowed types always have a statically known size
|
LL | a: &[u8],
| +
help: the `Box` type always has a statically known size and allocates its contents in the heap
|
LL | a: Box<[u8]>,
| ++++ +

error[E0512]: cannot transmute between types of different sizes, or dependently-sized types
--> $DIR/base-layout-is-sized-ice-123078.rs:10:23
|
LL | const C: S = unsafe { std::mem::transmute(()) };
| ^^^^^^^^^^^^^^^^^^^
|
= note: source type: `()` (0 bits)
= note: target type: `S` (this type does not have a fixed size)

error: aborting due to 2 previous errors

Some errors have detailed explanations: E0277, E0512.
For more information about an error, try `rustc --explain E0277`.
10 changes: 10 additions & 0 deletions tests/ui/layout/issue-unsized-tail-restatic-ice-122488.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// ICE Unexpected unsized type tail: &ReStatic [u8]
// issue: rust-lang/rust#122488
use std::ops::Deref;

struct ArenaSet<U: Deref, V: ?Sized = <U as Deref>::Target>(V, U);
//~^ ERROR the size for values of type `V` cannot be known at compilation time

const DATA: *const ArenaSet<Vec<u8>> = std::ptr::null_mut();

pub fn main() {}
27 changes: 27 additions & 0 deletions tests/ui/layout/issue-unsized-tail-restatic-ice-122488.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
error[E0277]: the size for values of type `V` cannot be known at compilation time
--> $DIR/issue-unsized-tail-restatic-ice-122488.rs:5:61
|
LL | struct ArenaSet<U: Deref, V: ?Sized = <U as Deref>::Target>(V, U);
| -------------------------------- ^ doesn't have a size known at compile-time
| |
| this type parameter needs to be `Sized`
|
= note: only the last field of a struct may have a dynamically sized type
= help: change the field's type to have a statically known size
help: consider removing the `?Sized` bound to make the type parameter `Sized`
|
LL - struct ArenaSet<U: Deref, V: ?Sized = <U as Deref>::Target>(V, U);
LL + struct ArenaSet<U: Deref, V = <U as Deref>::Target>(V, U);
|
help: borrowed types always have a statically known size
|
LL | struct ArenaSet<U: Deref, V: ?Sized = <U as Deref>::Target>(&V, U);
| +
help: the `Box` type always has a statically known size and allocates its contents in the heap
|
LL | struct ArenaSet<U: Deref, V: ?Sized = <U as Deref>::Target>(Box<V>, U);
| ++++ +

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0277`.
2 changes: 1 addition & 1 deletion tests/ui/linkage-attr/framework.omit.stderr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
error: linking with `cc` failed: exit status: 1
error: linking with `LINKER` failed: exit status: 1
|
ld: Undefined symbols:
_CFRunLoopGetTypeID, referenced from:
Expand Down
4 changes: 3 additions & 1 deletion tests/ui/linkage-attr/framework.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
//@ [weak]run-pass
//@ [both]run-pass

// The linker's exact error output changes between Xcode versions.
// The linker's exact error output changes between Xcode versions, depends on
// linker invocation details, and the linker sometimes outputs more warnings.
//@ compare-output-lines-by-subset
//@ normalize-stderr-test: "linking with `.*` failed" -> "linking with `LINKER` failed"
//@ normalize-stderr-test: "Undefined symbols for architecture .*" -> "ld: Undefined symbols:"
//@ normalize-stderr-test: "._CFRunLoopGetTypeID.," -> "_CFRunLoopGetTypeID,"

Expand Down

0 comments on commit 8f2c255

Please sign in to comment.