Auto merge of #87242 - JohnTitor:rollup-t9rmwpo, r=JohnTitor

Rollup of 8 pull requests

Successful merges:

 - #86763 (Add a regression test for issue-63355)
 - #86814 (Recover from a misplaced inner doc comment)
 - #86843 (Check that const parameters of trait methods have compatible types)
 - #86889 (rustdoc: Cleanup ExternalCrate)
 - #87092 (Remove nondeterminism in multiple-definitions test)
 - #87170 (Add diagnostic items for Clippy)
 - #87183 (fix typo in compile_fail doctest)
 - #87205 (rustc_middle: remove redundant clone)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
This commit is contained in:
bors 2021-07-18 08:15:17 +00:00
commit 5a8a44196b
34 changed files with 352 additions and 101 deletions

View file

@ -0,0 +1,25 @@
// Regression test for the ICE described in #86820.
#![allow(unused,dead_code)]
use std::ops::BitAnd;
const C: fn() = || is_set();
fn is_set() {
0xffu8.bit::<0>();
}
trait Bits {
fn bit<const I : u8>(self) -> bool;
//~^ NOTE: the const parameter `I` has type `usize`, but the declaration in trait `Bits::bit` has type `u8`
}
impl Bits for u8 {
fn bit<const I : usize>(self) -> bool {
//~^ ERROR: method `bit` has an incompatible const parameter type for trait [E0053]
let i = 1 << I;
let mask = u8::from(i);
mask & self == mask
}
}
fn main() {}

View file

@ -0,0 +1,15 @@
error[E0053]: method `bit` has an incompatible const parameter type for trait
--> $DIR/issue-86820.rs:17:18
|
LL | fn bit<const I : usize>(self) -> bool {
| ^
|
note: the const parameter `I` has type `usize`, but the declaration in trait `Bits::bit` has type `u8`
--> $DIR/issue-86820.rs:12:18
|
LL | fn bit<const I : u8>(self) -> bool;
| ^
error: aborting due to previous error
For more information about this error, try `rustc --explain E0053`.

View file

@ -0,0 +1,11 @@
// aux-build:test-macros.rs
#[macro_use]
extern crate test_macros;
//! Inner doc comment
//~^ ERROR expected outer doc comment
#[derive(Empty)]
pub struct Foo;
fn main() {}

View file

@ -0,0 +1,11 @@
error[E0753]: expected outer doc comment
--> $DIR/issue-86781-bad-inner-doc.rs:6:1
|
LL | //! Inner doc comment
| ^^^^^^^^^^^^^^^^^^^^^
|
= note: inner doc comments like this (starting with `//!` or `/*!`) can only appear before items
error: aborting due to previous error
For more information about this error, try `rustc --explain E0753`.

View file

@ -0,0 +1,19 @@
// only-i686-pc-windows-msvc
// compile-flags: --crate-type lib --emit link
#![allow(clashing_extern_declarations)]
#![feature(raw_dylib)]
//~^ WARN the feature `raw_dylib` is incomplete
#[link(name = "foo", kind = "raw-dylib")]
extern "C" {
fn f(x: i32);
}
pub fn lib_main() {
#[link(name = "foo", kind = "raw-dylib")]
extern "stdcall" {
fn f(x: i32);
//~^ ERROR multiple declarations of external function `f` from library `foo.dll` have different calling conventions
}
unsafe { f(42); }
}

View file

@ -0,0 +1,17 @@
warning: the feature `raw_dylib` is incomplete and may not be safe to use and/or cause compiler crashes
--> $DIR/multiple-declarations.rs:4:12
|
LL | #![feature(raw_dylib)]
| ^^^^^^^^^
|
= note: `#[warn(incomplete_features)]` on by default
= note: see issue #58713 <https://github.com/rust-lang/rust/issues/58713> for more information
error: multiple declarations of external function `f` from library `foo.dll` have different calling conventions
--> $DIR/multiple-declarations.rs:14:9
|
LL | fn f(x: i32);
| ^^^^^^^^^^^^^
error: aborting due to previous error; 1 warning emitted

View file

@ -0,0 +1,50 @@
#![feature(min_type_alias_impl_trait)]
#![feature(type_alias_impl_trait)]
#![allow(incomplete_features)]
pub trait Foo {}
pub trait Bar {
type Foo: Foo;
fn foo() -> Self::Foo;
}
pub trait Baz {
type Foo: Foo;
type Bar: Bar<Foo = Self::Foo>;
fn foo() -> Self::Foo;
fn bar() -> Self::Bar;
}
impl Foo for () {}
impl Bar for () {
type Foo = FooImpl;
fn foo() -> Self::Foo {
()
}
}
// FIXME(#86731): The below is illegal use of `min_type_alias_impl_trait`
// but the compiler doesn't report it, we should fix it.
pub type FooImpl = impl Foo;
pub type BarImpl = impl Bar<Foo = FooImpl>;
//~^ ERROR: type mismatch resolving `<() as Bar>::Foo == ()`
impl Baz for () {
type Foo = FooImpl;
type Bar = BarImpl;
fn foo() -> Self::Foo {
()
}
fn bar() -> Self::Bar {
()
}
}
fn main() {}

View file

@ -0,0 +1,14 @@
error[E0271]: type mismatch resolving `<() as Bar>::Foo == ()`
--> $DIR/issue-63355.rs:34:20
|
LL | pub type FooImpl = impl Foo;
| -------- the found opaque type
LL | pub type BarImpl = impl Bar<Foo = FooImpl>;
| ^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found opaque type
|
= note: expected unit type `()`
found opaque type `impl Foo`
error: aborting due to previous error
For more information about this error, try `rustc --explain E0271`.