forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
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 rust-lang#76914 - lcnr:path-no-more, r=ecstatic-morse
extend `Ty` and `TyCtxt` lints to self types blocked on rust-lang#76891 r? @ecstatic-morse cc @Aaron1011
- Loading branch information
Showing
5 changed files
with
83 additions
and
8 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
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
33 changes: 33 additions & 0 deletions
33
src/test/ui-fulldeps/internal-lints/pass_ty_by_ref_self.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,33 @@ | ||
// NOTE: This test doesn't actually require `fulldeps` | ||
// so we could instead use it as an `ui` test. | ||
// | ||
// Considering that all other `internal-lints` are tested here | ||
// this seems like the cleaner solution though. | ||
#![feature(rustc_attrs)] | ||
#![deny(rustc::ty_pass_by_reference)] | ||
#![allow(unused)] | ||
|
||
#[rustc_diagnostic_item = "TyCtxt"] | ||
struct TyCtxt<'tcx> { | ||
inner: &'tcx (), | ||
} | ||
|
||
impl<'tcx> TyCtxt<'tcx> { | ||
fn by_value(self) {} // OK | ||
fn by_ref(&self) {} //~ ERROR passing `TyCtxt<'tcx>` by reference | ||
} | ||
|
||
|
||
struct TyS<'tcx> { | ||
inner: &'tcx (), | ||
} | ||
|
||
#[rustc_diagnostic_item = "Ty"] | ||
type Ty<'tcx> = &'tcx TyS<'tcx>; | ||
|
||
impl<'tcx> TyS<'tcx> { | ||
fn by_value(self: Ty<'tcx>) {} | ||
fn by_ref(self: &Ty<'tcx>) {} //~ ERROR passing `Ty<'tcx>` by reference | ||
} | ||
|
||
fn main() {} |
20 changes: 20 additions & 0 deletions
20
src/test/ui-fulldeps/internal-lints/pass_ty_by_ref_self.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,20 @@ | ||
error: passing `TyCtxt<'tcx>` by reference | ||
--> $DIR/pass_ty_by_ref_self.rs:17:15 | ||
| | ||
LL | fn by_ref(&self) {} | ||
| ^^^^^ help: try passing by value: `TyCtxt<'tcx>` | ||
| | ||
note: the lint level is defined here | ||
--> $DIR/pass_ty_by_ref_self.rs:7:9 | ||
| | ||
LL | #![deny(rustc::ty_pass_by_reference)] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: passing `Ty<'tcx>` by reference | ||
--> $DIR/pass_ty_by_ref_self.rs:30:21 | ||
| | ||
LL | fn by_ref(self: &Ty<'tcx>) {} | ||
| ^^^^^^^^^ help: try passing by value: `Ty<'tcx>` | ||
|
||
error: aborting due to 2 previous errors | ||
|