Skip to content

Commit c4948e7

Browse files
committed
Do not show in this macro invocation for compiler desugared spans
1 parent efcef24 commit c4948e7

File tree

5 files changed

+47
-1
lines changed

5 files changed

+47
-1
lines changed

src/librustc_errors/emitter.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -677,7 +677,8 @@ impl EmitterWriter {
677677
}
678678
// Check to make sure we're not in any <*macros>
679679
if !cm.span_to_filename(def_site).contains("macros>") &&
680-
!trace.macro_decl_name.starts_with("#[") {
680+
!trace.macro_decl_name.starts_with("#[") &&
681+
!trace.macro_decl_name.starts_with("desugaring of") {
681682
new_labels.push((trace.call_site,
682683
"in this macro invocation".to_string()));
683684
break;

src/test/compile-fail/E0297.rs

+1
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,5 @@ fn main() {
1414
for Some(x) in xs {}
1515
//~^ ERROR E0297
1616
//~| NOTE pattern `None` not covered
17+
//~| NOTE in this expansion of desugaring of `for`
1718
}

src/test/compile-fail/if-let-arm-types.rs

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ fn main() {
1313
//~^ expected (), found integral variable
1414
//~| expected type `()`
1515
//~| found type `{integer}`
16+
//~| NOTE: in this expansion of desugaring of `if let`
17+
//~| NOTE: in this expansion of desugaring of `if let`
1618
()
1719
} else { //~ NOTE: `if let` arm with an incompatible type
1820
1

src/test/ui/compiler_desugaring.rs

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// checks that errors on compiler-desugared spans don't have
12+
// useless `in this macro invocation` notes.
13+
14+
fn main() {
15+
let _ = foo();
16+
}
17+
18+
fn foo() -> Result<(), ()> {
19+
let _: i32 = bar()?; //~ ERROR E0308
20+
Ok(())
21+
}
22+
23+
fn bar() -> Result<(), ()> {
24+
Ok(())
25+
}
26+
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
error[E0308]: match arms have incompatible types
2+
--> $DIR/compiler_desugaring.rs:19:18
3+
|
4+
19 | let _: i32 = bar()?; //~ ERROR E0308
5+
| ^^^^^^ expected i32, found ()
6+
|
7+
= note: expected type `i32`
8+
found type `()`
9+
note: match arm with an incompatible type
10+
--> $DIR/compiler_desugaring.rs:19:18
11+
|
12+
19 | let _: i32 = bar()?; //~ ERROR E0308
13+
| ^^^^^^
14+
15+
error: aborting due to previous error
16+

0 commit comments

Comments
 (0)