Rollup merge of #123673 - oli-obk:sig_wfcheck_ice, r=jieyouxu,estebank
Don't ICE for kind mismatches during error rendering fixes #123457 also some test suite cleanups to make backtraces easier to read
This commit is contained in:
commit
4aaa8f964f
5 changed files with 72 additions and 3 deletions
|
@ -1977,6 +1977,9 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
||||||
for (obligation_arg, impl_arg) in
|
for (obligation_arg, impl_arg) in
|
||||||
std::iter::zip(obligation_trait_ref.args, impl_trait_ref.args)
|
std::iter::zip(obligation_trait_ref.args, impl_trait_ref.args)
|
||||||
{
|
{
|
||||||
|
if (obligation_arg, impl_arg).references_error() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if let Err(terr) =
|
if let Err(terr) =
|
||||||
ocx.eq(&ObligationCause::dummy(), param_env, impl_arg, obligation_arg)
|
ocx.eq(&ObligationCause::dummy(), param_env, impl_arg, obligation_arg)
|
||||||
{
|
{
|
||||||
|
|
|
@ -265,7 +265,10 @@ impl TestProps {
|
||||||
aux_bins: vec![],
|
aux_bins: vec![],
|
||||||
aux_crates: vec![],
|
aux_crates: vec![],
|
||||||
revisions: vec![],
|
revisions: vec![],
|
||||||
rustc_env: vec![("RUSTC_ICE".to_string(), "0".to_string())],
|
rustc_env: vec![
|
||||||
|
("RUSTC_ICE".to_string(), "0".to_string()),
|
||||||
|
("RUST_BACKTRACE".to_string(), "short".to_string()),
|
||||||
|
],
|
||||||
unset_rustc_env: vec![("RUSTC_LOG_COLOR".to_string())],
|
unset_rustc_env: vec![("RUSTC_LOG_COLOR".to_string())],
|
||||||
exec_env: vec![],
|
exec_env: vec![],
|
||||||
unset_exec_env: vec![],
|
unset_exec_env: vec![],
|
||||||
|
|
|
@ -2173,8 +2173,8 @@ impl<'test> TestCx<'test> {
|
||||||
let aux_dir = self.aux_output_dir();
|
let aux_dir = self.aux_output_dir();
|
||||||
self.build_all_auxiliary(&self.testpaths, &aux_dir, &mut rustc);
|
self.build_all_auxiliary(&self.testpaths, &aux_dir, &mut rustc);
|
||||||
|
|
||||||
self.props.unset_rustc_env.iter().fold(&mut rustc, Command::env_remove);
|
|
||||||
rustc.envs(self.props.rustc_env.clone());
|
rustc.envs(self.props.rustc_env.clone());
|
||||||
|
self.props.unset_rustc_env.iter().fold(&mut rustc, Command::env_remove);
|
||||||
self.compose_and_run(
|
self.compose_and_run(
|
||||||
rustc,
|
rustc,
|
||||||
self.config.compile_lib_path.to_str().unwrap(),
|
self.config.compile_lib_path.to_str().unwrap(),
|
||||||
|
@ -2220,10 +2220,10 @@ impl<'test> TestCx<'test> {
|
||||||
);
|
);
|
||||||
aux_cx.build_all_auxiliary(of, &aux_dir, &mut aux_rustc);
|
aux_cx.build_all_auxiliary(of, &aux_dir, &mut aux_rustc);
|
||||||
|
|
||||||
|
aux_rustc.envs(aux_props.rustc_env.clone());
|
||||||
for key in &aux_props.unset_rustc_env {
|
for key in &aux_props.unset_rustc_env {
|
||||||
aux_rustc.env_remove(key);
|
aux_rustc.env_remove(key);
|
||||||
}
|
}
|
||||||
aux_rustc.envs(aux_props.rustc_env.clone());
|
|
||||||
|
|
||||||
let (aux_type, crate_type) = if is_bin {
|
let (aux_type, crate_type) = if is_bin {
|
||||||
(AuxType::Bin, Some("bin"))
|
(AuxType::Bin, Some("bin"))
|
||||||
|
|
24
tests/ui/const-generics/kind_mismatch.rs
Normal file
24
tests/ui/const-generics/kind_mismatch.rs
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
//! This test used to ICE in typeck because of the type/const mismatch,
|
||||||
|
//! even though wfcheck already errored.
|
||||||
|
//! issue: rust-lang/rust#123457
|
||||||
|
|
||||||
|
pub struct KeyHolder<const K: u8> {}
|
||||||
|
|
||||||
|
pub trait ContainsKey<const K: u8> {}
|
||||||
|
|
||||||
|
pub trait SubsetExcept<P> {}
|
||||||
|
|
||||||
|
impl<K> ContainsKey<K> for KeyHolder<K> {}
|
||||||
|
//~^ ERROR: type provided when a constant was expected
|
||||||
|
//~| ERROR: type provided when a constant was expected
|
||||||
|
|
||||||
|
impl<P, T: ContainsKey<0>> SubsetExcept<P> for T {}
|
||||||
|
|
||||||
|
pub fn remove_key<K, S: SubsetExcept<K>>() -> S {
|
||||||
|
loop {}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let map: KeyHolder<0> = remove_key::<_, _>();
|
||||||
|
//~^ ERROR: the trait bound `KeyHolder<0>: SubsetExcept<_>` is not satisfied
|
||||||
|
}
|
39
tests/ui/const-generics/kind_mismatch.stderr
Normal file
39
tests/ui/const-generics/kind_mismatch.stderr
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
error[E0747]: type provided when a constant was expected
|
||||||
|
--> $DIR/kind_mismatch.rs:11:38
|
||||||
|
|
|
||||||
|
LL | impl<K> ContainsKey<K> for KeyHolder<K> {}
|
||||||
|
| - ^
|
||||||
|
| |
|
||||||
|
| help: consider changing this type parameter to a const parameter: `const K: u8`
|
||||||
|
|
||||||
|
error[E0747]: type provided when a constant was expected
|
||||||
|
--> $DIR/kind_mismatch.rs:11:21
|
||||||
|
|
|
||||||
|
LL | impl<K> ContainsKey<K> for KeyHolder<K> {}
|
||||||
|
| - ^
|
||||||
|
| |
|
||||||
|
| help: consider changing this type parameter to a const parameter: `const K: u8`
|
||||||
|
|
||||||
|
error[E0277]: the trait bound `KeyHolder<0>: SubsetExcept<_>` is not satisfied
|
||||||
|
--> $DIR/kind_mismatch.rs:22:45
|
||||||
|
|
|
||||||
|
LL | let map: KeyHolder<0> = remove_key::<_, _>();
|
||||||
|
| ^ the trait `ContainsKey<0>` is not implemented for `KeyHolder<0>`, which is required by `KeyHolder<0>: SubsetExcept<_>`
|
||||||
|
|
|
||||||
|
note: required for `KeyHolder<0>` to implement `SubsetExcept<_>`
|
||||||
|
--> $DIR/kind_mismatch.rs:15:28
|
||||||
|
|
|
||||||
|
LL | impl<P, T: ContainsKey<0>> SubsetExcept<P> for T {}
|
||||||
|
| -------------- ^^^^^^^^^^^^^^^ ^
|
||||||
|
| |
|
||||||
|
| unsatisfied trait bound introduced here
|
||||||
|
note: required by a bound in `remove_key`
|
||||||
|
--> $DIR/kind_mismatch.rs:17:25
|
||||||
|
|
|
||||||
|
LL | pub fn remove_key<K, S: SubsetExcept<K>>() -> S {
|
||||||
|
| ^^^^^^^^^^^^^^^ required by this bound in `remove_key`
|
||||||
|
|
||||||
|
error: aborting due to 3 previous errors
|
||||||
|
|
||||||
|
Some errors have detailed explanations: E0277, E0747.
|
||||||
|
For more information about an error, try `rustc --explain E0277`.
|
Loading…
Add table
Add a link
Reference in a new issue