-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of #96812 - cjgillot:no-lint-outllives-macro, r=petroche…
…nkov Do not lint on explicit outlives requirements from external macros. The current implementation of the list rightfully skipped where predicates from external macros. However, if the where predicate came from the current macro but the bounds were from an external macro, the lint still fired. Closes #96640
- Loading branch information
Showing
4 changed files
with
50 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
src/test/ui/rust-2018/auxiliary/edition-lint-infer-outlives-macro.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
pub fn foo() {} | ||
|
||
#[macro_export] | ||
macro_rules! gimme_a { | ||
($($mac:tt)*) => { $($mac)* { 'a } } | ||
} |
28 changes: 28 additions & 0 deletions
28
src/test/ui/rust-2018/edition-lint-infer-outlives-macro.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// edition:2018 | ||
// aux-build:edition-lint-infer-outlives-macro.rs | ||
|
||
// Test that the lint does not fire if the where predicate | ||
// is from the local crate, but all the bounds are from an | ||
// external macro. | ||
|
||
#![deny(explicit_outlives_requirements)] | ||
|
||
#[macro_use] | ||
extern crate edition_lint_infer_outlives_macro; | ||
|
||
macro_rules! make_foo { | ||
($a:tt) => { | ||
struct Foo<$a, 'b> where 'b: $a { | ||
foo: &$a &'b (), | ||
} | ||
} | ||
} | ||
|
||
gimme_a! {make_foo!} | ||
|
||
struct Bar<'a, 'b: 'a> { | ||
//~^ ERROR: outlives requirements can be inferred | ||
bar: &'a &'b (), | ||
} | ||
|
||
fn main() {} |
14 changes: 14 additions & 0 deletions
14
src/test/ui/rust-2018/edition-lint-infer-outlives-macro.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
error: outlives requirements can be inferred | ||
--> $DIR/edition-lint-infer-outlives-macro.rs:23:18 | ||
| | ||
LL | struct Bar<'a, 'b: 'a> { | ||
| ^^^^ help: remove this bound | ||
| | ||
note: the lint level is defined here | ||
--> $DIR/edition-lint-infer-outlives-macro.rs:8:9 | ||
| | ||
LL | #![deny(explicit_outlives_requirements)] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: aborting due to previous error | ||
|