forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 7
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 rust-lang#92329 - matthiaskrgr:rollup-l3b4fl1, r=matthi…
…askrgr Rollup of 7 pull requests Successful merges: - rust-lang#90586 (Relax priv-in-pub lint on generic bounds and where clauses of trait impls.) - rust-lang#92112 (Fix the error of checking `base_expr` twice in type_changing_struct_update) - rust-lang#92147 (rustc_builtin_macros: make asm mod public for rustfmt) - rust-lang#92161 (resolve: Minor miscellaneous cleanups from rust-lang#89059) - rust-lang#92264 (Remove `maybe_uninit_extra` feature from Vec docs) - rust-lang#92303 (Add test cases for issue rust-lang#26186) - rust-lang#92307 (Fix minor typos) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
- Loading branch information
Showing
21 changed files
with
437 additions
and
118 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
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
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
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
35 changes: 2 additions & 33 deletions
35
src/test/ui/const-generics/generic_const_exprs/eval-privacy.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 |
---|---|---|
@@ -1,43 +1,12 @@ | ||
warning: private type `fn(u8) -> u8 {my_const_fn}` in public interface (error E0446) | ||
--> $DIR/eval-privacy.rs:12:1 | ||
| | ||
LL | / impl<const U: u8> Trait for Const<U> | ||
LL | | | ||
LL | | | ||
LL | | | ||
... | | ||
LL | | } | ||
LL | | } | ||
| |_^ | ||
| | ||
= note: `#[warn(private_in_public)]` on by default | ||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! | ||
= note: for more information, see issue #34537 <https://github.com/rust-lang/rust/issues/34537> | ||
|
||
warning: private type `fn(u8) -> u8 {my_const_fn}` in public interface (error E0446) | ||
--> $DIR/eval-privacy.rs:12:1 | ||
| | ||
LL | / impl<const U: u8> Trait for Const<U> | ||
LL | | | ||
LL | | | ||
LL | | | ||
... | | ||
LL | | } | ||
LL | | } | ||
| |_^ | ||
| | ||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! | ||
= note: for more information, see issue #34537 <https://github.com/rust-lang/rust/issues/34537> | ||
|
||
error[E0446]: private type `fn(u8) -> u8 {my_const_fn}` in public interface | ||
--> $DIR/eval-privacy.rs:21:5 | ||
--> $DIR/eval-privacy.rs:16:5 | ||
| | ||
LL | type AssocTy = Const<{ my_const_fn(U) }>; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private type | ||
... | ||
LL | const fn my_const_fn(val: u8) -> u8 { | ||
| ----------------------------------- `fn(u8) -> u8 {my_const_fn}` declared as private | ||
|
||
error: aborting due to previous error; 2 warnings emitted | ||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0446`. |
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,62 @@ | ||
// check-pass | ||
use std::sync::Mutex; | ||
use std::cell::RefCell; | ||
use std::rc::Rc; | ||
use std::ops::*; | ||
|
||
//eefriedman example | ||
struct S<'a, T:FnMut() + 'static + ?Sized>(&'a mut T); | ||
impl<'a, T:?Sized + FnMut() + 'static> DerefMut for S<'a, T> { | ||
fn deref_mut(&mut self) -> &mut Self::Target { &mut self.0 } | ||
} | ||
impl<'a, T:?Sized + FnMut() + 'static> Deref for S<'a, T> { | ||
type Target = dyn FnMut() + 'a; | ||
fn deref(&self) -> &Self::Target { &self.0 } | ||
} | ||
|
||
//Ossipal example | ||
struct FunctionIcon { | ||
get_icon: Mutex<Box<dyn FnMut() -> u32>>, | ||
} | ||
|
||
impl FunctionIcon { | ||
fn get_icon(&self) -> impl '_ + std::ops::DerefMut<Target=Box<dyn FnMut() -> u32>> { | ||
self.get_icon.lock().unwrap() | ||
} | ||
|
||
fn load_icon(&self) { | ||
let mut get_icon = self.get_icon(); | ||
let _rgba_icon = (*get_icon)(); | ||
} | ||
} | ||
|
||
//shepmaster example | ||
struct Foo; | ||
|
||
impl Deref for Foo { | ||
type Target = dyn FnMut() + 'static; | ||
fn deref(&self) -> &Self::Target { | ||
unimplemented!() | ||
} | ||
} | ||
|
||
impl DerefMut for Foo { | ||
fn deref_mut(&mut self) -> &mut Self::Target { | ||
unimplemented!() | ||
} | ||
} | ||
|
||
fn main() { | ||
//eefriedman example | ||
let mut f = ||{}; | ||
let mut s = S(&mut f); | ||
s(); | ||
|
||
//Diggsey/Mark-Simulacrum example | ||
let a: Rc<RefCell<dyn FnMut()>> = Rc::new(RefCell::new(||{})); | ||
a.borrow_mut()(); | ||
|
||
//shepmaster example | ||
let mut t = Foo; | ||
t(); | ||
} |
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
Oops, something went wrong.