Auto merge of #94134 - matthiaskrgr:rollup-b132kjz, r=matthiaskrgr

Rollup of 10 pull requests

Successful merges:

 - #89892 (Suggest `impl Trait` return type when incorrectly using a generic return type)
 - #91675 (Add MemTagSanitizer Support)
 - #92806 (Add more information to `impl Trait` error)
 - #93497 (Pass `--test` flag through rustdoc to rustc so `#[test]` functions can be scraped)
 - #93814 (mips64-openwrt-linux-musl: correct soft-foat)
 - #93847 (kmc-solid: Use the filesystem thread-safety wrapper)
 - #93877 (asm: Allow the use of r8-r14 as clobbers on Thumb1)
 - #93892 (Only mark projection as ambiguous if GAT substs are constrained)
 - #93915 (Implement --check-cfg option (RFC 3013), take 2)
 - #93953 (Add the `known-bug` test directive, use it, and do some cleanup)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
This commit is contained in:
bors 2022-02-19 02:07:43 +00:00
commit 1882597991
127 changed files with 1593 additions and 577 deletions

View file

@ -509,3 +509,6 @@ reverse-dependency like `examples/ex.rs` is given to rustdoc with the target
crate being documented (`foobar`) and a path to output the calls
(`output.calls`). Then, the generated calls file can be passed via
`--with-examples` to the subsequent documentation of `foobar`.
To scrape examples from test code, e.g. functions marked `#[test]`, then
add the `--scrape-tests` flag.

View file

@ -16,11 +16,13 @@ This feature allows for use of one of following sanitizers:
AddressSanitizer, but based on partial hardware assistance.
* [LeakSanitizer][clang-lsan] a run-time memory leak detector.
* [MemorySanitizer][clang-msan] a detector of uninitialized reads.
* [MemTagSanitizer][clang-memtag] fast memory error detector based on
Armv8.5-A Memory Tagging Extension.
* [ThreadSanitizer][clang-tsan] a fast data race detector.
To enable a sanitizer compile with `-Zsanitizer=address`,`-Zsanitizer=cfi`,
`-Zsanitizer=hwaddress`, `-Zsanitizer=leak`, `-Zsanitizer=memory` or
`-Zsanitizer=thread`.
`-Zsanitizer=hwaddress`, `-Zsanitizer=leak`, `-Zsanitizer=memory`,
`-Zsanitizer=memtag`, or `-Zsanitizer=thread`.
# AddressSanitizer
@ -494,6 +496,20 @@ $ cargo run -Zbuild-std --target x86_64-unknown-linux-gnu
#0 0x560c04b2bc50 in memory::main::hd2333c1899d997f5 $CWD/src/main.rs:3
```
# MemTagSanitizer
MemTagSanitizer detects a similar class of errors as AddressSanitizer and HardwareAddressSanitizer, but with lower overhead suitable for use as hardening for production binaries.
MemTagSanitizer is supported on the following targets:
* `aarch64-linux-android`
* `aarch64-unknown-linux-gnu`
MemTagSanitizer requires hardware support and the `mte` target feature.
To enable this target feature compile with `-C target-feature="+mte"`.
More information can be found in the associated [LLVM documentation](https://llvm.org/docs/MemTagSanitizer.html).
# ThreadSanitizer
ThreadSanitizer is a data race detection tool. It is supported on the following

View file

@ -200,6 +200,7 @@ crate fn create_config(
lint_opts,
describe_lints,
lint_cap,
scrape_examples_options,
..
}: RustdocOptions,
) -> rustc_interface::Config {
@ -227,6 +228,7 @@ crate fn create_config(
let crate_types =
if proc_macro_crate { vec![CrateType::ProcMacro] } else { vec![CrateType::Rlib] };
let test = scrape_examples_options.map(|opts| opts.scrape_tests).unwrap_or(false);
// plays with error output here!
let sessopts = config::Options {
maybe_sysroot,
@ -244,12 +246,14 @@ crate fn create_config(
edition,
describe_lints,
crate_name,
test,
..Options::default()
};
interface::Config {
opts: sessopts,
crate_cfg: interface::parse_cfgspecs(cfgs),
crate_check_cfg: interface::parse_check_cfg(vec![]),
input,
input_path: cpath,
output_file: None,

View file

@ -91,6 +91,7 @@ crate fn run(options: RustdocOptions) -> Result<(), ErrorReported> {
let config = interface::Config {
opts: sessopts,
crate_cfg: interface::parse_cfgspecs(cfgs),
crate_check_cfg: interface::parse_check_cfg(vec![]),
input,
input_path: None,
output_file: None,

View file

@ -596,6 +596,9 @@ fn opts() -> Vec<RustcOptGroup> {
"collect function call information for functions from the target crate",
)
}),
unstable("scrape-tests", |o| {
o.optflag("", "scrape-tests", "Include test code when scraping examples")
}),
unstable("with-examples", |o| {
o.optmulti(
"",

View file

@ -34,6 +34,7 @@ use std::path::PathBuf;
crate struct ScrapeExamplesOptions {
output_path: PathBuf,
target_crates: Vec<String>,
crate scrape_tests: bool,
}
impl ScrapeExamplesOptions {
@ -43,16 +44,22 @@ impl ScrapeExamplesOptions {
) -> Result<Option<Self>, i32> {
let output_path = matches.opt_str("scrape-examples-output-path");
let target_crates = matches.opt_strs("scrape-examples-target-crate");
match (output_path, !target_crates.is_empty()) {
(Some(output_path), true) => Ok(Some(ScrapeExamplesOptions {
let scrape_tests = matches.opt_present("scrape-tests");
match (output_path, !target_crates.is_empty(), scrape_tests) {
(Some(output_path), true, _) => Ok(Some(ScrapeExamplesOptions {
output_path: PathBuf::from(output_path),
target_crates,
scrape_tests,
})),
(Some(_), false) | (None, true) => {
(Some(_), false, _) | (None, true, _) => {
diag.err("must use --scrape-examples-output-path and --scrape-examples-target-crate together");
Err(1)
}
(None, false) => Ok(None),
(None, false, true) => {
diag.err("must use --scrape-examples-output-path and --scrape-examples-target-crate with --scrape-tests");
Err(1)
}
(None, false, false) => Ok(None),
}
}
}

View file

@ -0,0 +1,12 @@
// This tests that the sanitize_memtag attribute is
// applied when enabling the memtag sanitizer.
//
// needs-sanitizer-memtag
// compile-flags: -Zsanitizer=memtag -Ctarget-feature=+mte
#![crate_type = "lib"]
// CHECK: ; Function Attrs:{{.*}}sanitize_memtag
pub fn tagged() {}
// CHECK: attributes #0 = {{.*}}sanitize_memtag

View file

@ -49,6 +49,7 @@ fn compile(code: String, output: PathBuf, sysroot: PathBuf) {
let config = interface::Config {
opts,
crate_cfg: Default::default(),
crate_check_cfg: Default::default(),
input,
input_path: None,
output_file: Some(output),

View file

@ -7,7 +7,8 @@ $(TMPDIR)/%.calls: $(TMPDIR)/libfoobar.rmeta
--extern foobar=$(TMPDIR)/libfoobar.rmeta \
-Z unstable-options \
--scrape-examples-output-path $@ \
--scrape-examples-target-crate foobar
--scrape-examples-target-crate foobar \
$(extra_flags)
$(TMPDIR)/lib%.rmeta: src/lib.rs
$(RUSTC) src/lib.rs --crate-name $* --crate-type lib --emit=metadata

View file

@ -0,0 +1,6 @@
extra_flags := --scrape-tests
deps := ex
-include ../rustdoc-scrape-examples-multiple/scrape.mk
all: scrape

View file

@ -0,0 +1,6 @@
fn main() {}
#[test]
fn a_test() {
foobar::ok();
}

View file

@ -0,0 +1,3 @@
// @has foobar/fn.ok.html '//*[@class="docblock scraped-example-list"]' ''
pub fn ok() {}

View file

@ -0,0 +1,10 @@
// Check warning for unexpected cfg
//
// check-pass
// compile-flags: --check-cfg=names() -Z unstable-options
#[cfg(unknown_key = "value")]
//~^ WARNING unexpected `cfg` condition name
pub fn f() {}
fn main() {}

View file

@ -0,0 +1,10 @@
warning: unexpected `cfg` condition name
--> $DIR/empty-names.rs:6:7
|
LL | #[cfg(unknown_key = "value")]
| ^^^^^^^^^^^^^^^^^^^^^
|
= note: `#[warn(unexpected_cfgs)]` on by default
warning: 1 warning emitted

View file

@ -0,0 +1,6 @@
// Check that a an empty values() is rejected
//
// check-fail
// compile-flags: --check-cfg=values() -Z unstable-options
fn main() {}

View file

@ -0,0 +1,2 @@
error: invalid `--check-cfg` argument: `values()` (expected `names(name1, name2, ... nameN)` or `values(name, "value1", "value2", ... "valueN")`)

View file

@ -0,0 +1,2 @@
error: invalid `--check-cfg` argument: `anything_else(...)` (expected `names(name1, name2, ... nameN)` or `values(name, "value1", "value2", ... "valueN")`)

View file

@ -0,0 +1,2 @@
error: invalid `--check-cfg` argument: `names("NOT_IDENT")` (`names()` arguments must be simple identifers)

View file

@ -0,0 +1,10 @@
// Check that invalid --check-cfg are rejected
//
// check-fail
// revisions: anything_else names_simple_ident values_simple_ident values_string_literals
// [anything_else]compile-flags: -Z unstable-options --check-cfg=anything_else(...)
// [names_simple_ident]compile-flags: -Z unstable-options --check-cfg=names("NOT_IDENT")
// [values_simple_ident]compile-flags: -Z unstable-options --check-cfg=values("NOT_IDENT")
// [values_string_literals]compile-flags: -Z unstable-options --check-cfg=values(test,12)
fn main() {}

View file

@ -0,0 +1,2 @@
error: invalid `--check-cfg` argument: `values("NOT_IDENT")` (`values()` first argument must be a simple identifer)

View file

@ -0,0 +1,2 @@
error: invalid `--check-cfg` argument: `values(test,12)` (`values()` arguments must be string literals)

View file

@ -0,0 +1,14 @@
// Check warning for invalid configuration name
//
// edition:2018
// check-pass
// compile-flags: --check-cfg=names() -Z unstable-options
#[cfg(widnows)]
//~^ WARNING unexpected `cfg` condition name
pub fn f() {}
#[cfg(windows)]
pub fn g() {}
pub fn main() {}

View file

@ -0,0 +1,10 @@
warning: unexpected `cfg` condition name
--> $DIR/invalid-cfg-name.rs:7:7
|
LL | #[cfg(widnows)]
| ^^^^^^^
|
= note: `#[warn(unexpected_cfgs)]` on by default
warning: 1 warning emitted

View file

@ -0,0 +1,17 @@
// Check warning for invalid configuration value
//
// edition:2018
// check-pass
// compile-flags: --check-cfg=values(feature,"serde","full") --cfg=feature="rand" -Z unstable-options
#[cfg(feature = "sedre")]
//~^ WARNING unexpected `cfg` condition value
pub fn f() {}
#[cfg(feature = "serde")]
pub fn g() {}
#[cfg(feature = "rand")]
pub fn h() {}
pub fn main() {}

View file

@ -0,0 +1,10 @@
warning: unexpected `cfg` condition value
--> $DIR/invalid-cfg-value.rs:7:7
|
LL | #[cfg(feature = "sedre")]
| ^^^^^^^^^^^^^^^^^
|
= note: `#[warn(unexpected_cfgs)]` on by default
warning: 1 warning emitted

View file

@ -57,20 +57,20 @@ fn _rpit_dyn() -> Box<dyn Tr1<As1: Copy>> { Box::new(S1) }
const _cdef: impl Tr1<As1: Copy> = S1;
//~^ ERROR associated type bounds are unstable
//~| ERROR `impl Trait` not allowed outside of function and method return types [E0562]
//~| ERROR `impl Trait` only allowed in function and inherent method return types
// FIXME: uncomment when `impl_trait_in_bindings` feature is fixed.
// const _cdef_dyn: &dyn Tr1<As1: Copy> = &S1;
static _sdef: impl Tr1<As1: Copy> = S1;
//~^ ERROR associated type bounds are unstable
//~| ERROR `impl Trait` not allowed outside of function and method return types [E0562]
//~| ERROR `impl Trait` only allowed in function and inherent method return types
// FIXME: uncomment when `impl_trait_in_bindings` feature is fixed.
// static _sdef_dyn: &dyn Tr1<As1: Copy> = &S1;
fn main() {
let _: impl Tr1<As1: Copy> = S1;
//~^ ERROR associated type bounds are unstable
//~| ERROR `impl Trait` not allowed outside of function and method return types [E0562]
//~| ERROR `impl Trait` only allowed in function and inherent method return types
// FIXME: uncomment when `impl_trait_in_bindings` feature is fixed.
// let _: &dyn Tr1<As1: Copy> = &S1;
}

View file

@ -115,19 +115,19 @@ LL | let _: impl Tr1<As1: Copy> = S1;
= note: see issue #52662 <https://github.com/rust-lang/rust/issues/52662> for more information
= help: add `#![feature(associated_type_bounds)]` to the crate attributes to enable
error[E0562]: `impl Trait` not allowed outside of function and method return types
error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in type
--> $DIR/feature-gate-associated_type_bounds.rs:58:14
|
LL | const _cdef: impl Tr1<As1: Copy> = S1;
| ^^^^^^^^^^^^^^^^^^^
error[E0562]: `impl Trait` not allowed outside of function and method return types
error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in type
--> $DIR/feature-gate-associated_type_bounds.rs:64:15
|
LL | static _sdef: impl Tr1<As1: Copy> = S1;
| ^^^^^^^^^^^^^^^^^^^
error[E0562]: `impl Trait` not allowed outside of function and method return types
error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in variable binding
--> $DIR/feature-gate-associated_type_bounds.rs:71:12
|
LL | let _: impl Tr1<As1: Copy> = S1;

View file

@ -0,0 +1,3 @@
// compile-flags: --check-cfg "names()"
fn main() {}

View file

@ -0,0 +1,2 @@
error: the `-Z unstable-options` flag must also be passed to enable the flag `check-cfg`

View file

@ -1,4 +1,5 @@
// check-fail
// known-bug
// This should pass, but it requires `Sized` to be coinductive.
@ -11,7 +12,6 @@ trait Allocator {
enum LinkedList<A: Allocator> {
Head,
Next(A::Allocated<Self>)
//~^ overflow
}
fn main() {}

View file

@ -1,5 +1,5 @@
error[E0275]: overflow evaluating the requirement `LinkedList<A>: Sized`
--> $DIR/issue-80626.rs:13:10
--> $DIR/issue-80626.rs:14:10
|
LL | Next(A::Allocated<Self>)
| ^^^^^^^^^^^^^^^^^^

View file

@ -1,4 +1,5 @@
// check-fail
// known-bug
// This should pass, but seems to run into a TAIT issue.
@ -20,7 +21,6 @@ trait Yay<AdditionalValue> {
impl<'a> Yay<&'a ()> for () {
type InnerStream<'s> = impl Stream<Item = i32> + 's;
//~^ the type
fn foo<'s>() -> Self::InnerStream<'s> { todo!() }
}

View file

@ -1,11 +1,11 @@
error[E0477]: the type `impl Stream<Item = i32>` does not fulfill the required lifetime
--> $DIR/issue-86218.rs:22:28
--> $DIR/issue-86218.rs:23:28
|
LL | type InnerStream<'s> = impl Stream<Item = i32> + 's;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
note: type must outlive the lifetime `'s` as defined here as required by this binding
--> $DIR/issue-86218.rs:22:22
--> $DIR/issue-86218.rs:23:22
|
LL | type InnerStream<'s> = impl Stream<Item = i32> + 's;
| ^^

View file

@ -1,4 +1,5 @@
// check-fail
// known-bug
// This should pass, but we need an extension of implied bounds (probably).
@ -23,7 +24,7 @@ struct Foo<T>(T);
#[derive(Debug)]
struct FooRef<'a, U>(&'a [U]);
impl<'b, T, U> AsRef2 for Foo<T> //~ the type parameter
impl<'b, T, U> AsRef2 for Foo<T>
where
// * `for<'b, 'c> T: AsRef2<Output<'b> = &'c [U]>>` does not work
//

View file

@ -1,5 +1,5 @@
error[E0207]: the type parameter `U` is not constrained by the impl trait, self type, or predicates
--> $DIR/issue-87735.rs:26:13
--> $DIR/issue-87735.rs:27:13
|
LL | impl<'b, T, U> AsRef2 for Foo<T>
| ^ unconstrained type parameter

View file

@ -1,4 +1,5 @@
// check-fail
// known-bug
// This should pass, but unnormalized input args aren't treated as implied.
@ -14,7 +15,7 @@ struct Foo;
impl MyTrait for Foo {
type Assoc<'a, 'b> where 'b: 'a = u32;
fn do_sth(_: u32) {} //~ lifetime bound
fn do_sth(_: u32) {}
// fn do_sth(_: Self::Assoc<'static, 'static>) {}
// fn do_sth(_: Self::Assoc<'_, '_>) {}
}

View file

@ -1,16 +1,16 @@
error[E0478]: lifetime bound not satisfied
--> $DIR/issue-87748.rs:17:5
--> $DIR/issue-87748.rs:18:5
|
LL | fn do_sth(_: u32) {}
| ^^^^^^^^^^^^^^^^^
|
note: lifetime parameter instantiated with the anonymous lifetime #2 defined here
--> $DIR/issue-87748.rs:17:5
--> $DIR/issue-87748.rs:18:5
|
LL | fn do_sth(_: u32) {}
| ^^^^^^^^^^^^^^^^^
note: but lifetime parameter must outlive the anonymous lifetime #1 defined here
--> $DIR/issue-87748.rs:17:5
--> $DIR/issue-87748.rs:18:5
|
LL | fn do_sth(_: u32) {}
| ^^^^^^^^^^^^^^^^^

View file

@ -1,4 +1,5 @@
// check-fail
// known-bug
// This should pass.
@ -15,7 +16,6 @@ struct Bar;
impl Foo for Bar {
type Ass = Bar;
//~^ overflow
}
fn main() {}

View file

@ -1,5 +1,5 @@
error[E0275]: overflow evaluating the requirement `<Bar as Foo>::Ass == _`
--> $DIR/issue-87755.rs:17:16
--> $DIR/issue-87755.rs:18:16
|
LL | type Ass = Bar;
| ^^^

View file

@ -1,4 +1,5 @@
// check-fail
// known-bug
// This should pass, but using a type alias vs a reference directly
// changes late-bound -> early-bound.
@ -18,7 +19,7 @@ impl Scanner for IdScanner {
type Input<'a> = &'a str;
type Token<'a> = &'a str;
fn scan<'a>(&mut self, s : &'a str) -> &'a str { //~ lifetime parameters
fn scan<'a>(&mut self, s : &'a str) -> &'a str {
s
}
}

View file

@ -1,5 +1,5 @@
error[E0195]: lifetime parameters or bounds on method `scan` do not match the trait declaration
--> $DIR/issue-87803.rs:21:12
--> $DIR/issue-87803.rs:22:12
|
LL | fn scan<'a>(&mut self, i : Self::Input<'a>) -> Self::Token<'a>;
| ---- lifetimes in impl do not match this method in trait

View file

@ -1,4 +1,5 @@
// check-fail
// known-bug
// This should pass, but has a missed normalization due to HRTB.
@ -25,7 +26,6 @@ fn do_something<I: Iterable>(i: I, mut f: impl for<'a> Fn(&mut I::Iterator<'a>))
fn main() {
do_something(SomeImplementation(), |_| ());
do_something(SomeImplementation(), test);
//~^ type mismatch
}
fn test<'a, I: Iterable>(_: &mut I::Iterator<'a>) {}

View file

@ -1,5 +1,5 @@
error[E0631]: type mismatch in function arguments
--> $DIR/issue-88382.rs:27:40
--> $DIR/issue-88382.rs:28:40
|
LL | do_something(SomeImplementation(), test);
| ------------ ^^^^ expected signature of `for<'a> fn(&mut <SomeImplementation as Iterable>::Iterator<'a>) -> _`
@ -10,7 +10,7 @@ LL | fn test<'a, I: Iterable>(_: &mut I::Iterator<'a>) {}
| ------------------------------------------------- found signature of `for<'r> fn(&'r mut std::iter::Empty<usize>) -> _`
|
note: required by a bound in `do_something`
--> $DIR/issue-88382.rs:21:56
--> $DIR/issue-88382.rs:22:56
|
LL | fn do_something<I: Iterable>(i: I, mut f: impl for<'a> Fn(&mut I::Iterator<'a>)) {
| ^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `do_something`

View file

@ -1,4 +1,5 @@
// check-fail
// known-bug
// This should pass, but has a missed normalization due to HRTB.
@ -27,5 +28,4 @@ impl Trait for Foo {
fn main() {
test(Foo);
//~^ the trait bound
}

View file

@ -1,11 +1,11 @@
error[E0277]: the trait bound `for<'a> <_ as Trait>::Assoc<'a>: Marker` is not satisfied
--> $DIR/issue-88460.rs:29:5
--> $DIR/issue-88460.rs:30:5
|
LL | test(Foo);
| ^^^^ the trait `for<'a> Marker` is not implemented for `<_ as Trait>::Assoc<'a>`
|
note: required by a bound in `test`
--> $DIR/issue-88460.rs:16:27
--> $DIR/issue-88460.rs:17:27
|
LL | fn test<T>(value: T)
| ---- required by a bound in this

View file

@ -1,4 +1,5 @@
// check-fail
// known-bug
// This should pass, but requires more logic.
@ -23,7 +24,7 @@ struct TestB<Q, F>
f: F,
}
impl<'q, Q, I, F> A for TestB<Q, F> //~ the type parameter
impl<'q, Q, I, F> A for TestB<Q, F>
where
Q: A<I<'q> = &'q I>,
F: Fn(I),

View file

@ -1,5 +1,5 @@
error[E0207]: the type parameter `I` is not constrained by the impl trait, self type, or predicates
--> $DIR/issue-88526.rs:26:13
--> $DIR/issue-88526.rs:27:13
|
LL | impl<'q, Q, I, F> A for TestB<Q, F>
| ^ unconstrained type parameter

View file

@ -1,5 +1,6 @@
// check-fail
// edition:2021
// known-bug
// This should pass, but seems to run into a TAIT bug.
@ -31,11 +32,11 @@ trait X {
struct Y;
impl X for Y {
type LineStream<'a, Repr> = impl Stream<Item = Repr>; //~ could not find
type LineStream<'a, Repr> = impl Stream<Item = Repr>;
type LineStreamFut<'a, Repr> = impl Future<Output = Self::LineStream<'a, Repr>> ;
fn line_stream<'a, Repr>(&'a self) -> Self::LineStreamFut<'a, Repr> { //~ type mismatch
fn line_stream<'a, Repr>(&'a self) -> Self::LineStreamFut<'a, Repr> {
async {empty()}
}
}

View file

@ -1,5 +1,5 @@
error[E0271]: type mismatch resolving `<impl Future<Output = [async output]> as Future>::Output == impl Stream<Item = Repr>`
--> $DIR/issue-89008.rs:38:43
--> $DIR/issue-89008.rs:39:43
|
LL | type LineStream<'a, Repr> = impl Stream<Item = Repr>;
| ------------------------ the expected opaque type
@ -11,7 +11,7 @@ LL | fn line_stream<'a, Repr>(&'a self) -> Self::LineStreamFut<'a, Repr> {
found struct `Empty<_>`
error: could not find defining uses
--> $DIR/issue-89008.rs:34:33
--> $DIR/issue-89008.rs:35:33
|
LL | type LineStream<'a, Repr> = impl Stream<Item = Repr>;
| ^^^^^^^^^^^^^^^^^^^^^^^^

View file

@ -17,7 +17,6 @@ impl<T> UnsafeCopy for T {}
fn main() {
let b = Box::new(42usize);
let copy = <()>::copy(&b);
//~^ type annotations needed
let raw_b = Box::deref(&b) as *const _;
let raw_copy = Box::deref(&copy) as *const _;

View file

@ -27,13 +27,6 @@ help: consider restricting type parameter `T`
LL | type Copy<T: std::clone::Clone>: Copy = Box<T>;
| +++++++++++++++++++
error[E0282]: type annotations needed
--> $DIR/issue-74824.rs:19:16
|
LL | let copy = <()>::copy(&b);
| ^^^^^^^^^^ cannot infer type for type parameter `T` declared on the associated function `copy`
error: aborting due to 2 previous errors
error: aborting due to 3 previous errors
Some errors have detailed explanations: E0277, E0282.
For more information about an error, try `rustc --explain E0277`.
For more information about this error, try `rustc --explain E0277`.

View file

@ -0,0 +1,35 @@
// check-pass
#![feature(generic_associated_types)]
pub trait Build {
type Output<O>;
fn build<O>(self, input: O) -> Self::Output<O>;
}
pub struct IdentityBuild;
impl Build for IdentityBuild {
type Output<O> = O;
fn build<O>(self, input: O) -> Self::Output<O> {
input
}
}
fn a() {
let _x: u8 = IdentityBuild.build(10);
}
fn b() {
let _x: Vec<u8> = IdentityBuild.build(Vec::new());
}
fn c() {
let mut f = IdentityBuild.build(|| ());
(f)();
}
pub fn main() {
a();
b();
c();
}

View file

@ -2,6 +2,6 @@ use std::fmt::Debug;
fn main() {
let x: Option<impl Debug> = Some(44_u32);
//~^ `impl Trait` not allowed outside of function and method return types
//~^ `impl Trait` only allowed in function and inherent method return types
println!("{:?}", x);
}

View file

@ -1,4 +1,4 @@
error[E0562]: `impl Trait` not allowed outside of function and method return types
error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in variable binding
--> $DIR/issue-54600.rs:4:19
|
LL | let x: Option<impl Debug> = Some(44_u32);

View file

@ -3,5 +3,5 @@ use std::ops::Add;
fn main() {
let i: i32 = 0;
let j: &impl Add = &i;
//~^ `impl Trait` not allowed outside of function and method return types
//~^ `impl Trait` only allowed in function and inherent method return types
}

View file

@ -1,4 +1,4 @@
error[E0562]: `impl Trait` not allowed outside of function and method return types
error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in variable binding
--> $DIR/issue-54840.rs:5:13
|
LL | let j: &impl Add = &i;

View file

@ -8,5 +8,5 @@ fn mk_gen() -> impl Generator<Return=!, Yield=()> {
fn main() {
let gens: [impl Generator<Return=!, Yield=()>;2] = [ mk_gen(), mk_gen() ];
//~^ `impl Trait` not allowed outside of function and method return types
//~^ `impl Trait` only allowed in function and inherent method return types
}

View file

@ -1,4 +1,4 @@
error[E0562]: `impl Trait` not allowed outside of function and method return types
error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in variable binding
--> $DIR/issue-58504.rs:10:16
|
LL | let gens: [impl Generator<Return=!, Yield=()>;2] = [ mk_gen(), mk_gen() ];

View file

@ -5,9 +5,9 @@ impl Lam for B {}
pub struct Wrap<T>(T);
const _A: impl Lam = {
//~^ `impl Trait` not allowed outside of function and method return types
//~^ `impl Trait` only allowed in function and inherent method return types
let x: Wrap<impl Lam> = Wrap(B);
//~^ `impl Trait` not allowed outside of function and method return types
//~^ `impl Trait` only allowed in function and inherent method return types
x.0
};

View file

@ -1,10 +1,10 @@
error[E0562]: `impl Trait` not allowed outside of function and method return types
error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in type
--> $DIR/issue-58956.rs:7:11
|
LL | const _A: impl Lam = {
| ^^^^^^^^
error[E0562]: `impl Trait` not allowed outside of function and method return types
error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in variable binding
--> $DIR/issue-58956.rs:9:17
|
LL | let x: Wrap<impl Lam> = Wrap(B);

View file

@ -1,4 +1,4 @@
fn main() {
let x : (impl Copy,) = (true,);
//~^ `impl Trait` not allowed outside of function and method return types
//~^ `impl Trait` only allowed in function and inherent method return types
}

View file

@ -1,4 +1,4 @@
error[E0562]: `impl Trait` not allowed outside of function and method return types
error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in variable binding
--> $DIR/issue-70971.rs:2:14
|
LL | let x : (impl Copy,) = (true,);

View file

@ -1,7 +1,7 @@
struct Bug {
V1: [(); {
let f: impl core::future::Future<Output = u8> = async { 1 };
//~^ `impl Trait` not allowed outside of function and method return types
//~^ `impl Trait` only allowed in function and inherent method return types
//~| expected identifier
1
}],

View file

@ -9,7 +9,7 @@ LL | let f: impl core::future::Future<Output = u8> = async { 1 };
= help: set `edition = "2021"` in `Cargo.toml`
= note: for more on editions, read https://doc.rust-lang.org/edition-guide
error[E0562]: `impl Trait` not allowed outside of function and method return types
error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in variable binding
--> $DIR/issue-79099.rs:3:16
|
LL | let f: impl core::future::Future<Output = u8> = async { 1 };

View file

@ -1,8 +1,8 @@
struct Foo<T = impl Copy>(T);
//~^ ERROR `impl Trait` not allowed outside of function and method return types
//~^ ERROR `impl Trait` only allowed in function and inherent method return types
type Result<T, E = impl std::error::Error> = std::result::Result<T, E>;
//~^ ERROR `impl Trait` not allowed outside of function and method return types
//~^ ERROR `impl Trait` only allowed in function and inherent method return types
// should not cause ICE
fn x() -> Foo {

View file

@ -1,10 +1,10 @@
error[E0562]: `impl Trait` not allowed outside of function and method return types
error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in type
--> $DIR/issue-83929-impl-trait-in-generic-default.rs:1:16
|
LL | struct Foo<T = impl Copy>(T);
| ^^^^^^^^^
error[E0562]: `impl Trait` not allowed outside of function and method return types
error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in type
--> $DIR/issue-83929-impl-trait-in-generic-default.rs:4:20
|
LL | type Result<T, E = impl std::error::Error> = std::result::Result<T, E>;

View file

@ -3,7 +3,7 @@ impl Trait for () {}
fn foo<'a: 'a>() {
let _x: impl Trait = ();
//~^ `impl Trait` not allowed outside of function and method return types
//~^ `impl Trait` only allowed in function and inherent method return types
}
fn main() {}

View file

@ -1,4 +1,4 @@
error[E0562]: `impl Trait` not allowed outside of function and method return types
error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in variable binding
--> $DIR/issue-84919.rs:5:13
|
LL | let _x: impl Trait = ();

View file

@ -1,5 +1,5 @@
static x: impl Fn(&str) -> Result<&str, ()> = move |source| {
//~^ `impl Trait` not allowed outside of function and method return types
//~^ `impl Trait` only allowed in function and inherent method return types
let res = (move |source| Ok(source))(source);
let res = res.or((move |source| Ok(source))(source));
res

View file

@ -1,4 +1,4 @@
error[E0562]: `impl Trait` not allowed outside of function and method return types
error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in type
--> $DIR/issue-86642.rs:1:11
|
LL | static x: impl Fn(&str) -> Result<&str, ()> = move |source| {

View file

@ -14,5 +14,5 @@ impl<F> Struct<F> {
fn main() {
let _do_not_waste: Struct<impl Trait<Output = i32>> = Struct::new(());
//~^ `impl Trait` not allowed outside of function and method return types
//~^ `impl Trait` only allowed in function and inherent method return types
}

View file

@ -1,4 +1,4 @@
error[E0562]: `impl Trait` not allowed outside of function and method return types
error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in variable binding
--> $DIR/issue-87295.rs:16:31
|
LL | let _do_not_waste: Struct<impl Trait<Output = i32>> = Struct::new(());

View file

@ -7,7 +7,7 @@ fn bad_in_ret_position(x: impl Into<u32>) -> impl Into<impl Debug> { x }
fn bad_in_fn_syntax(x: fn() -> impl Into<impl Debug>) {}
//~^ ERROR nested `impl Trait` is not allowed
//~^^ `impl Trait` not allowed
//~| `impl Trait` only allowed in function and inherent method return types
fn bad_in_arg_position(_: impl Into<impl Debug>) { }
//~^ ERROR nested `impl Trait` is not allowed
@ -23,7 +23,7 @@ fn allowed_in_assoc_type() -> impl Iterator<Item=impl Fn()> {
}
fn allowed_in_ret_type() -> impl Fn() -> impl Into<u32> {
//~^ `impl Trait` not allowed
//~^ `impl Trait` only allowed in function and inherent method return types
|| 5
}

View file

@ -34,13 +34,13 @@ LL | fn bad(x: impl Into<u32>) -> impl Into<impl Debug> { x }
| | nested `impl Trait` here
| outer `impl Trait`
error[E0562]: `impl Trait` not allowed outside of function and method return types
error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `fn` pointer return
--> $DIR/nested_impl_trait.rs:8:32
|
LL | fn bad_in_fn_syntax(x: fn() -> impl Into<impl Debug>) {}
| ^^^^^^^^^^^^^^^^^^^^^
error[E0562]: `impl Trait` not allowed outside of function and method return types
error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `Fn` trait return
--> $DIR/nested_impl_trait.rs:25:42
|
LL | fn allowed_in_ret_type() -> impl Fn() -> impl Into<u32> {

View file

@ -13,61 +13,61 @@ fn in_adt_in_parameters(_: Vec<impl Debug>) { panic!() }
// Disallowed
fn in_fn_parameter_in_parameters(_: fn(impl Debug)) { panic!() }
//~^ ERROR `impl Trait` not allowed outside of function and method return types
//~^ ERROR `impl Trait` only allowed in function and inherent method return types
// Disallowed
fn in_fn_return_in_parameters(_: fn() -> impl Debug) { panic!() }
//~^ ERROR `impl Trait` not allowed outside of function and method return types
//~^ ERROR `impl Trait` only allowed in function and inherent method return types
// Disallowed
fn in_fn_parameter_in_return() -> fn(impl Debug) { panic!() }
//~^ ERROR `impl Trait` not allowed outside of function and method return types
//~^ ERROR `impl Trait` only allowed in function and inherent method return types
// Disallowed
fn in_fn_return_in_return() -> fn() -> impl Debug { panic!() }
//~^ ERROR `impl Trait` not allowed outside of function and method return types
//~^ ERROR `impl Trait` only allowed in function and inherent method return types
// Disallowed
fn in_dyn_Fn_parameter_in_parameters(_: &dyn Fn(impl Debug)) { panic!() }
//~^ ERROR `impl Trait` not allowed outside of function and method return types
//~^ ERROR `impl Trait` only allowed in function and inherent method return types
// Disallowed
fn in_dyn_Fn_return_in_parameters(_: &dyn Fn() -> impl Debug) { panic!() }
//~^ ERROR `impl Trait` not allowed outside of function and method return types
//~^ ERROR `impl Trait` only allowed in function and inherent method return types
// Disallowed
fn in_dyn_Fn_parameter_in_return() -> &'static dyn Fn(impl Debug) { panic!() }
//~^ ERROR `impl Trait` not allowed outside of function and method return types
//~^ ERROR `impl Trait` only allowed in function and inherent method return types
// Disallowed
fn in_dyn_Fn_return_in_return() -> &'static dyn Fn() -> impl Debug { panic!() }
//~^ ERROR `impl Trait` not allowed outside of function and method return types
//~^ ERROR `impl Trait` only allowed in function and inherent method return types
// Disallowed
fn in_impl_Fn_parameter_in_parameters(_: &impl Fn(impl Debug)) { panic!() }
//~^ ERROR `impl Trait` not allowed outside of function and method return types
//~^ ERROR `impl Trait` only allowed in function and inherent method return types
//~^^ ERROR nested `impl Trait` is not allowed
// Disallowed
fn in_impl_Fn_return_in_parameters(_: &impl Fn() -> impl Debug) { panic!() }
//~^ ERROR `impl Trait` not allowed outside of function and method return types
//~^ ERROR `impl Trait` only allowed in function and inherent method return types
// Disallowed
fn in_impl_Fn_parameter_in_return() -> &'static impl Fn(impl Debug) { panic!() }
//~^ ERROR `impl Trait` not allowed outside of function and method return types
//~^ ERROR `impl Trait` only allowed in function and inherent method return types
//~| ERROR nested `impl Trait` is not allowed
// Disallowed
fn in_impl_Fn_return_in_return() -> &'static impl Fn() -> impl Debug { panic!() }
//~^ ERROR `impl Trait` not allowed outside of function and method return types
//~^ ERROR `impl Trait` only allowed in function and inherent method return types
// Disallowed
fn in_Fn_parameter_in_generics<F: Fn(impl Debug)> (_: F) { panic!() }
//~^ ERROR `impl Trait` not allowed outside of function and method return types
//~^ ERROR `impl Trait` only allowed in function and inherent method return types
// Disallowed
fn in_Fn_return_in_generics<F: Fn() -> impl Debug> (_: F) { panic!() }
//~^ ERROR `impl Trait` not allowed outside of function and method return types
//~^ ERROR `impl Trait` only allowed in function and inherent method return types
// Allowed
@ -80,22 +80,22 @@ fn in_impl_Trait_in_return() -> impl IntoIterator<Item = impl IntoIterator> {
// Disallowed
struct InBraceStructField { x: impl Debug }
//~^ ERROR `impl Trait` not allowed outside of function and method return types
//~^ ERROR `impl Trait` only allowed in function and inherent method return types
// Disallowed
struct InAdtInBraceStructField { x: Vec<impl Debug> }
//~^ ERROR `impl Trait` not allowed outside of function and method return types
//~^ ERROR `impl Trait` only allowed in function and inherent method return types
// Disallowed
struct InTupleStructField(impl Debug);
//~^ ERROR `impl Trait` not allowed outside of function and method return types
//~^ ERROR `impl Trait` only allowed in function and inherent method return types
// Disallowed
enum InEnum {
InBraceVariant { x: impl Debug },
//~^ ERROR `impl Trait` not allowed outside of function and method return types
//~^ ERROR `impl Trait` only allowed in function and inherent method return types
InTupleVariant(impl Debug),
//~^ ERROR `impl Trait` not allowed outside of function and method return types
//~^ ERROR `impl Trait` only allowed in function and inherent method return types
}
// Allowed
@ -106,7 +106,7 @@ trait InTraitDefnParameters {
// Disallowed
trait InTraitDefnReturn {
fn in_return() -> impl Debug;
//~^ ERROR `impl Trait` not allowed outside of function and method return types
//~^ ERROR `impl Trait` only allowed in function and inherent method return types
}
// Allowed and disallowed in trait impls
@ -123,7 +123,7 @@ impl DummyTrait for () {
// Allowed
fn in_trait_impl_return() -> impl Debug { () }
//~^ ERROR `impl Trait` not allowed outside of function and method return types
//~^ ERROR `impl Trait` only allowed in function and inherent method return types
}
// Allowed
@ -136,10 +136,10 @@ impl DummyType {
// Disallowed
extern "C" {
fn in_foreign_parameters(_: impl Debug);
//~^ ERROR `impl Trait` not allowed outside of function and method return types
//~^ ERROR `impl Trait` only allowed in function and inherent method return types
fn in_foreign_return() -> impl Debug;
//~^ ERROR `impl Trait` not allowed outside of function and method return types
//~^ ERROR `impl Trait` only allowed in function and inherent method return types
}
// Allowed
@ -155,97 +155,97 @@ type InTypeAlias<R> = impl Debug;
//~^ ERROR `impl Trait` in type aliases is unstable
type InReturnInTypeAlias<R> = fn() -> impl Debug;
//~^ ERROR `impl Trait` not allowed outside of function and method return types
//~^ ERROR `impl Trait` only allowed in function and inherent method return types
//~| ERROR `impl Trait` in type aliases is unstable
// Disallowed in impl headers
impl PartialEq<impl Debug> for () {
//~^ ERROR `impl Trait` not allowed outside of function and method return types
//~^ ERROR `impl Trait` only allowed in function and inherent method return types
}
// Disallowed in impl headers
impl PartialEq<()> for impl Debug {
//~^ ERROR `impl Trait` not allowed outside of function and method return types
//~^ ERROR `impl Trait` only allowed in function and inherent method return types
}
// Disallowed in inherent impls
impl impl Debug {
//~^ ERROR `impl Trait` not allowed outside of function and method return types
//~^ ERROR `impl Trait` only allowed in function and inherent method return types
}
// Disallowed in inherent impls
struct InInherentImplAdt<T> { t: T }
impl InInherentImplAdt<impl Debug> {
//~^ ERROR `impl Trait` not allowed outside of function and method return types
//~^ ERROR `impl Trait` only allowed in function and inherent method return types
}
// Disallowed in where clauses
fn in_fn_where_clause()
where impl Debug: Debug
//~^ ERROR `impl Trait` not allowed outside of function and method return types
//~^ ERROR `impl Trait` only allowed in function and inherent method return types
{
}
// Disallowed in where clauses
fn in_adt_in_fn_where_clause()
where Vec<impl Debug>: Debug
//~^ ERROR `impl Trait` not allowed outside of function and method return types
//~^ ERROR `impl Trait` only allowed in function and inherent method return types
{
}
// Disallowed
fn in_trait_parameter_in_fn_where_clause<T>()
where T: PartialEq<impl Debug>
//~^ ERROR `impl Trait` not allowed outside of function and method return types
//~^ ERROR `impl Trait` only allowed in function and inherent method return types
{
}
// Disallowed
fn in_Fn_parameter_in_fn_where_clause<T>()
where T: Fn(impl Debug)
//~^ ERROR `impl Trait` not allowed outside of function and method return types
//~^ ERROR `impl Trait` only allowed in function and inherent method return types
{
}
// Disallowed
fn in_Fn_return_in_fn_where_clause<T>()
where T: Fn() -> impl Debug
//~^ ERROR `impl Trait` not allowed outside of function and method return types
//~^ ERROR `impl Trait` only allowed in function and inherent method return types
{
}
// Disallowed
struct InStructGenericParamDefault<T = impl Debug>(T);
//~^ ERROR `impl Trait` not allowed outside of function and method return types
//~^ ERROR `impl Trait` only allowed in function and inherent method return types
// Disallowed
enum InEnumGenericParamDefault<T = impl Debug> { Variant(T) }
//~^ ERROR `impl Trait` not allowed outside of function and method return types
//~^ ERROR `impl Trait` only allowed in function and inherent method return types
// Disallowed
trait InTraitGenericParamDefault<T = impl Debug> {}
//~^ ERROR `impl Trait` not allowed outside of function and method return types
//~^ ERROR `impl Trait` only allowed in function and inherent method return types
// Disallowed
type InTypeAliasGenericParamDefault<T = impl Debug> = T;
//~^ ERROR `impl Trait` not allowed outside of function and method return types
//~^ ERROR `impl Trait` only allowed in function and inherent method return types
// Disallowed
impl <T = impl Debug> T {}
//~^ ERROR defaults for type parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions
//~| WARNING this was previously accepted by the compiler but is being phased out
//~| ERROR `impl Trait` not allowed outside of function and method return types
//~| ERROR `impl Trait` only allowed in function and inherent method return types
//~| ERROR no nominal type found
// Disallowed
fn in_method_generic_param_default<T = impl Debug>(_: T) {}
//~^ ERROR defaults for type parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions
//~| WARNING this was previously accepted by the compiler but is being phased out
//~| ERROR `impl Trait` not allowed outside of function and method return types
//~| ERROR `impl Trait` only allowed in function and inherent method return types
fn main() {
let _in_local_variable: impl Fn() = || {};
//~^ ERROR `impl Trait` not allowed outside of function and method return types
//~^ ERROR `impl Trait` only allowed in function and inherent method return types
let _in_return_in_local_variable = || -> impl Fn() { || {} };
//~^ ERROR `impl Trait` not allowed outside of function and method return types
//~^ ERROR `impl Trait` only allowed in function and inherent method return types
}

View file

@ -43,247 +43,247 @@ LL | type InReturnInTypeAlias<R> = fn() -> impl Debug;
= note: see issue #63063 <https://github.com/rust-lang/rust/issues/63063> for more information
= help: add `#![feature(type_alias_impl_trait)]` to the crate attributes to enable
error[E0562]: `impl Trait` not allowed outside of function and method return types
error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `fn` pointer param
--> $DIR/where-allowed.rs:15:40
|
LL | fn in_fn_parameter_in_parameters(_: fn(impl Debug)) { panic!() }
| ^^^^^^^^^^
error[E0562]: `impl Trait` not allowed outside of function and method return types
error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `fn` pointer return
--> $DIR/where-allowed.rs:19:42
|
LL | fn in_fn_return_in_parameters(_: fn() -> impl Debug) { panic!() }
| ^^^^^^^^^^
error[E0562]: `impl Trait` not allowed outside of function and method return types
error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `fn` pointer param
--> $DIR/where-allowed.rs:23:38
|
LL | fn in_fn_parameter_in_return() -> fn(impl Debug) { panic!() }
| ^^^^^^^^^^
error[E0562]: `impl Trait` not allowed outside of function and method return types
error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `fn` pointer return
--> $DIR/where-allowed.rs:27:40
|
LL | fn in_fn_return_in_return() -> fn() -> impl Debug { panic!() }
| ^^^^^^^^^^
error[E0562]: `impl Trait` not allowed outside of function and method return types
error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `Fn` trait param
--> $DIR/where-allowed.rs:31:49
|
LL | fn in_dyn_Fn_parameter_in_parameters(_: &dyn Fn(impl Debug)) { panic!() }
| ^^^^^^^^^^
error[E0562]: `impl Trait` not allowed outside of function and method return types
error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `Fn` trait return
--> $DIR/where-allowed.rs:35:51
|
LL | fn in_dyn_Fn_return_in_parameters(_: &dyn Fn() -> impl Debug) { panic!() }
| ^^^^^^^^^^
error[E0562]: `impl Trait` not allowed outside of function and method return types
error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `Fn` trait param
--> $DIR/where-allowed.rs:39:55
|
LL | fn in_dyn_Fn_parameter_in_return() -> &'static dyn Fn(impl Debug) { panic!() }
| ^^^^^^^^^^
error[E0562]: `impl Trait` not allowed outside of function and method return types
error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `Fn` trait return
--> $DIR/where-allowed.rs:43:57
|
LL | fn in_dyn_Fn_return_in_return() -> &'static dyn Fn() -> impl Debug { panic!() }
| ^^^^^^^^^^
error[E0562]: `impl Trait` not allowed outside of function and method return types
error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `Fn` trait param
--> $DIR/where-allowed.rs:47:51
|
LL | fn in_impl_Fn_parameter_in_parameters(_: &impl Fn(impl Debug)) { panic!() }
| ^^^^^^^^^^
error[E0562]: `impl Trait` not allowed outside of function and method return types
error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `Fn` trait return
--> $DIR/where-allowed.rs:52:53
|
LL | fn in_impl_Fn_return_in_parameters(_: &impl Fn() -> impl Debug) { panic!() }
| ^^^^^^^^^^
error[E0562]: `impl Trait` not allowed outside of function and method return types
error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `Fn` trait param
--> $DIR/where-allowed.rs:56:57
|
LL | fn in_impl_Fn_parameter_in_return() -> &'static impl Fn(impl Debug) { panic!() }
| ^^^^^^^^^^
error[E0562]: `impl Trait` not allowed outside of function and method return types
error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `Fn` trait return
--> $DIR/where-allowed.rs:61:59
|
LL | fn in_impl_Fn_return_in_return() -> &'static impl Fn() -> impl Debug { panic!() }
| ^^^^^^^^^^
error[E0562]: `impl Trait` not allowed outside of function and method return types
error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `Fn` trait param
--> $DIR/where-allowed.rs:65:38
|
LL | fn in_Fn_parameter_in_generics<F: Fn(impl Debug)> (_: F) { panic!() }
| ^^^^^^^^^^
error[E0562]: `impl Trait` not allowed outside of function and method return types
error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `Fn` trait return
--> $DIR/where-allowed.rs:69:40
|
LL | fn in_Fn_return_in_generics<F: Fn() -> impl Debug> (_: F) { panic!() }
| ^^^^^^^^^^
error[E0562]: `impl Trait` not allowed outside of function and method return types
error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in type
--> $DIR/where-allowed.rs:82:32
|
LL | struct InBraceStructField { x: impl Debug }
| ^^^^^^^^^^
error[E0562]: `impl Trait` not allowed outside of function and method return types
error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in path
--> $DIR/where-allowed.rs:86:41
|
LL | struct InAdtInBraceStructField { x: Vec<impl Debug> }
| ^^^^^^^^^^
error[E0562]: `impl Trait` not allowed outside of function and method return types
error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in type
--> $DIR/where-allowed.rs:90:27
|
LL | struct InTupleStructField(impl Debug);
| ^^^^^^^^^^
error[E0562]: `impl Trait` not allowed outside of function and method return types
error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in type
--> $DIR/where-allowed.rs:95:25
|
LL | InBraceVariant { x: impl Debug },
| ^^^^^^^^^^
error[E0562]: `impl Trait` not allowed outside of function and method return types
error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in type
--> $DIR/where-allowed.rs:97:20
|
LL | InTupleVariant(impl Debug),
| ^^^^^^^^^^
error[E0562]: `impl Trait` not allowed outside of function and method return types
error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in trait method return
--> $DIR/where-allowed.rs:108:23
|
LL | fn in_return() -> impl Debug;
| ^^^^^^^^^^
error[E0562]: `impl Trait` not allowed outside of function and method return types
error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `impl` method return
--> $DIR/where-allowed.rs:125:34
|
LL | fn in_trait_impl_return() -> impl Debug { () }
| ^^^^^^^^^^
error[E0562]: `impl Trait` not allowed outside of function and method return types
error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `extern fn` param
--> $DIR/where-allowed.rs:138:33
|
LL | fn in_foreign_parameters(_: impl Debug);
| ^^^^^^^^^^
error[E0562]: `impl Trait` not allowed outside of function and method return types
error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `extern fn` return
--> $DIR/where-allowed.rs:141:31
|
LL | fn in_foreign_return() -> impl Debug;
| ^^^^^^^^^^
error[E0562]: `impl Trait` not allowed outside of function and method return types
error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `fn` pointer return
--> $DIR/where-allowed.rs:157:39
|
LL | type InReturnInTypeAlias<R> = fn() -> impl Debug;
| ^^^^^^^^^^
error[E0562]: `impl Trait` not allowed outside of function and method return types
error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in trait
--> $DIR/where-allowed.rs:162:16
|
LL | impl PartialEq<impl Debug> for () {
| ^^^^^^^^^^
error[E0562]: `impl Trait` not allowed outside of function and method return types
error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in type
--> $DIR/where-allowed.rs:167:24
|
LL | impl PartialEq<()> for impl Debug {
| ^^^^^^^^^^
error[E0562]: `impl Trait` not allowed outside of function and method return types
error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in type
--> $DIR/where-allowed.rs:172:6
|
LL | impl impl Debug {
| ^^^^^^^^^^
error[E0562]: `impl Trait` not allowed outside of function and method return types
error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in type
--> $DIR/where-allowed.rs:178:24
|
LL | impl InInherentImplAdt<impl Debug> {
| ^^^^^^^^^^
error[E0562]: `impl Trait` not allowed outside of function and method return types
error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in type
--> $DIR/where-allowed.rs:184:11
|
LL | where impl Debug: Debug
| ^^^^^^^^^^
error[E0562]: `impl Trait` not allowed outside of function and method return types
error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in type
--> $DIR/where-allowed.rs:191:15
|
LL | where Vec<impl Debug>: Debug
| ^^^^^^^^^^
error[E0562]: `impl Trait` not allowed outside of function and method return types
error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in bound
--> $DIR/where-allowed.rs:198:24
|
LL | where T: PartialEq<impl Debug>
| ^^^^^^^^^^
error[E0562]: `impl Trait` not allowed outside of function and method return types
error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `Fn` trait param
--> $DIR/where-allowed.rs:205:17
|
LL | where T: Fn(impl Debug)
| ^^^^^^^^^^
error[E0562]: `impl Trait` not allowed outside of function and method return types
error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `Fn` trait return
--> $DIR/where-allowed.rs:212:22
|
LL | where T: Fn() -> impl Debug
| ^^^^^^^^^^
error[E0562]: `impl Trait` not allowed outside of function and method return types
error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in type
--> $DIR/where-allowed.rs:218:40
|
LL | struct InStructGenericParamDefault<T = impl Debug>(T);
| ^^^^^^^^^^
error[E0562]: `impl Trait` not allowed outside of function and method return types
error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in type
--> $DIR/where-allowed.rs:222:36
|
LL | enum InEnumGenericParamDefault<T = impl Debug> { Variant(T) }
| ^^^^^^^^^^
error[E0562]: `impl Trait` not allowed outside of function and method return types
error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in type
--> $DIR/where-allowed.rs:226:38
|
LL | trait InTraitGenericParamDefault<T = impl Debug> {}
| ^^^^^^^^^^
error[E0562]: `impl Trait` not allowed outside of function and method return types
error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in type
--> $DIR/where-allowed.rs:230:41
|
LL | type InTypeAliasGenericParamDefault<T = impl Debug> = T;
| ^^^^^^^^^^
error[E0562]: `impl Trait` not allowed outside of function and method return types
error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in type
--> $DIR/where-allowed.rs:234:11
|
LL | impl <T = impl Debug> T {}
| ^^^^^^^^^^
error[E0562]: `impl Trait` not allowed outside of function and method return types
error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in type
--> $DIR/where-allowed.rs:241:40
|
LL | fn in_method_generic_param_default<T = impl Debug>(_: T) {}
| ^^^^^^^^^^
error[E0562]: `impl Trait` not allowed outside of function and method return types
error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in variable binding
--> $DIR/where-allowed.rs:247:29
|
LL | let _in_local_variable: impl Fn() = || {};
| ^^^^^^^^^
error[E0562]: `impl Trait` not allowed outside of function and method return types
error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in closure return
--> $DIR/where-allowed.rs:249:46
|
LL | let _in_return_in_local_variable = || -> impl Fn() { || {} };

View file

@ -4,7 +4,7 @@ error: invalid argument for `no_sanitize`
LL | #[no_sanitize(brontosaurus)]
| ^^^^^^^^^^^^
|
= note: expected one of: `address`, `hwaddress`, `memory` or `thread`
= note: expected one of: `address`, `cfi`, `hwaddress`, `memory`, `memtag`, or `thread`
error: aborting due to previous error

View file

@ -7,22 +7,22 @@ trait Iterable {
}
struct Container<T: Iterable<Item = impl Foo>> {
//~^ ERROR `impl Trait` not allowed
//~^ ERROR `impl Trait` only allowed in function and inherent method return types
field: T
}
enum Enum<T: Iterable<Item = impl Foo>> {
//~^ ERROR `impl Trait` not allowed
//~^ ERROR `impl Trait` only allowed in function and inherent method return types
A(T),
}
union Union<T: Iterable<Item = impl Foo> + Copy> {
//~^ ERROR `impl Trait` not allowed
//~^ ERROR `impl Trait` only allowed in function and inherent method return types
x: T,
}
type Type<T: Iterable<Item = impl Foo>> = T;
//~^ ERROR `impl Trait` not allowed
//~^ ERROR `impl Trait` only allowed in function and inherent method return types
fn main() {
}

View file

@ -1,22 +1,22 @@
error[E0562]: `impl Trait` not allowed outside of function and method return types
error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in generic
--> $DIR/issue-47715.rs:9:37
|
LL | struct Container<T: Iterable<Item = impl Foo>> {
| ^^^^^^^^
error[E0562]: `impl Trait` not allowed outside of function and method return types
error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in generic
--> $DIR/issue-47715.rs:14:30
|
LL | enum Enum<T: Iterable<Item = impl Foo>> {
| ^^^^^^^^
error[E0562]: `impl Trait` not allowed outside of function and method return types
error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in generic
--> $DIR/issue-47715.rs:19:32
|
LL | union Union<T: Iterable<Item = impl Foo> + Copy> {
| ^^^^^^^^
error[E0562]: `impl Trait` not allowed outside of function and method return types
error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in generic
--> $DIR/issue-47715.rs:24:30
|
LL | type Type<T: Iterable<Item = impl Foo>> = T;

View file

@ -0,0 +1,31 @@
trait Trait {}
impl Trait for () {}
fn bad_echo<T>(_t: T) -> T {
"this should not suggest impl Trait" //~ ERROR mismatched types
}
fn bad_echo_2<T: Trait>(_t: T) -> T {
"this will not suggest it, because that would probably be wrong" //~ ERROR mismatched types
}
fn other_bounds_bad<T>() -> T
where
T: Send,
Option<T>: Send,
{
"don't suggest this, because Option<T> places additional constraints" //~ ERROR mismatched types
}
// FIXME: implement this check
trait GenericTrait<T> {}
fn used_in_trait<T>() -> T
where
T: Send,
(): GenericTrait<T>,
{
"don't suggest this, because the generic param is used in the bound." //~ ERROR mismatched types
}
fn main() {}

View file

@ -0,0 +1,59 @@
error[E0308]: mismatched types
--> $DIR/return-impl-trait-bad.rs:5:5
|
LL | fn bad_echo<T>(_t: T) -> T {
| - - expected `T` because of return type
| |
| this type parameter
LL | "this should not suggest impl Trait"
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected type parameter `T`, found `&str`
|
= note: expected type parameter `T`
found reference `&'static str`
error[E0308]: mismatched types
--> $DIR/return-impl-trait-bad.rs:9:5
|
LL | fn bad_echo_2<T: Trait>(_t: T) -> T {
| - - expected `T` because of return type
| |
| this type parameter
LL | "this will not suggest it, because that would probably be wrong"
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected type parameter `T`, found `&str`
|
= note: expected type parameter `T`
found reference `&'static str`
error[E0308]: mismatched types
--> $DIR/return-impl-trait-bad.rs:17:5
|
LL | fn other_bounds_bad<T>() -> T
| - - expected `T` because of return type
| |
| this type parameter
...
LL | "don't suggest this, because Option<T> places additional constraints"
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected type parameter `T`, found `&str`
|
= note: expected type parameter `T`
found reference `&'static str`
error[E0308]: mismatched types
--> $DIR/return-impl-trait-bad.rs:28:5
|
LL | fn used_in_trait<T>() -> T
| - -
| | |
| | expected `T` because of return type
| | help: consider using an impl return type: `impl Send`
| this type parameter
...
LL | "don't suggest this, because the generic param is used in the bound."
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected type parameter `T`, found `&str`
|
= note: expected type parameter `T`
found reference `&'static str`
error: aborting due to 4 previous errors
For more information about this error, try `rustc --explain E0308`.

View file

@ -0,0 +1,30 @@
// run-rustfix
trait Trait {}
impl Trait for () {}
// this works
fn foo() -> impl Trait {
()
}
fn bar<T: Trait + std::marker::Sync>() -> impl Trait + std::marker::Sync + Send
where
T: Send,
{
() //~ ERROR mismatched types
}
fn other_bounds<T>() -> impl Trait
where
T: Trait,
Vec<usize>: Clone,
{
() //~ ERROR mismatched types
}
fn main() {
foo();
bar::<()>();
other_bounds::<()>();
}

View file

@ -0,0 +1,30 @@
// run-rustfix
trait Trait {}
impl Trait for () {}
// this works
fn foo() -> impl Trait {
()
}
fn bar<T: Trait + std::marker::Sync>() -> T
where
T: Send,
{
() //~ ERROR mismatched types
}
fn other_bounds<T>() -> T
where
T: Trait,
Vec<usize>: Clone,
{
() //~ ERROR mismatched types
}
fn main() {
foo();
bar::<()>();
other_bounds::<()>();
}

View file

@ -0,0 +1,34 @@
error[E0308]: mismatched types
--> $DIR/return-impl-trait.rs:15:5
|
LL | fn bar<T: Trait + std::marker::Sync>() -> T
| - -
| | |
| | expected `T` because of return type
| this type parameter help: consider using an impl return type: `impl Trait + std::marker::Sync + Send`
...
LL | ()
| ^^ expected type parameter `T`, found `()`
|
= note: expected type parameter `T`
found unit type `()`
error[E0308]: mismatched types
--> $DIR/return-impl-trait.rs:23:5
|
LL | fn other_bounds<T>() -> T
| - -
| | |
| | expected `T` because of return type
| | help: consider using an impl return type: `impl Trait`
| this type parameter
...
LL | ()
| ^^ expected type parameter `T`, found `()`
|
= note: expected type parameter `T`
found unit type `()`
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0308`.

View file

@ -4,7 +4,7 @@
// FIXME: this is ruled out for now but should work
type Foo = fn() -> impl Send;
//~^ ERROR: `impl Trait` not allowed outside of function and method return types
//~^ ERROR: `impl Trait` only allowed in function and inherent method return types
fn make_foo() -> Foo {
|| 15

View file

@ -1,4 +1,4 @@
error[E0562]: `impl Trait` not allowed outside of function and method return types
error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `fn` pointer return
--> $DIR/type-alias-impl-trait-fn-type.rs:6:20
|
LL | type Foo = fn() -> impl Send;

View file

@ -41,12 +41,15 @@ impl EarlyProps {
pub fn from_reader<R: Read>(config: &Config, testfile: &Path, rdr: R) -> Self {
let mut props = EarlyProps::default();
iter_header(testfile, rdr, &mut |_, ln| {
if let Some(s) = config.parse_aux_build(ln) {
props.aux.push(s);
}
if let Some(ac) = config.parse_aux_crate(ln) {
props.aux_crate.push(ac);
}
config.push_name_value_directive(ln, directives::AUX_BUILD, &mut props.aux, |r| {
r.trim().to_string()
});
config.push_name_value_directive(
ln,
directives::AUX_CRATE,
&mut props.aux_crate,
Config::parse_aux_crate,
);
config.parse_and_update_revisions(ln, &mut props.revisions);
});
return props;
@ -126,6 +129,12 @@ pub struct TestProps {
// empty before the test starts. Incremental mode tests will reuse the
// incremental directory between passes in the same test.
pub incremental: bool,
// If `true`, this test is a known bug.
//
// When set, some requirements are relaxed. Currently, this only means no
// error annotations are needed, but this may be updated in the future to
// include other relaxations.
pub known_bug: bool,
// How far should the test proceed while still passing.
pass_mode: Option<PassMode>,
// Ignore `--pass` overrides from the command line for this test.
@ -150,6 +159,38 @@ pub struct TestProps {
pub stderr_per_bitwidth: bool,
}
mod directives {
pub const ERROR_PATTERN: &'static str = "error-pattern";
pub const COMPILE_FLAGS: &'static str = "compile-flags";
pub const RUN_FLAGS: &'static str = "run-flags";
pub const SHOULD_ICE: &'static str = "should-ice";
pub const BUILD_AUX_DOCS: &'static str = "build-aux-docs";
pub const FORCE_HOST: &'static str = "force-host";
pub const CHECK_STDOUT: &'static str = "check-stdout";
pub const CHECK_RUN_RESULTS: &'static str = "check-run-results";
pub const DONT_CHECK_COMPILER_STDOUT: &'static str = "dont-check-compiler-stdout";
pub const DONT_CHECK_COMPILER_STDERR: &'static str = "dont-check-compiler-stderr";
pub const NO_PREFER_DYNAMIC: &'static str = "no-prefer-dynamic";
pub const PRETTY_EXPANDED: &'static str = "pretty-expanded";
pub const PRETTY_MODE: &'static str = "pretty-mode";
pub const PRETTY_COMPARE_ONLY: &'static str = "pretty-compare-only";
pub const AUX_BUILD: &'static str = "aux-build";
pub const AUX_CRATE: &'static str = "aux-crate";
pub const EXEC_ENV: &'static str = "exec-env";
pub const RUSTC_ENV: &'static str = "rustc-env";
pub const UNSET_RUSTC_ENV: &'static str = "unset-rustc-env";
pub const FORBID_OUTPUT: &'static str = "forbid-output";
pub const CHECK_TEST_LINE_NUMBERS_MATCH: &'static str = "check-test-line-numbers-match";
pub const IGNORE_PASS: &'static str = "ignore-pass";
pub const FAILURE_STATUS: &'static str = "failure-status";
pub const RUN_RUSTFIX: &'static str = "run-rustfix";
pub const RUSTFIX_ONLY_MACHINE_APPLICABLE: &'static str = "rustfix-only-machine-applicable";
pub const ASSEMBLY_OUTPUT: &'static str = "assembly-output";
pub const STDERR_PER_BITWIDTH: &'static str = "stderr-per-bitwidth";
pub const INCREMENTAL: &'static str = "incremental";
pub const KNOWN_BUG: &'static str = "known-bug";
}
impl TestProps {
pub fn new() -> Self {
TestProps {
@ -176,6 +217,7 @@ impl TestProps {
forbid_output: vec![],
incremental_dir: None,
incremental: false,
known_bug: false,
pass_mode: None,
fail_mode: None,
ignore_pass: false,
@ -228,11 +270,16 @@ impl TestProps {
return;
}
if let Some(ep) = config.parse_error_pattern(ln) {
self.error_patterns.push(ep);
}
use directives::*;
if let Some(flags) = config.parse_compile_flags(ln) {
config.push_name_value_directive(
ln,
ERROR_PATTERN,
&mut self.error_patterns,
|r| r,
);
if let Some(flags) = config.parse_name_value_directive(ln, COMPILE_FLAGS) {
self.compile_flags.extend(flags.split_whitespace().map(|s| s.to_owned()));
}
@ -243,93 +290,73 @@ impl TestProps {
config.parse_and_update_revisions(ln, &mut self.revisions);
if self.run_flags.is_none() {
self.run_flags = config.parse_run_flags(ln);
}
config.set_name_value_directive(ln, RUN_FLAGS, &mut self.run_flags, |r| r);
if self.pp_exact.is_none() {
self.pp_exact = config.parse_pp_exact(ln, testfile);
}
if !self.should_ice {
self.should_ice = config.parse_should_ice(ln);
}
config.set_name_directive(ln, SHOULD_ICE, &mut self.should_ice);
config.set_name_directive(ln, BUILD_AUX_DOCS, &mut self.build_aux_docs);
config.set_name_directive(ln, FORCE_HOST, &mut self.force_host);
config.set_name_directive(ln, CHECK_STDOUT, &mut self.check_stdout);
config.set_name_directive(ln, CHECK_RUN_RESULTS, &mut self.check_run_results);
config.set_name_directive(
ln,
DONT_CHECK_COMPILER_STDOUT,
&mut self.dont_check_compiler_stdout,
);
config.set_name_directive(
ln,
DONT_CHECK_COMPILER_STDERR,
&mut self.dont_check_compiler_stderr,
);
config.set_name_directive(ln, NO_PREFER_DYNAMIC, &mut self.no_prefer_dynamic);
config.set_name_directive(ln, PRETTY_EXPANDED, &mut self.pretty_expanded);
if !self.build_aux_docs {
self.build_aux_docs = config.parse_build_aux_docs(ln);
}
if !self.force_host {
self.force_host = config.parse_force_host(ln);
}
if !self.check_stdout {
self.check_stdout = config.parse_check_stdout(ln);
}
if !self.check_run_results {
self.check_run_results = config.parse_check_run_results(ln);
}
if !self.dont_check_compiler_stdout {
self.dont_check_compiler_stdout = config.parse_dont_check_compiler_stdout(ln);
}
if !self.dont_check_compiler_stderr {
self.dont_check_compiler_stderr = config.parse_dont_check_compiler_stderr(ln);
}
if !self.no_prefer_dynamic {
self.no_prefer_dynamic = config.parse_no_prefer_dynamic(ln);
}
if !self.pretty_expanded {
self.pretty_expanded = config.parse_pretty_expanded(ln);
}
if let Some(m) = config.parse_pretty_mode(ln) {
if let Some(m) = config.parse_name_value_directive(ln, PRETTY_MODE) {
self.pretty_mode = m;
}
if !self.pretty_compare_only {
self.pretty_compare_only = config.parse_pretty_compare_only(ln);
}
if let Some(ab) = config.parse_aux_build(ln) {
self.aux_builds.push(ab);
}
if let Some(ac) = config.parse_aux_crate(ln) {
self.aux_crates.push(ac);
}
if let Some(ee) = config.parse_env(ln, "exec-env") {
self.exec_env.push(ee);
}
if let Some(ee) = config.parse_env(ln, "rustc-env") {
self.rustc_env.push(ee);
}
if let Some(ev) = config.parse_name_value_directive(ln, "unset-rustc-env") {
self.unset_rustc_env.push(ev);
}
if let Some(of) = config.parse_forbid_output(ln) {
self.forbid_output.push(of);
}
if !self.check_test_line_numbers_match {
self.check_test_line_numbers_match =
config.parse_check_test_line_numbers_match(ln);
}
config.set_name_directive(ln, PRETTY_COMPARE_ONLY, &mut self.pretty_compare_only);
config.push_name_value_directive(ln, AUX_BUILD, &mut self.aux_builds, |r| {
r.trim().to_string()
});
config.push_name_value_directive(
ln,
AUX_CRATE,
&mut self.aux_crates,
Config::parse_aux_crate,
);
config.push_name_value_directive(
ln,
EXEC_ENV,
&mut self.exec_env,
Config::parse_env,
);
config.push_name_value_directive(
ln,
RUSTC_ENV,
&mut self.rustc_env,
Config::parse_env,
);
config.push_name_value_directive(
ln,
UNSET_RUSTC_ENV,
&mut self.unset_rustc_env,
|r| r,
);
config.push_name_value_directive(ln, FORBID_OUTPUT, &mut self.forbid_output, |r| r);
config.set_name_directive(
ln,
CHECK_TEST_LINE_NUMBERS_MATCH,
&mut self.check_test_line_numbers_match,
);
self.update_pass_mode(ln, cfg, config);
self.update_fail_mode(ln, config);
if !self.ignore_pass {
self.ignore_pass = config.parse_ignore_pass(ln);
}
config.set_name_directive(ln, IGNORE_PASS, &mut self.ignore_pass);
if let Some(rule) = config.parse_custom_normalization(ln, "normalize-stdout") {
self.normalize_stdout.push(rule);
@ -338,30 +365,28 @@ impl TestProps {
self.normalize_stderr.push(rule);
}
if let Some(code) = config.parse_failure_status(ln) {
if let Some(code) = config
.parse_name_value_directive(ln, FAILURE_STATUS)
.and_then(|code| code.trim().parse::<i32>().ok())
{
self.failure_status = code;
}
if !self.run_rustfix {
self.run_rustfix = config.parse_run_rustfix(ln);
}
if !self.rustfix_only_machine_applicable {
self.rustfix_only_machine_applicable =
config.parse_rustfix_only_machine_applicable(ln);
}
if self.assembly_output.is_none() {
self.assembly_output = config.parse_assembly_output(ln);
}
if !self.stderr_per_bitwidth {
self.stderr_per_bitwidth = config.parse_stderr_per_bitwidth(ln);
}
if !self.incremental {
self.incremental = config.parse_incremental(ln);
}
config.set_name_directive(ln, RUN_RUSTFIX, &mut self.run_rustfix);
config.set_name_directive(
ln,
RUSTFIX_ONLY_MACHINE_APPLICABLE,
&mut self.rustfix_only_machine_applicable,
);
config.set_name_value_directive(
ln,
ASSEMBLY_OUTPUT,
&mut self.assembly_output,
|r| r.trim().to_string(),
);
config.set_name_directive(ln, STDERR_PER_BITWIDTH, &mut self.stderr_per_bitwidth);
config.set_name_directive(ln, INCREMENTAL, &mut self.incremental);
config.set_name_directive(ln, KNOWN_BUG, &mut self.known_bug);
});
}
@ -503,33 +528,12 @@ fn iter_header<R: Read>(testfile: &Path, rdr: R, it: &mut dyn FnMut(Option<&str>
}
impl Config {
fn parse_should_ice(&self, line: &str) -> bool {
self.parse_name_directive(line, "should-ice")
}
fn parse_error_pattern(&self, line: &str) -> Option<String> {
self.parse_name_value_directive(line, "error-pattern")
}
fn parse_forbid_output(&self, line: &str) -> Option<String> {
self.parse_name_value_directive(line, "forbid-output")
}
fn parse_aux_build(&self, line: &str) -> Option<String> {
self.parse_name_value_directive(line, "aux-build").map(|r| r.trim().to_string())
}
fn parse_aux_crate(&self, line: &str) -> Option<(String, String)> {
self.parse_name_value_directive(line, "aux-crate").map(|r| {
let mut parts = r.trim().splitn(2, '=');
(
parts.next().expect("missing aux-crate name (e.g. log=log.rs)").to_string(),
parts.next().expect("missing aux-crate value (e.g. log=log.rs)").to_string(),
)
})
}
fn parse_compile_flags(&self, line: &str) -> Option<String> {
self.parse_name_value_directive(line, "compile-flags")
fn parse_aux_crate(r: String) -> (String, String) {
let mut parts = r.trim().splitn(2, '=');
(
parts.next().expect("missing aux-crate name (e.g. log=log.rs)").to_string(),
parts.next().expect("missing aux-crate value (e.g. log=log.rs)").to_string(),
)
}
fn parse_and_update_revisions(&self, line: &str, existing: &mut Vec<String>) {
@ -544,87 +548,18 @@ impl Config {
}
}
fn parse_run_flags(&self, line: &str) -> Option<String> {
self.parse_name_value_directive(line, "run-flags")
}
fn parse_env(nv: String) -> (String, String) {
// nv is either FOO or FOO=BAR
let mut strs: Vec<String> = nv.splitn(2, '=').map(str::to_owned).collect();
fn parse_force_host(&self, line: &str) -> bool {
self.parse_name_directive(line, "force-host")
}
fn parse_build_aux_docs(&self, line: &str) -> bool {
self.parse_name_directive(line, "build-aux-docs")
}
fn parse_check_stdout(&self, line: &str) -> bool {
self.parse_name_directive(line, "check-stdout")
}
fn parse_check_run_results(&self, line: &str) -> bool {
self.parse_name_directive(line, "check-run-results")
}
fn parse_dont_check_compiler_stdout(&self, line: &str) -> bool {
self.parse_name_directive(line, "dont-check-compiler-stdout")
}
fn parse_dont_check_compiler_stderr(&self, line: &str) -> bool {
self.parse_name_directive(line, "dont-check-compiler-stderr")
}
fn parse_no_prefer_dynamic(&self, line: &str) -> bool {
self.parse_name_directive(line, "no-prefer-dynamic")
}
fn parse_pretty_expanded(&self, line: &str) -> bool {
self.parse_name_directive(line, "pretty-expanded")
}
fn parse_pretty_mode(&self, line: &str) -> Option<String> {
self.parse_name_value_directive(line, "pretty-mode")
}
fn parse_pretty_compare_only(&self, line: &str) -> bool {
self.parse_name_directive(line, "pretty-compare-only")
}
fn parse_failure_status(&self, line: &str) -> Option<i32> {
match self.parse_name_value_directive(line, "failure-status") {
Some(code) => code.trim().parse::<i32>().ok(),
_ => None,
}
}
fn parse_check_test_line_numbers_match(&self, line: &str) -> bool {
self.parse_name_directive(line, "check-test-line-numbers-match")
}
fn parse_ignore_pass(&self, line: &str) -> bool {
self.parse_name_directive(line, "ignore-pass")
}
fn parse_stderr_per_bitwidth(&self, line: &str) -> bool {
self.parse_name_directive(line, "stderr-per-bitwidth")
}
fn parse_assembly_output(&self, line: &str) -> Option<String> {
self.parse_name_value_directive(line, "assembly-output").map(|r| r.trim().to_string())
}
fn parse_env(&self, line: &str, name: &str) -> Option<(String, String)> {
self.parse_name_value_directive(line, name).map(|nv| {
// nv is either FOO or FOO=BAR
let mut strs: Vec<String> = nv.splitn(2, '=').map(str::to_owned).collect();
match strs.len() {
1 => (strs.pop().unwrap(), String::new()),
2 => {
let end = strs.pop().unwrap();
(strs.pop().unwrap(), end)
}
n => panic!("Expected 1 or 2 strings, not {}", n),
match strs.len() {
1 => (strs.pop().unwrap(), String::new()),
2 => {
let end = strs.pop().unwrap();
(strs.pop().unwrap(), end)
}
})
n => panic!("Expected 1 or 2 strings, not {}", n),
}
}
fn parse_pp_exact(&self, line: &str, testfile: &Path) -> Option<PathBuf> {
@ -736,20 +671,38 @@ impl Config {
None
}
fn parse_run_rustfix(&self, line: &str) -> bool {
self.parse_name_directive(line, "run-rustfix")
}
fn parse_rustfix_only_machine_applicable(&self, line: &str) -> bool {
self.parse_name_directive(line, "rustfix-only-machine-applicable")
}
fn parse_edition(&self, line: &str) -> Option<String> {
self.parse_name_value_directive(line, "edition")
}
fn parse_incremental(&self, line: &str) -> bool {
self.parse_name_directive(line, "incremental")
fn set_name_directive(&self, line: &str, directive: &str, value: &mut bool) {
if !*value {
*value = self.parse_name_directive(line, directive)
}
}
fn set_name_value_directive<T>(
&self,
line: &str,
directive: &str,
value: &mut Option<T>,
parse: impl FnOnce(String) -> T,
) {
if value.is_none() {
*value = self.parse_name_value_directive(line, directive).map(parse);
}
}
fn push_name_value_directive<T>(
&self,
line: &str,
directive: &str,
values: &mut Vec<T>,
parse: impl FnOnce(String) -> T,
) {
if let Some(value) = self.parse_name_value_directive(line, directive).map(parse) {
values.push(value);
}
}
}
@ -863,6 +816,7 @@ pub fn make_test_description<R: Read>(
let has_msan = util::MSAN_SUPPORTED_TARGETS.contains(&&*config.target);
let has_tsan = util::TSAN_SUPPORTED_TARGETS.contains(&&*config.target);
let has_hwasan = util::HWASAN_SUPPORTED_TARGETS.contains(&&*config.target);
let has_memtag = util::MEMTAG_SUPPORTED_TARGETS.contains(&&*config.target);
// for `-Z gcc-ld=lld`
let has_rust_lld = config
.compile_lib_path
@ -899,9 +853,11 @@ pub fn make_test_description<R: Read>(
ignore |= !has_msan && config.parse_name_directive(ln, "needs-sanitizer-memory");
ignore |= !has_tsan && config.parse_name_directive(ln, "needs-sanitizer-thread");
ignore |= !has_hwasan && config.parse_name_directive(ln, "needs-sanitizer-hwaddress");
ignore |= !has_memtag && config.parse_name_directive(ln, "needs-sanitizer-memtag");
ignore |= config.target_panic == PanicStrategy::Abort
&& config.parse_name_directive(ln, "needs-unwind");
ignore |= config.target == "wasm32-unknown-unknown" && config.parse_check_run_results(ln);
ignore |= config.target == "wasm32-unknown-unknown"
&& config.parse_name_directive(ln, directives::CHECK_RUN_RESULTS);
ignore |= config.debugger == Some(Debugger::Cdb) && ignore_cdb(config, ln);
ignore |= config.debugger == Some(Debugger::Gdb) && ignore_gdb(config, ln);
ignore |= config.debugger == Some(Debugger::Lldb) && ignore_lldb(config, ln);

View file

@ -1274,6 +1274,16 @@ impl<'test> TestCx<'test> {
self.fatal_proc_rec("process did not return an error status", proc_res);
}
if self.props.known_bug {
if !expected_errors.is_empty() {
self.fatal_proc_rec(
"`known_bug` tests should not have an expected errors",
proc_res,
);
}
return;
}
// On Windows, keep all '\' path separators to match the paths reported in the JSON output
// from the compiler
let os_file_name = self.testpaths.file.display().to_string();
@ -1310,6 +1320,7 @@ impl<'test> TestCx<'test> {
}
None => {
// If the test is a known bug, don't require that the error is annotated
if self.is_unexpected_compiler_message(actual_error, expect_help, expect_note) {
self.error(&format!(
"{}:{}: unexpected {}: '{}'",

View file

@ -117,6 +117,9 @@ pub const TSAN_SUPPORTED_TARGETS: &[&str] = &[
pub const HWASAN_SUPPORTED_TARGETS: &[&str] =
&["aarch64-linux-android", "aarch64-unknown-linux-gnu"];
pub const MEMTAG_SUPPORTED_TARGETS: &[&str] =
&["aarch64-linux-android", "aarch64-unknown-linux-gnu"];
const BIG_ENDIAN: &[&str] = &[
"aarch64_be",
"armebv7r",

View file

@ -7,7 +7,7 @@ use std::path::Path;
const ENTRY_LIMIT: usize = 1000;
// FIXME: The following limits should be reduced eventually.
const ROOT_ENTRY_LIMIT: usize = 982;
const ROOT_ENTRY_LIMIT: usize = 983;
const ISSUES_ENTRY_LIMIT: usize = 2310;
fn check_entries(path: &Path, bad: &mut bool) {