Auto merge of #39384 - wesleywiser:fix_fixmes, r=alexcrichton
Resolve a bunch of fixmes Resolves 56 fixmes in test code related to `box` syntax.
This commit is contained in:
commit
3b24c70012
@ -66,7 +66,6 @@ fn test_writer_hasher() {
|
||||
assert_eq!(hash(& s), 97 + 0xFF);
|
||||
let cs: &[u8] = &[1, 2, 3];
|
||||
assert_eq!(hash(& cs), 9);
|
||||
// FIXME (#22405): Replace `Box::new` with `box` here when/if possible.
|
||||
let cs: Box<[u8]> = Box::new([1, 2, 3]);
|
||||
assert_eq!(hash(& cs), 9);
|
||||
|
||||
|
@ -700,7 +700,6 @@ fn test_collect() {
|
||||
|
||||
#[test]
|
||||
fn test_all() {
|
||||
// FIXME (#22405): Replace `Box::new` with `box` here when/if possible.
|
||||
let v: Box<[isize]> = Box::new([1, 2, 3, 4, 5]);
|
||||
assert!(v.iter().all(|&x| x < 10));
|
||||
assert!(!v.iter().all(|&x| x % 2 == 0));
|
||||
@ -710,7 +709,6 @@ fn test_all() {
|
||||
|
||||
#[test]
|
||||
fn test_any() {
|
||||
// FIXME (#22405): Replace `Box::new` with `box` here when/if possible.
|
||||
let v: Box<[isize]> = Box::new([1, 2, 3, 4, 5]);
|
||||
assert!(v.iter().any(|&x| x < 10));
|
||||
assert!(v.iter().any(|&x| x % 2 == 0));
|
||||
|
@ -36,11 +36,9 @@ pub fn plugin_registrar(reg: &mut Registry) {
|
||||
reg.register_macro("identity", expand_identity);
|
||||
reg.register_syntax_extension(
|
||||
Symbol::intern("into_multi_foo"),
|
||||
// FIXME (#22405): Replace `Box::new` with `box` here when/if possible.
|
||||
MultiModifier(Box::new(expand_into_foo_multi)));
|
||||
reg.register_syntax_extension(
|
||||
Symbol::intern("duplicate"),
|
||||
// FIXME (#22405): Replace `Box::new` with `box` here when/if possible.
|
||||
MultiDecorator(Box::new(expand_duplicate)));
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,6 @@ use std::collections::HashMap;
|
||||
fn main() {
|
||||
let tmp: Box<_>;
|
||||
let mut buggy_map: HashMap<usize, &usize> = HashMap::new();
|
||||
// FIXME (#22405): Replace `Box::new` with `box` here when/if possible.
|
||||
buggy_map.insert(42, &*Box::new(1)); //~ ERROR borrowed value does not live long enough
|
||||
|
||||
// but it is ok if we use a temporary
|
||||
|
@ -16,7 +16,6 @@ trait Trait { fn foo(&self) {} }
|
||||
impl Trait for Foo {}
|
||||
|
||||
pub fn main() {
|
||||
// FIXME (#22405): Replace `Box::new` with `box` here when/if possible.
|
||||
let x: Box<Trait> = Box::new(Foo);
|
||||
let _y: &Trait = x; //~ ERROR mismatched types
|
||||
//~| expected type `&Trait`
|
||||
|
@ -41,7 +41,6 @@ impl ToBar for Bar1 {
|
||||
pub fn main() {
|
||||
// Assignment.
|
||||
let f5: &mut Fat<ToBar> = &mut Fat { f1: 5, f2: "some str", ptr: Bar1 {f :42} };
|
||||
// FIXME (#22405): Replace `Box::new` with `box` here when/if possible.
|
||||
let z: Box<ToBar> = Box::new(Bar1 {f: 36});
|
||||
f5.ptr = *z;
|
||||
//~^ ERROR `ToBar: std::marker::Sized` is not satisfied
|
||||
|
@ -41,7 +41,6 @@ impl ToBar for Bar1 {
|
||||
pub fn main() {
|
||||
// Assignment.
|
||||
let f5: &mut Fat<ToBar> = &mut Fat { f1: 5, f2: "some str", ptr: Bar1 {f :42} };
|
||||
// FIXME (#22405): Replace `Box::new` with `box` here when/if possible.
|
||||
let z: Box<ToBar> = Box::new(Bar1 {f: 36});
|
||||
f5.ptr = Bar1 {f: 36};
|
||||
//~^ ERROR mismatched types
|
||||
|
@ -9,7 +9,6 @@
|
||||
// except according to those terms.
|
||||
|
||||
fn test<'x>(x: &'x isize) {
|
||||
// FIXME (#22405): Replace `Box::new` with `box` here when/if possible.
|
||||
drop::<Box<for<'z> FnMut(&'z isize) -> &'z isize>>(Box::new(|z| {
|
||||
x //~ ERROR E0312
|
||||
}));
|
||||
|
@ -15,7 +15,6 @@ struct Test {
|
||||
}
|
||||
|
||||
fn main() {
|
||||
// FIXME (#22405): Replace `Box::new` with `box` here when/if possible.
|
||||
let closure: Box<Fn()+'static> = Box::new(|| ());
|
||||
let test = box Test { func: closure }; //~ ERROR mismatched types
|
||||
}
|
||||
|
@ -13,7 +13,6 @@ fn main() {
|
||||
//~^ ERROR cast to unsized type: `&[usize; 2]` as `[usize]`
|
||||
//~^^ HELP consider using an implicit coercion to `&[usize]` instead
|
||||
|
||||
// FIXME (#22405): Replace `std::boxed::Box::new` with `box` here when/if possible.
|
||||
let _bar = Box::new(1_usize) as std::fmt::Debug;
|
||||
//~^ ERROR cast to unsized type: `std::boxed::Box<usize>` as `std::fmt::Debug`
|
||||
//~^^ HELP try casting to a `Box` instead
|
||||
|
@ -12,7 +12,6 @@
|
||||
// and rejected.
|
||||
|
||||
fn main() {
|
||||
// FIXME (#22405): Replace `Box::new` with `box` here when/if possible.
|
||||
(|| Box::new(*(&[0][..])))();
|
||||
//~^ ERROR `[{integer}]: std::marker::Sized` is not satisfied
|
||||
}
|
||||
|
@ -10,8 +10,6 @@
|
||||
|
||||
use std::cell::RefCell;
|
||||
|
||||
// FIXME (#22405): Replace `Box::new` with `box` here when/if possible.
|
||||
|
||||
fn main() {
|
||||
let mut y = 1;
|
||||
let c = RefCell::new(vec![]);
|
||||
|
@ -25,13 +25,11 @@ fn main() {
|
||||
let _woohoo = (&my_struct).priv_field;
|
||||
//~^ ERROR field `priv_field` of struct `my_mod::MyStruct` is private
|
||||
|
||||
// FIXME (#22405): Replace `Box::new` with `box` here when/if possible.
|
||||
let _woohoo = (Box::new(my_struct)).priv_field;
|
||||
//~^ ERROR field `priv_field` of struct `my_mod::MyStruct` is private
|
||||
|
||||
(&my_struct).happyfun(); //~ ERROR method `happyfun` is private
|
||||
|
||||
// FIXME (#22405): Replace `Box::new` with `box` here when/if possible.
|
||||
(Box::new(my_struct)).happyfun(); //~ ERROR method `happyfun` is private
|
||||
let nope = my_struct.priv_field;
|
||||
//~^ ERROR field `priv_field` of struct `my_mod::MyStruct` is private
|
||||
|
@ -13,7 +13,6 @@
|
||||
fn id<T>(t: T) -> T { t }
|
||||
|
||||
fn f<'r, T>(v: &'r T) -> Box<FnMut() -> T + 'r> {
|
||||
// FIXME (#22405): Replace `Box::new` with `box` here when/if possible.
|
||||
id(Box::new(|| *v))
|
||||
//~^ ERROR E0373
|
||||
//~| NOTE `v` is borrowed here
|
||||
|
@ -24,7 +24,6 @@ impl<K, V> Map<K, V> for HashMap<K, V> {}
|
||||
fn main() {
|
||||
let x: Box<HashMap<isize, isize>> = box HashMap::new();
|
||||
let x: Box<Map<isize, isize>> = x;
|
||||
// FIXME (#22405): Replace `Box::new` with `box` here when/if possible.
|
||||
let y: Box<Map<usize, isize>> = Box::new(x);
|
||||
//~^ ERROR `std::boxed::Box<Map<isize, isize>>: Map<usize, isize>` is not satisfied
|
||||
}
|
||||
|
@ -38,7 +38,6 @@ fn innocent_looking_victim() {
|
||||
}
|
||||
|
||||
fn conspirator<F>(mut f: F) where F: FnMut(&mut R, bool) {
|
||||
// FIXME (#22405): Replace `Box::new` with `box` here when/if possible.
|
||||
let mut r = R {c: Box::new(f)};
|
||||
f(&mut r, false) //~ ERROR use of moved value
|
||||
}
|
||||
|
@ -14,8 +14,6 @@
|
||||
trait Foo {}
|
||||
impl<'a> Foo for &'a [u8] {}
|
||||
|
||||
// FIXME (#22405): Replace `Box::new` with `box` here when/if possible.
|
||||
|
||||
fn a(v: &[u8]) -> Box<Foo + 'static> {
|
||||
let x: Box<Foo + 'static> = Box::new(v);
|
||||
//~^ ERROR cannot infer an appropriate lifetime due to conflicting
|
||||
|
@ -10,8 +10,6 @@
|
||||
|
||||
#![feature(box_syntax)]
|
||||
|
||||
// FIXME (#22405): Replace `Box::new` with `box` here when/if possible.
|
||||
|
||||
trait X {}
|
||||
|
||||
trait Iter {
|
||||
|
@ -8,8 +8,6 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// FIXME (#22405): Replace `Box::new` with `box` here when/if possible.
|
||||
|
||||
trait X { fn foo(&self) {} }
|
||||
|
||||
fn p1<T>(v: T) -> Box<X+'static>
|
||||
|
@ -8,8 +8,6 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// FIXME (#22405): Replace `Box::new` with `box` here when/if possible.
|
||||
|
||||
fn ignore<T>(t: T) {}
|
||||
|
||||
fn nested<'x>(x: &'x isize) {
|
||||
|
@ -8,8 +8,6 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// FIXME (#22405): Replace `Box::new` with `box` here when/if possible.
|
||||
|
||||
fn borrowed_proc<'a>(x: &'a isize) -> Box<FnMut()->(isize) + 'a> {
|
||||
// This is legal, because the region bound on `proc`
|
||||
// states that it captures `x`.
|
||||
|
@ -21,7 +21,6 @@ fn box_it<'r>(x: Box<FnMut() + 'r>) -> closure_box<'r> {
|
||||
fn main() {
|
||||
let mut cl_box = {
|
||||
let mut i = 3;
|
||||
// FIXME (#22405): Replace `Box::new` with `box` here when/if possible.
|
||||
box_it(Box::new(|| i += 1)) //~ ERROR `i` does not live long enough
|
||||
};
|
||||
cl_box.cl.call_mut(());
|
||||
|
@ -23,7 +23,6 @@ impl Trait<&'static str> for Struct {
|
||||
}
|
||||
|
||||
fn main() {
|
||||
// FIXME (#22405): Replace `Box::new` with `box` here when/if possible.
|
||||
let s: Box<Trait<isize>> = Box::new(Struct { person: "Fred" });
|
||||
//~^ ERROR `Struct: Trait<isize>` is not satisfied
|
||||
s.f(1);
|
||||
|
@ -25,6 +25,5 @@ impl Trait<&'static str> for Struct {
|
||||
fn main() {
|
||||
let person = "Fred".to_string();
|
||||
let person: &str = &person; //~ ERROR `person` does not live long enough
|
||||
// FIXME (#22405): Replace `Box::new` with `box` here when/if possible.
|
||||
let s: Box<Trait<&'static str>> = Box::new(Struct { person: person });
|
||||
}
|
||||
|
@ -18,8 +18,6 @@ fn to_fn<A,F:Fn<A>>(f: F) -> F { f }
|
||||
fn to_fn_mut<A,F:FnMut<A>>(f: F) -> F { f }
|
||||
fn to_fn_once<A,F:FnOnce<A>>(f: F) -> F { f }
|
||||
|
||||
// FIXME (#22405): Replace `Box::new` with `box` here when/if possible.
|
||||
|
||||
fn main() {
|
||||
// By-ref cases
|
||||
{
|
||||
|
@ -18,7 +18,6 @@ impl Drop for r {
|
||||
}
|
||||
|
||||
fn main() {
|
||||
// FIXME (#22405): Replace `Box::new` with `box` here when/if possible.
|
||||
let i = Box::new(r { b: true });
|
||||
let _j = i.clone(); //~ ERROR no method named `clone` found
|
||||
println!("{:?}", i);
|
||||
|
@ -38,15 +38,12 @@ pub fn plugin_registrar(reg: &mut Registry) {
|
||||
reg.register_macro("identity", expand_identity);
|
||||
reg.register_syntax_extension(
|
||||
Symbol::intern("into_multi_foo"),
|
||||
// FIXME (#22405): Replace `Box::new` with `box` here when/if possible.
|
||||
MultiModifier(Box::new(expand_into_foo_multi)));
|
||||
reg.register_syntax_extension(
|
||||
Symbol::intern("duplicate"),
|
||||
// FIXME (#22405): Replace `Box::new` with `box` here when/if possible.
|
||||
MultiDecorator(Box::new(expand_duplicate)));
|
||||
reg.register_syntax_extension(
|
||||
Symbol::intern("caller"),
|
||||
// FIXME (#22405): Replace `Box::new` with `box` here when/if possible.
|
||||
MultiDecorator(Box::new(expand_caller)));
|
||||
}
|
||||
|
||||
|
@ -48,6 +48,5 @@ impl TTMacroExpander for Expander {
|
||||
pub fn plugin_registrar(reg: &mut Registry) {
|
||||
let args = reg.args().to_owned();
|
||||
reg.register_syntax_extension(Symbol::intern("plugin_args"),
|
||||
// FIXME (#22405): Replace `Box::new` with `box` here when/if possible.
|
||||
NormalTT(Box::new(Expander { args: args, }), None, false));
|
||||
}
|
||||
|
@ -24,7 +24,6 @@ struct A {
|
||||
}
|
||||
|
||||
fn main() {
|
||||
// FIXME (#22405): Replace `Box::new` with `box` here when/if possible.
|
||||
let obj = A { foo: Box::new([true, false]) };
|
||||
let s = json::encode(&obj).unwrap();
|
||||
let obj2: A = json::decode(&s).unwrap();
|
||||
|
@ -28,7 +28,6 @@ struct Fat<T: ?Sized> {
|
||||
|
||||
pub fn main() {
|
||||
{
|
||||
// FIXME (#22405): Replace `Box::new` with `box` here when/if possible.
|
||||
let _x: Box<Fat<Trait>> = Box::<Fat<Foo>>::new(Fat { f: Foo });
|
||||
}
|
||||
unsafe {
|
||||
|
@ -25,7 +25,6 @@ struct Fat<T: ?Sized> {
|
||||
|
||||
pub fn main() {
|
||||
{
|
||||
// FIXME (#22405): Replace `Box::new` with `box` here when/if possible.
|
||||
let _x: Box<Fat<[Foo]>> = Box::<Fat<[Foo; 3]>>::new(Fat { f: [Foo, Foo, Foo] });
|
||||
}
|
||||
unsafe {
|
||||
|
@ -26,7 +26,6 @@ fn pairwise_sub(mut t: Box<DoubleEndedIterator<Item=isize>>) -> isize {
|
||||
|
||||
fn main() {
|
||||
let v = vec![1, 2, 3, 4, 5, 6];
|
||||
// FIXME (#22405): Replace `Box::new` with `box` here when/if possible.
|
||||
let r = pairwise_sub(Box::new(v.into_iter()));
|
||||
assert_eq!(r, 9);
|
||||
}
|
||||
|
@ -19,15 +19,6 @@ use std::rc::Rc;
|
||||
// rvalue expressions to be unsized. See #20169 for more information.
|
||||
|
||||
pub fn main() {
|
||||
// FIXME #22405: We cannot infer the type `Box<[isize; k]>` for
|
||||
// the r-value expression from the context `Box<[isize]>`, and
|
||||
// therefore the `box EXPR` desugaring breaks down.
|
||||
//
|
||||
// One could reasonably claim that the `box EXPR` desugaring is
|
||||
// effectively regressing half of Issue #20169. Hopefully we will
|
||||
// eventually fix that, at which point the `Box::new` calls below
|
||||
// should be replaced wth uses of `box`.
|
||||
|
||||
let _: Box<[isize]> = Box::new({ [1, 2, 3] });
|
||||
let _: Box<[isize]> = Box::new(if true { [1, 2, 3] } else { [1, 3, 4] });
|
||||
let _: Box<[isize]> = Box::new(match true { true => [1, 2, 3], false => [1, 3, 4] });
|
||||
|
@ -21,7 +21,6 @@ struct A {
|
||||
|
||||
pub fn main() {
|
||||
let a: A = Default::default();
|
||||
// FIXME (#22405): Replace `Box::new` with `box` here when/if possible.
|
||||
let b: Box<[_]> = Box::<[bool; 0]>::new([]);
|
||||
assert_eq!(a.foo, b);
|
||||
}
|
||||
|
@ -12,7 +12,6 @@
|
||||
struct Foo(Box<[u8]>);
|
||||
|
||||
pub fn main() {
|
||||
// FIXME (#22405): Replace `Box::new` with `box` here when/if possible.
|
||||
let a = Foo(Box::new([0, 1, 2]));
|
||||
let b = Foo(Box::new([0, 1, 2]));
|
||||
assert_eq!(a, b);
|
||||
|
@ -39,7 +39,6 @@ pub fn foo(arr: &mut Arr) {
|
||||
}
|
||||
|
||||
fn main() {
|
||||
// FIXME (#22405): Replace `Box::new` with `box` here when/if possible.
|
||||
let mut a = Arr { ptr: Box::new([1, 2, 3]) };
|
||||
foo(&mut a);
|
||||
}
|
||||
|
@ -34,7 +34,6 @@ pub fn foo(arr: &Arr) {
|
||||
}
|
||||
|
||||
fn main() {
|
||||
// FIXME (#22405): Replace `Box::new` with `box` here when/if possible.
|
||||
let a = Arr { ptr: Box::new([1, 2, 3]) };
|
||||
foo(&a);
|
||||
}
|
||||
|
@ -127,7 +127,6 @@ pub fn main() {
|
||||
let f2 : Box<Fat<[isize]>> = f1;
|
||||
foo(&*f2);
|
||||
|
||||
// FIXME (#22405): Replace `Box::new` with `box` here when/if possible.
|
||||
let f3 : Box<Fat<[isize]>> =
|
||||
Box::<Fat<[_; 3]>>::new(Fat { f1: 5, f2: "some str", ptr: [1, 2, 3] });
|
||||
foo(&*f3);
|
||||
|
@ -97,7 +97,6 @@ pub fn main() {
|
||||
|
||||
// &*
|
||||
//
|
||||
// FIXME (#22405): Replace `Box::new` with `box` here when/if possible.
|
||||
let f7: Box<ToBar> = Box::new(Bar1 {f :42});
|
||||
bar(&*f7);
|
||||
|
||||
|
@ -8,9 +8,6 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// FIXME (#22405): Replace `Box::new` with `box` here when/if possible.
|
||||
|
||||
|
||||
pub fn main() {
|
||||
assert!(Some(Box::new(())).is_some());
|
||||
|
||||
|
@ -62,7 +62,6 @@ mod map_reduce {
|
||||
}
|
||||
|
||||
let ctrl_clone = ctrl.clone();
|
||||
// FIXME (#22405): Replace `Box::new` with `box` here when/if possible.
|
||||
::map(input, Box::new(|a,b| emit(&mut intermediates, ctrl.clone(), a, b)));
|
||||
ctrl_clone.send(ctrl_proto::mapper_done).unwrap();
|
||||
}
|
||||
|
@ -17,7 +17,6 @@
|
||||
// cause a compilation error. Issue #18772.
|
||||
|
||||
fn adder(y: isize) -> Box<Fn(isize) -> isize + 'static> {
|
||||
// FIXME (#22405): Replace `Box::new` with `box` here when/if possible.
|
||||
Box::new(move |x| y + x)
|
||||
}
|
||||
|
||||
|
@ -12,8 +12,6 @@
|
||||
|
||||
#![allow(dead_code)]
|
||||
|
||||
// FIXME (#22405): Replace `Box::new` with `box` here when/if possible.
|
||||
|
||||
trait Foo { fn dummy(&self) { } }
|
||||
impl Foo for isize {}
|
||||
fn foo(_: [&Foo; 2]) {}
|
||||
|
@ -27,6 +27,5 @@ impl X<isize> for F {
|
||||
}
|
||||
|
||||
fn main() {
|
||||
// FIXME (#22405): Replace `Box::new` with `box` here when/if possible.
|
||||
S {f: Box::new(F), g: Box::new(F) };
|
||||
}
|
||||
|
@ -9,7 +9,6 @@
|
||||
// except according to those terms.
|
||||
|
||||
fn main() {
|
||||
// FIXME (#22405): Replace `Box::new` with `box` here when/if possible.
|
||||
fn test() -> Box<std::any::Any + 'static> { Box::new(1) }
|
||||
println!("{:?}", test())
|
||||
}
|
||||
|
@ -16,7 +16,6 @@ struct Foo<'a> {
|
||||
|
||||
impl<'a> Foo<'a> {
|
||||
fn new<F>(listener: F) -> Foo<'a> where F: FnMut() + 'a {
|
||||
// FIXME (#22405): Replace `Box::new` with `box` here when/if possible.
|
||||
Foo { listener: Box::new(listener) }
|
||||
}
|
||||
}
|
||||
|
@ -11,8 +11,6 @@
|
||||
// All 3 expressions should work in that the argument gets
|
||||
// coerced to a trait object
|
||||
|
||||
// FIXME (#22405): Replace `Box::new` with `box` here when/if possible.
|
||||
|
||||
// pretty-expanded FIXME #23616
|
||||
|
||||
fn main() {
|
||||
|
@ -31,7 +31,6 @@ trait IntoMatcher<'a, T> {
|
||||
|
||||
impl<'a, 'b, F> IntoMatcher<'a, CharPredMatcher<'a, 'b>> for F where F: FnMut(char) -> bool + 'b {
|
||||
fn into_matcher(self, s: &'a str) -> CharPredMatcher<'a, 'b> {
|
||||
// FIXME (#22405): Replace `Box::new` with `box` here when/if possible.
|
||||
CharPredMatcher {
|
||||
str: s,
|
||||
pred: Box::new(self),
|
||||
|
@ -16,7 +16,6 @@ struct Parser<'a, I, O> {
|
||||
|
||||
impl<'a, I: 'a, O: 'a> Parser<'a, I, O> {
|
||||
fn compose<K: 'a>(mut self, mut rhs: Parser<'a, O, K>) -> Parser<'a, I, K> {
|
||||
// FIXME (#22405): Replace `Box::new` with `box` here when/if possible.
|
||||
Parser {
|
||||
parse: Box::new(move |x: I| {
|
||||
match (self.parse)(x) {
|
||||
|
@ -17,8 +17,6 @@ fn f(s: Box<str>) -> Box<str> {
|
||||
|
||||
fn main() {
|
||||
// There is currently no safe way to construct a `Box<str>`, so improvise
|
||||
//
|
||||
// FIXME (#22405): Replace `Box::new` with `box` here when/if possible.
|
||||
let box_arr: Box<[u8]> = Box::new(['h' as u8, 'e' as u8, 'l' as u8, 'l' as u8, 'o' as u8]);
|
||||
let box_str: Box<str> = unsafe { std::mem::transmute(box_arr) };
|
||||
assert_eq!(&*box_str, "hello");
|
||||
|
@ -13,7 +13,6 @@
|
||||
// pretty-expanded FIXME #23616
|
||||
|
||||
fn main() {
|
||||
// FIXME (#22405): Replace `Box::new` with `box` here when/if possible.
|
||||
let functions: [Box<Fn() -> Option<()>>; 1] = [Box::new(|| None)];
|
||||
|
||||
let _: Option<Vec<()>> = functions.iter().map(|f| (*f)()).collect();
|
||||
|
@ -13,7 +13,6 @@
|
||||
type Connection = Box<FnMut(Vec<u8>) + 'static>;
|
||||
|
||||
fn f() -> Option<Connection> {
|
||||
// FIXME (#22405): Replace `Box::new` with `box` here when/if possible.
|
||||
let mock_connection: Connection = Box::new(|_| {});
|
||||
Some(mock_connection)
|
||||
}
|
||||
|
@ -26,7 +26,6 @@ fn foo(name: String, samples_chan: Sender<Msg>) {
|
||||
thread::spawn(move|| {
|
||||
let mut samples_chan = samples_chan;
|
||||
|
||||
// FIXME (#22405): Replace `Box::new` with `box` here when/if possible.
|
||||
let callback: SamplesFn = Box::new(move |buffer| {
|
||||
for i in 0..buffer.len() {
|
||||
println!("{}: {}", i, buffer[i])
|
||||
|
@ -11,7 +11,6 @@
|
||||
// Test that the lambda kind is inferred correctly as a return
|
||||
// expression
|
||||
|
||||
// FIXME (#22405): Replace `Box::new` with `box` here when/if possible.
|
||||
// pretty-expanded FIXME #23616
|
||||
|
||||
fn unique() -> Box<FnMut()+'static> { return Box::new(|| ()); }
|
||||
|
@ -11,7 +11,6 @@
|
||||
// Test that the lambda kind is inferred correctly as a return
|
||||
// expression
|
||||
|
||||
// FIXME (#22405): Replace `Box::new` with `box` here when/if possible.
|
||||
// pretty-expanded FIXME #23616
|
||||
|
||||
fn unique() -> Box<FnMut()+'static> { Box::new(|| ()) }
|
||||
|
@ -16,8 +16,6 @@
|
||||
#![allow(unused_variables)]
|
||||
#![allow(unknown_features)]
|
||||
|
||||
// FIXME (#22405): Replace `Box::new` with `box` here when/if possible.
|
||||
|
||||
// Should pass region checking.
|
||||
fn ok(f: Box<FnMut(&usize)>) {
|
||||
// Here, g is a function that can accept a usize pointer with
|
||||
|
@ -31,7 +31,6 @@ struct Foo<'a,'tcx:'a> {
|
||||
|
||||
impl<'a,'tcx> Foo<'a,'tcx> {
|
||||
fn bother(&mut self) -> isize {
|
||||
// FIXME (#22405): Replace `Box::new` with `box` here when/if possible.
|
||||
self.elaborate_bounds(Box::new(|this| {
|
||||
// (*) Here: type of `this` is `&'f0 Foo<&'f1, '_2>`,
|
||||
// where `'f0` and `'f1` are fresh, free regions that
|
||||
|
@ -12,6 +12,5 @@
|
||||
struct Foo(Box<[u8]>);
|
||||
|
||||
pub fn main() {
|
||||
// FIXME (#22405): Replace `Box::new` with `box` here when/if possible.
|
||||
println!("{:?}", Foo(Box::new([0, 1, 2])));
|
||||
}
|
||||
|
@ -105,7 +105,6 @@ fn check_legs(arc: Arc<Vec<Box<Pet+Sync+Send>>>) {
|
||||
}
|
||||
fn check_names(arc: Arc<Vec<Box<Pet+Sync+Send>>>) {
|
||||
for pet in arc.iter() {
|
||||
// FIXME (#22405): Replace `Box::new` with `box` here when/if possible.
|
||||
pet.name(Box::new(|name| {
|
||||
assert!(name.as_bytes()[0] == 'a' as u8 && name.as_bytes()[1] == 'l' as u8);
|
||||
}))
|
||||
|
@ -26,7 +26,6 @@ impl Trait<&'static str> for Struct {
|
||||
|
||||
pub fn main() {
|
||||
let a = Struct { x: 1, y: 2 };
|
||||
// FIXME (#22405): Replace `Box::new` with `box` here when/if possible.
|
||||
let b: Box<Trait<&'static str>> = Box::new(a);
|
||||
b.f("Mary");
|
||||
let c: &Trait<&'static str> = &a;
|
||||
|
@ -30,8 +30,6 @@ impl Trait for Struct {
|
||||
|
||||
fn foo(mut a: Box<Write>) {}
|
||||
|
||||
// FIXME (#22405): Replace `Box::new` with `box` here when/if possible.
|
||||
|
||||
pub fn main() {
|
||||
let a = Struct { x: 1, y: 2 };
|
||||
let b: Box<Trait> = Box::new(a);
|
||||
|
@ -15,7 +15,6 @@
|
||||
use std::ops::FnMut;
|
||||
|
||||
fn make_adder(x: isize) -> Box<FnMut(isize)->isize + 'static> {
|
||||
// FIXME (#22405): Replace `Box::new` with `box` here when/if possible.
|
||||
Box::new(move |y| { x + y })
|
||||
}
|
||||
|
||||
|
@ -13,7 +13,6 @@
|
||||
use std::ops::FnMut;
|
||||
|
||||
fn make_adder(x: isize) -> Box<FnMut(isize)->isize + 'static> {
|
||||
// FIXME (#22405): Replace `Box::new` with `box` here when/if possible.
|
||||
Box::new(move |y| { x + y })
|
||||
}
|
||||
|
||||
|
@ -18,7 +18,6 @@ struct Test<'a> {
|
||||
f: Box<FnMut() + 'a>
|
||||
}
|
||||
|
||||
// FIXME (#22405): Replace `Box::new` with `box` here when/if possible.
|
||||
fn call<F>(mut f: F) where F: FnMut(Fn) {
|
||||
f(Box::new(|| {
|
||||
//~^ ERROR: cannot borrow `f` as mutable more than once
|
||||
@ -58,7 +57,6 @@ fn test6() {
|
||||
fn test7() {
|
||||
fn foo<F>(_: F) where F: FnMut(Box<FnMut(isize)>, isize) {}
|
||||
let mut f = |g: Box<FnMut(isize)>, b: isize| {};
|
||||
// FIXME (#22405): Replace `Box::new` with `box` here when/if possible.
|
||||
f(Box::new(|a| {
|
||||
foo(f);
|
||||
//~^ ERROR cannot move `f` into closure because it is borrowed
|
||||
|
@ -1,44 +1,44 @@
|
||||
error[E0499]: cannot borrow `f` as mutable more than once at a time
|
||||
--> $DIR/borrowck-call-is-borrow-issue-12224.rs:23:16
|
||||
--> $DIR/borrowck-call-is-borrow-issue-12224.rs:22:16
|
||||
|
|
||||
23 | f(Box::new(|| {
|
||||
22 | f(Box::new(|| {
|
||||
| - ^^ second mutable borrow occurs here
|
||||
| |
|
||||
| first mutable borrow occurs here
|
||||
24 | //~^ ERROR: cannot borrow `f` as mutable more than once
|
||||
25 | f((Box::new(|| {})))
|
||||
23 | //~^ ERROR: cannot borrow `f` as mutable more than once
|
||||
24 | f((Box::new(|| {})))
|
||||
| - borrow occurs due to use of `f` in closure
|
||||
26 | }));
|
||||
25 | }));
|
||||
| - first borrow ends here
|
||||
|
||||
error: cannot borrow immutable borrowed content `*f` as mutable
|
||||
--> $DIR/borrowck-call-is-borrow-issue-12224.rs:36:5
|
||||
--> $DIR/borrowck-call-is-borrow-issue-12224.rs:35:5
|
||||
|
|
||||
35 | fn test2<F>(f: &F) where F: FnMut() {
|
||||
34 | fn test2<F>(f: &F) where F: FnMut() {
|
||||
| -- use `&mut F` here to make mutable
|
||||
36 | (*f)(); //~ ERROR: cannot borrow immutable borrowed content `*f` as mutable
|
||||
35 | (*f)(); //~ ERROR: cannot borrow immutable borrowed content `*f` as mutable
|
||||
| ^^^^ cannot borrow as mutable
|
||||
|
||||
error: cannot borrow immutable `Box` content `*f.f` as mutable
|
||||
--> $DIR/borrowck-call-is-borrow-issue-12224.rs:44:5
|
||||
--> $DIR/borrowck-call-is-borrow-issue-12224.rs:43:5
|
||||
|
|
||||
43 | fn test4(f: &Test) {
|
||||
42 | fn test4(f: &Test) {
|
||||
| ----- use `&mut Test` here to make mutable
|
||||
44 | f.f.call_mut(()) //~ ERROR: cannot borrow immutable `Box` content `*f.f` as mutable
|
||||
43 | f.f.call_mut(()) //~ ERROR: cannot borrow immutable `Box` content `*f.f` as mutable
|
||||
| ^^^ cannot borrow as mutable
|
||||
|
||||
error[E0504]: cannot move `f` into closure because it is borrowed
|
||||
--> $DIR/borrowck-call-is-borrow-issue-12224.rs:63:13
|
||||
--> $DIR/borrowck-call-is-borrow-issue-12224.rs:61:13
|
||||
|
|
||||
62 | f(Box::new(|a| {
|
||||
60 | f(Box::new(|a| {
|
||||
| - borrow of `f` occurs here
|
||||
63 | foo(f);
|
||||
61 | foo(f);
|
||||
| ^ move into closure occurs here
|
||||
|
||||
error[E0507]: cannot move out of captured outer variable in an `FnMut` closure
|
||||
--> $DIR/borrowck-call-is-borrow-issue-12224.rs:63:13
|
||||
--> $DIR/borrowck-call-is-borrow-issue-12224.rs:61:13
|
||||
|
|
||||
63 | foo(f);
|
||||
61 | foo(f);
|
||||
| ^ cannot move out of captured outer variable in an `FnMut` closure
|
||||
|
||||
error: aborting due to 5 previous errors
|
||||
|
Loading…
Reference in New Issue
Block a user