diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:19:13 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:19:13 +0000 |
commit | 218caa410aa38c29984be31a5229b9fa717560ee (patch) | |
tree | c54bd55eeb6e4c508940a30e94c0032fbd45d677 /tests/ui/derived-errors | |
parent | Releasing progress-linux version 1.67.1+dfsg1-1~progress7.99u1. (diff) | |
download | rustc-218caa410aa38c29984be31a5229b9fa717560ee.tar.xz rustc-218caa410aa38c29984be31a5229b9fa717560ee.zip |
Merging upstream version 1.68.2+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ui/derived-errors')
-rw-r--r-- | tests/ui/derived-errors/issue-30580.rs | 17 | ||||
-rw-r--r-- | tests/ui/derived-errors/issue-30580.stderr | 9 | ||||
-rw-r--r-- | tests/ui/derived-errors/issue-31997-1.rs | 56 | ||||
-rw-r--r-- | tests/ui/derived-errors/issue-31997-1.stderr | 14 | ||||
-rw-r--r-- | tests/ui/derived-errors/issue-31997.rs | 18 | ||||
-rw-r--r-- | tests/ui/derived-errors/issue-31997.stderr | 9 |
6 files changed, 123 insertions, 0 deletions
diff --git a/tests/ui/derived-errors/issue-30580.rs b/tests/ui/derived-errors/issue-30580.rs new file mode 100644 index 000000000..6940fcf7c --- /dev/null +++ b/tests/ui/derived-errors/issue-30580.rs @@ -0,0 +1,17 @@ +// Test that we do not see uninformative region-related errors +// when we get some basic type-checking failure. See #30580. + +pub struct Foo { a: u32 } +pub struct Pass<'a, 'tcx: 'a>(&'a mut &'a (), &'a &'tcx ()); + +impl<'a, 'tcx> Pass<'a, 'tcx> +{ + pub fn tcx(&self) -> &'a &'tcx () { self.1 } + fn lol(&mut self, b: &Foo) + { + b.c; //~ ERROR no field `c` on type `&Foo` + self.tcx(); + } +} + +fn main() {} diff --git a/tests/ui/derived-errors/issue-30580.stderr b/tests/ui/derived-errors/issue-30580.stderr new file mode 100644 index 000000000..7bd0eaf77 --- /dev/null +++ b/tests/ui/derived-errors/issue-30580.stderr @@ -0,0 +1,9 @@ +error[E0609]: no field `c` on type `&Foo` + --> $DIR/issue-30580.rs:12:11 + | +LL | b.c; + | ^ help: a field with a similar name exists: `a` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0609`. diff --git a/tests/ui/derived-errors/issue-31997-1.rs b/tests/ui/derived-errors/issue-31997-1.rs new file mode 100644 index 000000000..90c1b498c --- /dev/null +++ b/tests/ui/derived-errors/issue-31997-1.rs @@ -0,0 +1,56 @@ +// Regression test for this example from #31997 -- main goal is to +// emit as minimal and precise an error set as possible. Ideally, we'd +// only emit the E0433 error below, but right now we emit two. + +use std::io::prelude::*; +// use std::collections::HashMap; +use std::io; + +#[derive(Debug)] +struct Instance { + name: String, + start: Option<String>, + end: Option<String>, +} + +fn main() { + let input = io::stdin(); + let mut input = input.lock(); + + let mut map = HashMap::new(); + //~^ ERROR E0433 + + for line in input.lines() { + let line = line.unwrap(); + println!("process: {}", line); + let mut parts = line.splitn(2, ":"); + let _logfile = parts.next().unwrap(); + let rest = parts.next().unwrap(); + let mut parts = line.split(" [-] "); + + let stamp = parts.next().unwrap(); + + let rest = parts.next().unwrap(); + let words = rest.split_whitespace().collect::<Vec<_>>(); + + let instance = words.iter().find(|a| a.starts_with("i-")).unwrap(); + let name = words[1].to_owned(); + let mut entry = map.entry(instance.to_owned()).or_insert(Instance { + name: name, + start: None, + end: None, + }); + + if rest.contains("terminating") { + assert!(entry.end.is_none()); + entry.end = Some(stamp.to_string()); + } + if rest.contains("waiting for") { + assert!(entry.start.is_none()); + entry.start = Some(stamp.to_string()); + } + + } + + println!("{:?}", map); +} diff --git a/tests/ui/derived-errors/issue-31997-1.stderr b/tests/ui/derived-errors/issue-31997-1.stderr new file mode 100644 index 000000000..2f4aabf84 --- /dev/null +++ b/tests/ui/derived-errors/issue-31997-1.stderr @@ -0,0 +1,14 @@ +error[E0433]: failed to resolve: use of undeclared type `HashMap` + --> $DIR/issue-31997-1.rs:20:19 + | +LL | let mut map = HashMap::new(); + | ^^^^^^^ use of undeclared type `HashMap` + | +help: consider importing this struct + | +LL | use std::collections::HashMap; + | + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0433`. diff --git a/tests/ui/derived-errors/issue-31997.rs b/tests/ui/derived-errors/issue-31997.rs new file mode 100644 index 000000000..ff619313a --- /dev/null +++ b/tests/ui/derived-errors/issue-31997.rs @@ -0,0 +1,18 @@ +// Test that the resolve failure does not lead to downstream type errors. +// See issue #31997. +#![allow(deprecated)] + +trait TheTrait { } + +fn closure<F, T>(x: F) -> Result<T, ()> + where F: FnMut() -> T, T: TheTrait, +{ + unimplemented!() +} + +fn foo() -> Result<(), ()> { + try!(closure(|| bar(core::ptr::null_mut()))); //~ ERROR cannot find function `bar` in this scope + Ok(()) +} + +fn main() { } diff --git a/tests/ui/derived-errors/issue-31997.stderr b/tests/ui/derived-errors/issue-31997.stderr new file mode 100644 index 000000000..b53c0cda8 --- /dev/null +++ b/tests/ui/derived-errors/issue-31997.stderr @@ -0,0 +1,9 @@ +error[E0425]: cannot find function `bar` in this scope + --> $DIR/issue-31997.rs:14:21 + | +LL | try!(closure(|| bar(core::ptr::null_mut()))); + | ^^^ not found in this scope + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0425`. |