Try to render shorthand differently
This commit is contained in:
parent
33651f49a0
commit
1952b87780
2 changed files with 12 additions and 9 deletions
|
@ -205,9 +205,15 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
|||
|
||||
if self_ty.is_fn() {
|
||||
let fn_sig = self_ty.fn_sig(self.tcx);
|
||||
let shortname = match fn_sig.safety() {
|
||||
let shortname = if let ty::FnDef(def_id, _) = self_ty.kind()
|
||||
&& self.tcx.codegen_fn_attrs(def_id).safe_target_features
|
||||
{
|
||||
"#[target_feature] fn"
|
||||
} else {
|
||||
match fn_sig.safety() {
|
||||
hir::Safety::Safe => "fn",
|
||||
hir::Safety::Unsafe => "unsafe fn",
|
||||
}
|
||||
};
|
||||
flags.push((sym::_Self, Some(shortname.to_owned())));
|
||||
}
|
||||
|
|
|
@ -2,12 +2,11 @@ error[E0277]: expected a `Fn()` closure, found `#[target_features] fn() {foo}`
|
|||
--> $DIR/fn-traits.rs:24:10
|
||||
|
|
||||
LL | call(foo);
|
||||
| ---- ^^^ call the function in a closure: `|| unsafe { /* code */ }`
|
||||
| ---- ^^^ expected an `Fn()` closure, found `#[target_features] fn() {foo}`
|
||||
| |
|
||||
| required by a bound introduced by this call
|
||||
|
|
||||
= help: the trait `Fn()` is not implemented for fn item `#[target_features] fn() {foo}`
|
||||
= note: unsafe function cannot be called generically without an unsafe block
|
||||
= note: wrap the `#[target_features] fn() {foo}` in a closure with no arguments: `|| { /* code */ }`
|
||||
= note: `#[target_feature]` functions do not implement the `Fn` traits
|
||||
note: required by a bound in `call`
|
||||
|
@ -20,12 +19,11 @@ error[E0277]: expected a `FnMut()` closure, found `#[target_features] fn() {foo}
|
|||
--> $DIR/fn-traits.rs:25:14
|
||||
|
|
||||
LL | call_mut(foo);
|
||||
| -------- ^^^ call the function in a closure: `|| unsafe { /* code */ }`
|
||||
| -------- ^^^ expected an `FnMut()` closure, found `#[target_features] fn() {foo}`
|
||||
| |
|
||||
| required by a bound introduced by this call
|
||||
|
|
||||
= help: the trait `FnMut()` is not implemented for fn item `#[target_features] fn() {foo}`
|
||||
= note: unsafe function cannot be called generically without an unsafe block
|
||||
= note: wrap the `#[target_features] fn() {foo}` in a closure with no arguments: `|| { /* code */ }`
|
||||
= note: `#[target_feature]` functions do not implement the `Fn` traits
|
||||
note: required by a bound in `call_mut`
|
||||
|
@ -38,12 +36,11 @@ error[E0277]: expected a `FnOnce()` closure, found `#[target_features] fn() {foo
|
|||
--> $DIR/fn-traits.rs:26:15
|
||||
|
|
||||
LL | call_once(foo);
|
||||
| --------- ^^^ call the function in a closure: `|| unsafe { /* code */ }`
|
||||
| --------- ^^^ expected an `FnOnce()` closure, found `#[target_features] fn() {foo}`
|
||||
| |
|
||||
| required by a bound introduced by this call
|
||||
|
|
||||
= help: the trait `FnOnce()` is not implemented for fn item `#[target_features] fn() {foo}`
|
||||
= note: unsafe function cannot be called generically without an unsafe block
|
||||
= note: wrap the `#[target_features] fn() {foo}` in a closure with no arguments: `|| { /* code */ }`
|
||||
= note: `#[target_feature]` functions do not implement the `Fn` traits
|
||||
note: required by a bound in `call_once`
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue