-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #52756 - alexcrichton:cap-applicable, r=oli-obk
rustc: Disallow machine applicability in foreign macros Recent changes to lints disallowed lints from being emitted against code located in foreign macros, except for future-incompatible lints. For a future incompatible lint, however, the automatic suggestions may not be applicable! This commit updates this code path to force all applicability suggestions made to foreign macros to never be `MachineApplicable`. This should avoid rustfix actually attempting fixing these suggestions, causing non-compiling code to be produced. Closes rust-lang/cargo#5799
- Loading branch information
Showing
8 changed files
with
217 additions
and
35 deletions.
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
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
22 changes: 22 additions & 0 deletions
22
src/test/ui-fulldeps/rust-2018/auxiliary/suggestions-not-always-applicable.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,22 @@ | ||
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT | ||
// file at the top-level directory of this distribution and at | ||
// http://rust-lang.org/COPYRIGHT. | ||
// | ||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | ||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | ||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | ||
// option. This file may not be copied, modified, or distributed | ||
// except according to those terms. | ||
|
||
// no-prefer-dynamic | ||
|
||
#![crate_type = "proc-macro"] | ||
|
||
extern crate proc_macro; | ||
|
||
use proc_macro::*; | ||
|
||
#[proc_macro_attribute] | ||
pub fn foo(_attr: TokenStream, _f: TokenStream) -> TokenStream { | ||
"pub fn foo() -> ::Foo { ::Foo }".parse().unwrap() | ||
} |
37 changes: 37 additions & 0 deletions
37
src/test/ui-fulldeps/rust-2018/suggestions-not-always-applicable.fixed
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,37 @@ | ||
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT | ||
// file at the top-level directory of this distribution and at | ||
// http://rust-lang.org/COPYRIGHT. | ||
// | ||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | ||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | ||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | ||
// option. This file may not be copied, modified, or distributed | ||
// except according to those terms. | ||
|
||
// aux-build:suggestions-not-always-applicable.rs | ||
// compile-flags: --edition 2015 | ||
// run-rustfix | ||
// rustfix-only-machine-applicable | ||
// compile-pass | ||
|
||
#![feature(rust_2018_preview)] | ||
#![warn(rust_2018_compatibility)] | ||
|
||
extern crate suggestions_not_always_applicable as foo; | ||
|
||
pub struct Foo; | ||
|
||
mod test { | ||
use crate::foo::foo; | ||
|
||
#[foo] //~ WARN: absolute paths must start with | ||
//~| WARN: previously accepted | ||
//~| WARN: absolute paths | ||
//~| WARN: previously accepted | ||
fn main() { | ||
} | ||
} | ||
|
||
fn main() { | ||
test::foo(); | ||
} |
37 changes: 37 additions & 0 deletions
37
src/test/ui-fulldeps/rust-2018/suggestions-not-always-applicable.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,37 @@ | ||
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT | ||
// file at the top-level directory of this distribution and at | ||
// http://rust-lang.org/COPYRIGHT. | ||
// | ||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | ||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | ||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | ||
// option. This file may not be copied, modified, or distributed | ||
// except according to those terms. | ||
|
||
// aux-build:suggestions-not-always-applicable.rs | ||
// compile-flags: --edition 2015 | ||
// run-rustfix | ||
// rustfix-only-machine-applicable | ||
// compile-pass | ||
|
||
#![feature(rust_2018_preview)] | ||
#![warn(rust_2018_compatibility)] | ||
|
||
extern crate suggestions_not_always_applicable as foo; | ||
|
||
pub struct Foo; | ||
|
||
mod test { | ||
use crate::foo::foo; | ||
|
||
#[foo] //~ WARN: absolute paths must start with | ||
//~| WARN: previously accepted | ||
//~| WARN: absolute paths | ||
//~| WARN: previously accepted | ||
fn main() { | ||
} | ||
} | ||
|
||
fn main() { | ||
test::foo(); | ||
} |
24 changes: 24 additions & 0 deletions
24
src/test/ui-fulldeps/rust-2018/suggestions-not-always-applicable.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,24 @@ | ||
warning: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition | ||
--> $DIR/suggestions-not-always-applicable.rs:27:5 | ||
| | ||
LL | #[foo] //~ WARN: absolute paths must start with | ||
| ^^^^^^ | ||
| | ||
note: lint level defined here | ||
--> $DIR/suggestions-not-always-applicable.rs:18:9 | ||
| | ||
LL | #![warn(rust_2018_compatibility)] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^ | ||
= note: #[warn(absolute_paths_not_starting_with_crate)] implied by #[warn(rust_2018_compatibility)] | ||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition! | ||
= note: for more information, see issue TBD | ||
|
||
warning: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition | ||
--> $DIR/suggestions-not-always-applicable.rs:27:5 | ||
| | ||
LL | #[foo] //~ WARN: absolute paths must start with | ||
| ^^^^^^ | ||
| | ||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition! | ||
= note: for more information, see issue TBD | ||
|
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
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