Skip to content

Commit bcded33

Browse files
committed
Auto merge of #154909 - JonathanBrouwer:rollup-44bqfTG, r=JonathanBrouwer
Rollup of 2 pull requests Successful merges: - #154875 (Avoid duplicate diagnostic args in `RegionOriginNote::WithName`) - #154898 (Use debug! instead of info!)
2 parents a92a99e + 4be8f65 commit bcded33

File tree

4 files changed

+71
-5
lines changed

4 files changed

+71
-5
lines changed

compiler/rustc_hir/src/attrs/diagnostic.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ pub use rustc_ast::attr::data_structures::*;
66
use rustc_macros::{Decodable, Encodable, HashStable_Generic, PrintAttribute};
77
use rustc_span::{DesugaringKind, Span, Symbol, kw};
88
use thin_vec::ThinVec;
9-
use tracing::{debug, info};
9+
use tracing::debug;
1010

1111
use crate::attrs::PrintAttribute;
1212

@@ -58,7 +58,9 @@ impl Directive {
5858
args: &FormatArgs,
5959
) -> CustomDiagnostic {
6060
let this = &args.this;
61-
info!("eval({self:?}, this={this}, options={condition_options:?}, args ={args:?})");
61+
debug!(
62+
"Directive::eval({self:?}, this={this}, options={condition_options:?}, args ={args:?})"
63+
);
6264

6365
let Some(condition_options) = condition_options else {
6466
debug_assert!(

compiler/rustc_trait_selection/src/errors.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -442,9 +442,11 @@ impl Subdiagnostic for RegionOriginNote<'_> {
442442
label_or_note(diag, span, msg);
443443
}
444444
RegionOriginNote::WithName { span, msg, name, continues } => {
445-
diag.arg("name", name);
446-
diag.arg("continues", continues);
447-
label_or_note(diag, span, msg);
445+
label_or_note(
446+
diag,
447+
span,
448+
msg.arg("name", name).arg("continues", continues).format(),
449+
);
448450
}
449451
RegionOriginNote::WithRequirement {
450452
span,
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Regression test for https://github.com/rust-lang/rust/issues/152936
2+
3+
use std::collections::hash_map::{HashMap, Keys};
4+
use std::marker::PhantomData;
5+
6+
trait MapAssertion<'a, K, V, R> {
7+
fn key_set(&self) -> Subject<Keys<K, V>, (), R>;
8+
}
9+
10+
struct Subject<'a, T, V, R>(PhantomData<(&'a T, V, R)>);
11+
12+
impl<'a, K, V, R> MapAssertion<'a, K, V, R> for Subject<'a, HashMap<K, V>, (), R> {
13+
fn key_set(&self) -> Subject<'static, Keys<K, V>, (), R> {
14+
//~^ ERROR cannot infer an appropriate lifetime for lifetime parameter '_ in generic type due to conflicting requirements
15+
//~| ERROR mismatched types
16+
}
17+
}
18+
19+
fn main() {}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
error[E0803]: cannot infer an appropriate lifetime for lifetime parameter '_ in generic type due to conflicting requirements
2+
--> $DIR/impl-trait-lifetime-conflict-hashmap-keys.rs:13:5
3+
|
4+
LL | fn key_set(&self) -> Subject<'static, Keys<K, V>, (), R> {
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6+
|
7+
note: first, the lifetime cannot outlive the lifetime `'a` as defined here...
8+
--> $DIR/impl-trait-lifetime-conflict-hashmap-keys.rs:12:6
9+
|
10+
LL | impl<'a, K, V, R> MapAssertion<'a, K, V, R> for Subject<'a, HashMap<K, V>, (), R> {
11+
| ^^
12+
note: ...so that the reference type `&Subject<'a, HashMap<K, V>, (), R>` does not outlive the data it points at
13+
--> $DIR/impl-trait-lifetime-conflict-hashmap-keys.rs:13:5
14+
|
15+
LL | fn key_set(&self) -> Subject<'static, Keys<K, V>, (), R> {
16+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
17+
= note: but, the lifetime must be valid for the static lifetime...
18+
note: ...so that the type `std::collections::hash_map::Keys<'_, K, V>` will meet its required lifetime bounds...
19+
--> $DIR/impl-trait-lifetime-conflict-hashmap-keys.rs:13:5
20+
|
21+
LL | fn key_set(&self) -> Subject<'static, Keys<K, V>, (), R> {
22+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
23+
note: ...that is required by this bound
24+
--> $DIR/impl-trait-lifetime-conflict-hashmap-keys.rs:10:29
25+
|
26+
LL | struct Subject<'a, T, V, R>(PhantomData<(&'a T, V, R)>);
27+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
28+
29+
error[E0308]: mismatched types
30+
--> $DIR/impl-trait-lifetime-conflict-hashmap-keys.rs:13:26
31+
|
32+
LL | fn key_set(&self) -> Subject<'static, Keys<K, V>, (), R> {
33+
| ------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Subject<'_, Keys<'_, K, V>, (), R>`, found `()`
34+
| |
35+
| implicitly returns `()` as its body has no tail or `return` expression
36+
|
37+
= note: expected struct `Subject<'static, std::collections::hash_map::Keys<'_, K, V>, (), R>`
38+
found unit type `()`
39+
40+
error: aborting due to 2 previous errors
41+
42+
Some errors have detailed explanations: E0308, E0803.
43+
For more information about an error, try `rustc --explain E0308`.

0 commit comments

Comments
 (0)