Auto merge of #103083 - Dylan-DPC:rollup-97cvwdv, r=Dylan-DPC
Rollup of 6 pull requests Successful merges: - #102773 (Use semaphores for thread parking on Apple platforms) - #102884 (resolve: Some cleanup, asserts and tests for lifetime ribs) - #102954 (Add missing checks for `doc(cfg_hide(...))`) - #102998 (Drop temporaries created in a condition, even if it's a let chain) - #103003 (Fix `suggest_floating_point_literal` ICE) - #103041 (Update cargo) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
This commit is contained in:
commit
c93ef33700
18 changed files with 610 additions and 104 deletions
11
src/test/rustdoc-ui/doc_cfg_hide.rs
Normal file
11
src/test/rustdoc-ui/doc_cfg_hide.rs
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
#![feature(doc_cfg_hide)]
|
||||
#![deny(warnings)]
|
||||
|
||||
#![doc(cfg_hide = "test")] //~ ERROR
|
||||
//~^ WARN
|
||||
#![doc(cfg_hide)] //~ ERROR
|
||||
//~^ WARN
|
||||
|
||||
#[doc(cfg_hide(doc))] //~ ERROR
|
||||
//~^ WARN
|
||||
pub fn foo() {}
|
||||
40
src/test/rustdoc-ui/doc_cfg_hide.stderr
Normal file
40
src/test/rustdoc-ui/doc_cfg_hide.stderr
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
error: this attribute can only be applied at the crate level
|
||||
--> $DIR/doc_cfg_hide.rs:9:7
|
||||
|
|
||||
LL | #[doc(cfg_hide(doc))]
|
||||
| ^^^^^^^^^^^^^
|
||||
|
|
||||
= 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 #82730 <https://github.com/rust-lang/rust/issues/82730>
|
||||
= note: read <https://doc.rust-lang.org/nightly/rustdoc/the-doc-attribute.html#at-the-crate-level> for more information
|
||||
note: the lint level is defined here
|
||||
--> $DIR/doc_cfg_hide.rs:2:9
|
||||
|
|
||||
LL | #![deny(warnings)]
|
||||
| ^^^^^^^^
|
||||
= note: `#[deny(invalid_doc_attributes)]` implied by `#[deny(warnings)]`
|
||||
help: to apply to the crate, use an inner attribute
|
||||
|
|
||||
LL | #![doc(cfg_hide(doc))]
|
||||
| ~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
error: `#[doc(cfg_hide(...)]` takes a list of attributes
|
||||
--> $DIR/doc_cfg_hide.rs:4:8
|
||||
|
|
||||
LL | #![doc(cfg_hide = "test")]
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= 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 #82730 <https://github.com/rust-lang/rust/issues/82730>
|
||||
|
||||
error: `#[doc(cfg_hide(...)]` takes a list of attributes
|
||||
--> $DIR/doc_cfg_hide.rs:6:8
|
||||
|
|
||||
LL | #![doc(cfg_hide)]
|
||||
| ^^^^^^^^
|
||||
|
|
||||
= 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 #82730 <https://github.com/rust-lang/rust/issues/82730>
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
|
|
@ -1,4 +1,6 @@
|
|||
// run-pass
|
||||
// compile-flags: -Z validate-mir
|
||||
#![feature(let_chains)]
|
||||
|
||||
use std::cell::RefCell;
|
||||
use std::convert::TryInto;
|
||||
|
|
@ -116,6 +118,58 @@ impl DropOrderCollector {
|
|||
}
|
||||
}
|
||||
|
||||
fn let_chain(&self) {
|
||||
// take the "then" branch
|
||||
if self.option_loud_drop(2).is_some() // 2
|
||||
&& self.option_loud_drop(1).is_some() // 1
|
||||
&& let Some(_d) = self.option_loud_drop(4) { // 4
|
||||
self.print(3); // 3
|
||||
}
|
||||
|
||||
// take the "else" branch
|
||||
if self.option_loud_drop(6).is_some() // 2
|
||||
&& self.option_loud_drop(5).is_some() // 1
|
||||
&& let None = self.option_loud_drop(7) { // 3
|
||||
unreachable!();
|
||||
} else {
|
||||
self.print(8); // 4
|
||||
}
|
||||
|
||||
// let exprs interspersed
|
||||
if self.option_loud_drop(9).is_some() // 1
|
||||
&& let Some(_d) = self.option_loud_drop(13) // 5
|
||||
&& self.option_loud_drop(10).is_some() // 2
|
||||
&& let Some(_e) = self.option_loud_drop(12) { // 4
|
||||
self.print(11); // 3
|
||||
}
|
||||
|
||||
// let exprs first
|
||||
if let Some(_d) = self.option_loud_drop(18) // 5
|
||||
&& let Some(_e) = self.option_loud_drop(17) // 4
|
||||
&& self.option_loud_drop(14).is_some() // 1
|
||||
&& self.option_loud_drop(15).is_some() { // 2
|
||||
self.print(16); // 3
|
||||
}
|
||||
|
||||
// let exprs last
|
||||
if self.option_loud_drop(20).is_some() // 2
|
||||
&& self.option_loud_drop(19).is_some() // 1
|
||||
&& let Some(_d) = self.option_loud_drop(23) // 5
|
||||
&& let Some(_e) = self.option_loud_drop(22) { // 4
|
||||
self.print(21); // 3
|
||||
}
|
||||
}
|
||||
|
||||
fn while_(&self) {
|
||||
let mut v = self.option_loud_drop(4);
|
||||
while let Some(_d) = v
|
||||
&& self.option_loud_drop(1).is_some()
|
||||
&& self.option_loud_drop(2).is_some() {
|
||||
self.print(3);
|
||||
v = None;
|
||||
}
|
||||
}
|
||||
|
||||
fn assert_sorted(self) {
|
||||
assert!(
|
||||
self.0
|
||||
|
|
@ -142,4 +196,14 @@ fn main() {
|
|||
let collector = DropOrderCollector::default();
|
||||
collector.match_();
|
||||
collector.assert_sorted();
|
||||
|
||||
println!("-- let chain --");
|
||||
let collector = DropOrderCollector::default();
|
||||
collector.let_chain();
|
||||
collector.assert_sorted();
|
||||
|
||||
println!("-- while --");
|
||||
let collector = DropOrderCollector::default();
|
||||
collector.while_();
|
||||
collector.assert_sorted();
|
||||
}
|
||||
|
|
|
|||
28
src/test/ui/lifetimes/unusual-rib-combinations.rs
Normal file
28
src/test/ui/lifetimes/unusual-rib-combinations.rs
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
#![feature(inline_const)]
|
||||
|
||||
struct S<'a>(&'a u8);
|
||||
fn foo() {}
|
||||
|
||||
// Paren generic args in AnonConst
|
||||
fn a() -> [u8; foo::()] {
|
||||
//~^ ERROR parenthesized type parameters may only be used with a `Fn` trait
|
||||
//~| ERROR mismatched types
|
||||
panic!()
|
||||
}
|
||||
|
||||
// Paren generic args in ConstGeneric
|
||||
fn b<const C: u8()>() {}
|
||||
//~^ ERROR parenthesized type parameters may only be used with a `Fn` trait
|
||||
|
||||
// Paren generic args in AnonymousReportError
|
||||
fn c<T = u8()>() {}
|
||||
//~^ ERROR parenthesized type parameters may only be used with a `Fn` trait
|
||||
//~| ERROR defaults for type parameters are only allowed in
|
||||
//~| WARN this was previously accepted
|
||||
|
||||
// Elided lifetime in path in ConstGeneric
|
||||
fn d<const C: S>() {}
|
||||
//~^ ERROR missing lifetime specifier
|
||||
//~| ERROR `S<'static>` is forbidden as the type of a const generic parameter
|
||||
|
||||
fn main() {}
|
||||
61
src/test/ui/lifetimes/unusual-rib-combinations.stderr
Normal file
61
src/test/ui/lifetimes/unusual-rib-combinations.stderr
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
error[E0106]: missing lifetime specifier
|
||||
--> $DIR/unusual-rib-combinations.rs:24:15
|
||||
|
|
||||
LL | fn d<const C: S>() {}
|
||||
| ^ expected named lifetime parameter
|
||||
|
|
||||
help: consider introducing a named lifetime parameter
|
||||
|
|
||||
LL | fn d<'a, const C: S<'a>>() {}
|
||||
| +++ ++++
|
||||
|
||||
error[E0214]: parenthesized type parameters may only be used with a `Fn` trait
|
||||
--> $DIR/unusual-rib-combinations.rs:7:16
|
||||
|
|
||||
LL | fn a() -> [u8; foo::()] {
|
||||
| ^^^^^^^ only `Fn` traits may use parentheses
|
||||
|
||||
error[E0214]: parenthesized type parameters may only be used with a `Fn` trait
|
||||
--> $DIR/unusual-rib-combinations.rs:14:15
|
||||
|
|
||||
LL | fn b<const C: u8()>() {}
|
||||
| ^^^^ only `Fn` traits may use parentheses
|
||||
|
||||
error[E0214]: parenthesized type parameters may only be used with a `Fn` trait
|
||||
--> $DIR/unusual-rib-combinations.rs:18:10
|
||||
|
|
||||
LL | fn c<T = u8()>() {}
|
||||
| ^^^^ only `Fn` traits may use parentheses
|
||||
|
||||
error: defaults for type parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions
|
||||
--> $DIR/unusual-rib-combinations.rs:18:6
|
||||
|
|
||||
LL | fn c<T = u8()>() {}
|
||||
| ^^^^^^^^
|
||||
|
|
||||
= 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 #36887 <https://github.com/rust-lang/rust/issues/36887>
|
||||
= note: `#[deny(invalid_type_param_default)]` on by default
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/unusual-rib-combinations.rs:7:16
|
||||
|
|
||||
LL | fn a() -> [u8; foo::()] {
|
||||
| ^^^^^^^ expected `usize`, found fn item
|
||||
|
|
||||
= note: expected type `usize`
|
||||
found fn item `fn() {foo}`
|
||||
|
||||
error: `S<'static>` is forbidden as the type of a const generic parameter
|
||||
--> $DIR/unusual-rib-combinations.rs:24:15
|
||||
|
|
||||
LL | fn d<const C: S>() {}
|
||||
| ^
|
||||
|
|
||||
= note: the only supported types are integers, `bool` and `char`
|
||||
= help: more complex types are supported with `#![feature(adt_const_params)]`
|
||||
|
||||
error: aborting due to 7 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0106, E0214, E0308.
|
||||
For more information about an error, try `rustc --explain E0106`.
|
||||
16
src/test/ui/traits/issue-102989.rs
Normal file
16
src/test/ui/traits/issue-102989.rs
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
// normalize-stderr-test "loaded from .*libcore-.*.rlib" -> "loaded from SYSROOT/libcore-*.rlib"
|
||||
|
||||
#![feature(lang_items)]
|
||||
#[lang="sized"]
|
||||
trait Sized { } //~ ERROR found duplicate lang item `sized`
|
||||
|
||||
fn ref_Struct(self: &Struct, f: &u32) -> &u32 {
|
||||
//~^ ERROR `self` parameter is only allowed in associated functions
|
||||
//~| ERROR cannot find type `Struct` in this scope
|
||||
//~| ERROR mismatched types
|
||||
let x = x << 1;
|
||||
//~^ ERROR the size for values of type `{integer}` cannot be known at compilation time
|
||||
//~| ERROR cannot find value `x` in this scope
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
59
src/test/ui/traits/issue-102989.stderr
Normal file
59
src/test/ui/traits/issue-102989.stderr
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
error: `self` parameter is only allowed in associated functions
|
||||
--> $DIR/issue-102989.rs:7:15
|
||||
|
|
||||
LL | fn ref_Struct(self: &Struct, f: &u32) -> &u32 {
|
||||
| ^^^^ not semantically valid as function parameter
|
||||
|
|
||||
= note: associated functions are those in `impl` or `trait` definitions
|
||||
|
||||
error[E0412]: cannot find type `Struct` in this scope
|
||||
--> $DIR/issue-102989.rs:7:22
|
||||
|
|
||||
LL | fn ref_Struct(self: &Struct, f: &u32) -> &u32 {
|
||||
| ^^^^^^ not found in this scope
|
||||
|
||||
error[E0425]: cannot find value `x` in this scope
|
||||
--> $DIR/issue-102989.rs:11:13
|
||||
|
|
||||
LL | let x = x << 1;
|
||||
| ^ help: a local variable with a similar name exists: `f`
|
||||
|
||||
error[E0152]: found duplicate lang item `sized`
|
||||
--> $DIR/issue-102989.rs:5:1
|
||||
|
|
||||
LL | trait Sized { }
|
||||
| ^^^^^^^^^^^
|
||||
|
|
||||
= note: the lang item is first defined in crate `core` (which `std` depends on)
|
||||
= note: first definition in `core` loaded from SYSROOT/libcore-*.rlib
|
||||
= note: second definition in the local crate (`issue_102989`)
|
||||
|
||||
error[E0277]: the size for values of type `{integer}` cannot be known at compilation time
|
||||
--> $DIR/issue-102989.rs:11:15
|
||||
|
|
||||
LL | let x = x << 1;
|
||||
| ^^ doesn't have a size known at compile-time
|
||||
|
|
||||
= help: the trait `std::marker::Sized` is not implemented for `{integer}`
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/issue-102989.rs:7:42
|
||||
|
|
||||
LL | fn ref_Struct(self: &Struct, f: &u32) -> &u32 {
|
||||
| ---------- ^^^^ expected `&u32`, found `()`
|
||||
| |
|
||||
| implicitly returns `()` as its body has no tail or `return` expression
|
||||
|
|
||||
note: consider returning one of these bindings
|
||||
--> $DIR/issue-102989.rs:7:30
|
||||
|
|
||||
LL | fn ref_Struct(self: &Struct, f: &u32) -> &u32 {
|
||||
| ^
|
||||
...
|
||||
LL | let x = x << 1;
|
||||
| ^
|
||||
|
||||
error: aborting due to 6 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0152, E0277, E0308, E0412, E0425.
|
||||
For more information about an error, try `rustc --explain E0152`.
|
||||
Loading…
Add table
Add a link
Reference in a new issue