file_name
large_stringlengths
4
69
prefix
large_stringlengths
0
26.7k
suffix
large_stringlengths
0
24.8k
middle
large_stringlengths
0
2.12k
fim_type
large_stringclasses
4 values
bind-by-move-neither-can-live-while-the-other-survives-3.rs
// Copyright 2012 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 ...
error!("destructor runs"); } } enum double_option<T,U> { some2(T,U), none2 } fn main() { let x = some2(X { x: () }, X { x: () }); match x { some2(ref _y, _z) => { }, //~ ERROR cannot bind by-move and by-ref in the same pattern none2 => fail!() } }
struct X { x: (), } impl Drop for X { fn finalize(&self) {
random_line_split
bind-by-move-neither-can-live-while-the-other-survives-3.rs
// Copyright 2012 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 ...
(&self) { error!("destructor runs"); } } enum double_option<T,U> { some2(T,U), none2 } fn main() { let x = some2(X { x: () }, X { x: () }); match x { some2(ref _y, _z) => { }, //~ ERROR cannot bind by-move and by-ref in the same pattern none2 => fail!() } }
finalize
identifier_name
challenge47_48.rs
use crate::errors::*; use rsa::Rsa; use bignum::OpensslBigNum as BigNum; use bignum::{BigNumExt, BigNumTrait}; use rand::Rng; use std::cmp; struct Server { rsa: Rsa<BigNum>, } // We do not need an oracle which checks for full PKCS#1v1.5 conformance. // It suffices that the oracle tells us whether the cleartex...
else if M_prev.len() >= 2 { // Step 2.b si = &s_prev + &_1; while!wrapped_oracle(&si) { si = &si + &_1; } } else { // Step 2.c let (ref a, ref b) = M_prev[0]; let mut ri = (&_2 * &(&(b * &s_prev) - &_2B)).ceil_q...
{ // Step 2.a si = n.ceil_quotient(&_3B); while !wrapped_oracle(&si) { si = &si + &_1; } }
conditional_block
challenge47_48.rs
use crate::errors::*; use rsa::Rsa; use bignum::OpensslBigNum as BigNum; use bignum::{BigNumExt, BigNumTrait}; use rand::Rng; use std::cmp; struct Server { rsa: Rsa<BigNum>, } // We do not need an oracle which checks for full PKCS#1v1.5 conformance. // It suffices that the oracle tells us whether the cleartex...
(&self) -> &BigNum { self.rsa.n() } fn oracle(&self, ciphertext: &BigNum) -> bool { let cleartext = self.rsa.decrypt(ciphertext); cleartext.rsh(8 * (self.rsa.n().bytes() - 2)) == BigNum::from_u32(2) } fn get_ciphertext(&self) -> BigNum { let k = self.rsa.n().bytes() as ...
n
identifier_name
challenge47_48.rs
use crate::errors::*; use rsa::Rsa; use bignum::OpensslBigNum as BigNum; use bignum::{BigNumExt, BigNumTrait}; use rand::Rng; use std::cmp; struct Server { rsa: Rsa<BigNum>, } // We do not need an oracle which checks for full PKCS#1v1.5 conformance. // It suffices that the oracle tells us whether the cleartex...
let mut i = 1; // We know that the cleartext corresponding to our ciphertext is PKCS conforming, so we can skip // Step 1 of the paper. loop { // Step 2 let mut si; if i == 1 { // Step 2.a si = n.ceil_quotient(&_3B); while!wrapped_oracle(&si) ...
{ let _0 = BigNum::zero(); let _1 = BigNum::one(); let _2 = BigNum::from_u32(2); let _3 = BigNum::from_u32(3); let server = Server::new(rsa_bits); let n = server.n(); let k = n.bytes() as usize; let B = _1.lsh(8 * (k - 2)); let _2B = &_2 * &B; let _3B = &_3 * &B; let c = se...
identifier_body
challenge47_48.rs
use crate::errors::*; use rsa::Rsa; use bignum::OpensslBigNum as BigNum; use bignum::{BigNumExt, BigNumTrait};
use std::cmp; struct Server { rsa: Rsa<BigNum>, } // We do not need an oracle which checks for full PKCS#1v1.5 conformance. // It suffices that the oracle tells us whether the cleartext is of the form // 00 || 02 || another k - 2 bytes, // where k is the number of bytes in the RSA modulus. impl Server { fn n...
use rand::Rng;
random_line_split
unwind-resource.rs
// Copyright 2012-2014 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-MI...
impl Drop for complainer { fn drop(&mut self) { println!("About to send!"); self.tx.send(true); println!("Sent!"); } } fn complainer(tx: Sender<bool>) -> complainer { println!("Hello!"); complainer { tx: tx } } fn f(tx: Sender<bool>) { let _tx = complainer(tx);...
}
random_line_split
unwind-resource.rs
// Copyright 2012-2014 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-MI...
pub fn main() { let (tx, rx) = channel(); task::spawn(proc() f(tx.clone())); println!("hiiiiiiiii"); assert!(rx.recv()); }
{ let _tx = complainer(tx); fail!(); }
identifier_body
unwind-resource.rs
// Copyright 2012-2014 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-MI...
(&mut self) { println!("About to send!"); self.tx.send(true); println!("Sent!"); } } fn complainer(tx: Sender<bool>) -> complainer { println!("Hello!"); complainer { tx: tx } } fn f(tx: Sender<bool>) { let _tx = complainer(tx); fail!(); } pub fn main() { le...
drop
identifier_name
unsafe_removed_from_name.rs
use clippy_utils::diagnostics::span_lint; use rustc_ast::ast::{Item, ItemKind, UseTree, UseTreeKind}; use rustc_lint::{EarlyContext, EarlyLintPass}; use rustc_session::{declare_lint_pass, declare_tool_lint}; use rustc_span::source_map::Span; use rustc_span::symbol::Ident; declare_clippy_lint! { /// ### What it doe...
(name: &str) -> bool { name.contains("Unsafe") || name.contains("unsafe") }
contains_unsafe
identifier_name
unsafe_removed_from_name.rs
use clippy_utils::diagnostics::span_lint; use rustc_ast::ast::{Item, ItemKind, UseTree, UseTreeKind}; use rustc_lint::{EarlyContext, EarlyLintPass}; use rustc_session::{declare_lint_pass, declare_tool_lint}; use rustc_span::source_map::Span; use rustc_span::symbol::Ident; declare_clippy_lint! { /// ### What it doe...
fn unsafe_to_safe_check(old_name: Ident, new_name: Ident, cx: &EarlyContext<'_>, span: Span) { let old_str = old_name.name.as_str(); let new_str = new_name.name.as_str(); if contains_unsafe(&old_str) &&!contains_unsafe(&new_str) { span_lint( cx, UNSAFE_REMOVED_FROM_NAME, ...
{ match use_tree.kind { UseTreeKind::Simple(Some(new_name), ..) => { let old_name = use_tree .prefix .segments .last() .expect("use paths cannot be empty") .ident; unsafe_to_safe_check(old_name, new_name,...
identifier_body
unsafe_removed_from_name.rs
use clippy_utils::diagnostics::span_lint; use rustc_ast::ast::{Item, ItemKind, UseTree, UseTreeKind}; use rustc_lint::{EarlyContext, EarlyLintPass}; use rustc_session::{declare_lint_pass, declare_tool_lint}; use rustc_span::source_map::Span; use rustc_span::symbol::Ident; declare_clippy_lint! { /// ### What it doe...
}, } } fn unsafe_to_safe_check(old_name: Ident, new_name: Ident, cx: &EarlyContext<'_>, span: Span) { let old_str = old_name.name.as_str(); let new_str = new_name.name.as_str(); if contains_unsafe(&old_str) &&!contains_unsafe(&new_str) { span_lint( cx, UNSAFE_REM...
for &(ref use_tree, _) in nested_use_tree { check_use_tree(use_tree, cx, span); }
random_line_split
bots.rs
//============================================================================= // // WARNING: This file is AUTO-GENERATED // // Do not make changes directly to this file. // // If you would like to make a change to the library, please update the schema // definitions at https://github.com/slack-rs/s...
{ let params = vec![Some(("token", token)), request.bot.map(|bot| ("bot", bot))]; let params = params.into_iter().filter_map(|x| x).collect::<Vec<_>>(); let url = crate::get_slack_url_for_method("bots.info"); client .send(&url, &params[..]) .await .map_err(InfoError::Client) ...
identifier_body
bots.rs
//============================================================================= // // WARNING: This file is AUTO-GENERATED // // Do not make changes directly to this file. // // If you would like to make a change to the library, please update the schema // definitions at https://github.com/slack-rs/s...
<R>( client: &R, token: &str, request: &InfoRequest<'_>, ) -> Result<InfoResponse, InfoError<R::Error>> where R: SlackWebRequestSender, { let params = vec![Some(("token", token)), request.bot.map(|bot| ("bot", bot))]; let params = params.into_iter().filter_map(|x| x).collect::<Vec<_>>(); let...
info
identifier_name
bots.rs
//============================================================================= // // WARNING: This file is AUTO-GENERATED // // Do not make changes directly to this file. // // If you would like to make a change to the library, please update the schema // definitions at https://github.com/slack-rs/s...
.send(&url, &params[..]) .await .map_err(InfoError::Client) .and_then(|result| { serde_json::from_str::<InfoResponse>(&result) .map_err(|e| InfoError::MalformedResponse(result, e)) }) .and_then(|o| o.into()) }
{ let params = vec![Some(("token", token)), request.bot.map(|bot| ("bot", bot))]; let params = params.into_iter().filter_map(|x| x).collect::<Vec<_>>(); let url = crate::get_slack_url_for_method("bots.info"); client
random_line_split
UBT.rs
use std::cell::RefCell; use std::rc::Rc; #[derive(Debug, PartialEq, Eq)] pub struct TreeNode { pub val: i32, pub left: Option<Rc<RefCell<TreeNode>>>, pub right: Option<Rc<RefCell<TreeNode>>>, } impl TreeNode { #[inline] pub fn new(val: i32) -> Self { TreeNode { val, ...
is_UT_WithState(this_root.borrow().left.as_ref(), this_val) && is_UT_WithState(this_root.borrow().right.as_ref(), this_val) }
{ return false; }
conditional_block
UBT.rs
use std::cell::RefCell; use std::rc::Rc; #[derive(Debug, PartialEq, Eq)] pub struct TreeNode { pub val: i32, pub left: Option<Rc<RefCell<TreeNode>>>, pub right: Option<Rc<RefCell<TreeNode>>>, } impl TreeNode {
left: None, right: None, } } } pub fn is_unival_tree(root: Option<Rc<RefCell<TreeNode>>>) -> bool { is_UT_WithState(root.as_ref(), root.as_ref().unwrap().borrow().val.clone()) } pub fn is_UT_WithState(root: Option<&Rc<RefCell<TreeNode>>>, val: i32) -> bool { if root.is_none...
#[inline] pub fn new(val: i32) -> Self { TreeNode { val,
random_line_split
UBT.rs
use std::cell::RefCell; use std::rc::Rc; #[derive(Debug, PartialEq, Eq)] pub struct TreeNode { pub val: i32, pub left: Option<Rc<RefCell<TreeNode>>>, pub right: Option<Rc<RefCell<TreeNode>>>, } impl TreeNode { #[inline] pub fn new(val: i32) -> Self { TreeNode { val, ...
(root: Option<Rc<RefCell<TreeNode>>>) -> bool { is_UT_WithState(root.as_ref(), root.as_ref().unwrap().borrow().val.clone()) } pub fn is_UT_WithState(root: Option<&Rc<RefCell<TreeNode>>>, val: i32) -> bool { if root.is_none() { return true; } let this_root = root.as_ref().unwrap(); let this_...
is_unival_tree
identifier_name
structures.rs
//! Structures provided by D3D11 //! //! # References //! [D3D11 Structures, MSDN] //! (https://msdn.microsoft.com/en-us/library/windows/desktop/ff476155(v=vs.85).aspx) #![allow(non_snake_case, non_camel_case_types)] use winapi::minwindef::*; use winapi::basetsd::*; use winapi::{LPCSTR, RECT}; use dxgi::DXGI_FORMAT; ...
#[repr(C)] pub struct D3D11_BOX { pub left: UINT, pub top: UINT, pub front: UINT, pub right: UINT, pub bottom: UINT, pub back: UINT, } #[repr(C)] pub struct D3D11_COUNTER_DESC { pub Counter: D3D11_COUNTER, pub MiscFlags: UINT, } #[repr(C)] pub struct D3D11_COUNTER_INFO { pub LastD...
}
random_line_split
structures.rs
//! Structures provided by D3D11 //! //! # References //! [D3D11 Structures, MSDN] //! (https://msdn.microsoft.com/en-us/library/windows/desktop/ff476155(v=vs.85).aspx) #![allow(non_snake_case, non_camel_case_types)] use winapi::minwindef::*; use winapi::basetsd::*; use winapi::{LPCSTR, RECT}; use dxgi::DXGI_FORMAT; ...
{ pub TiledResourcesTier: D3D11_TILED_RESOURCES_TIER, pub MinMaxFiltering: BOOL, pub ClearViewAlsoSupportsDepthOnlyFormats: BOOL, pub MapOnDefaultBuffers: BOOL, } #[repr(C)] pub struct D3D11_FEATURE_DATA_DOUBLES { pub DoublePrecisionFloatShaderOps: BOOL, } #[repr(C)] pub struct D3D11_FEATURE_DATA...
D3D11_FEATURE_DATA_D3D11_OPTIONS1
identifier_name
price_fraction.rs
// http://rosettacode.org/wiki/Price_fraction fn fix_price(num: f64) -> f64 { match num { 0.96...1.00 => 1.00, 0.91...0.96 => 0.98, 0.86...0.91 => 0.94, 0.81...0.86 => 0.90, 0.76...0.81 => 0.86, 0.71...0.76 => 0.82, 0.66...0.71 => 0.78, 0.61...0.66 =>...
// typically this could be included in the match as those check for exhaustiveness already // by explicitly listing all remaining ranges / values instead of a catch-all underscore (_) // but f64::NaN, f64::INFINITY and f64::NEG_INFINITY can't be matched like this #[test] fn exhaustiveness_check() { let mut input_...
{ let mut n: f64 = 0.04; while n <= 1.00 { println!("{:.2} => {}", n, fix_price(n)); n += 0.04; } }
identifier_body
price_fraction.rs
// http://rosettacode.org/wiki/Price_fraction fn fix_price(num: f64) -> f64 { match num { 0.96...1.00 => 1.00, 0.91...0.96 => 0.98, 0.86...0.91 => 0.94, 0.81...0.86 => 0.90, 0.76...0.81 => 0.86, 0.71...0.76 => 0.82, 0.66...0.71 => 0.78, 0.61...0.66 =>...
_ => unreachable!(), } } fn main() { let mut n: f64 = 0.04; while n <= 1.00 { println!("{:.2} => {}", n, fix_price(n)); n += 0.04; } } // typically this could be included in the match as those check for exhaustiveness already // by explicitly listing all remaining ranges / valu...
// panics on invalid value
random_line_split
price_fraction.rs
// http://rosettacode.org/wiki/Price_fraction fn
(num: f64) -> f64 { match num { 0.96...1.00 => 1.00, 0.91...0.96 => 0.98, 0.86...0.91 => 0.94, 0.81...0.86 => 0.90, 0.76...0.81 => 0.86, 0.71...0.76 => 0.82, 0.66...0.71 => 0.78, 0.61...0.66 => 0.74, 0.56...0.61 => 0.70, 0.51...0.56 => ...
fix_price
identifier_name
main.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #![deny(unused_imports)] #![deny(unused_variables)] #![feature(box_syntax)] #![feature(convert)] // For FFI #![al...
{ browser: Browser, } fn main() { env_logger::init().unwrap(); // Parse the command line options and store them globally opts::from_cmdline_args(env::args().collect::<Vec<_>>().as_slice()); hosts::global_init(); let window = if opts::get().headless { None } else { Some(w...
BrowserWrapper
identifier_name
main.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #![deny(unused_imports)] #![deny(unused_variables)] #![feature(box_syntax)] #![feature(convert)] // For FFI #![al...
} }
{ break }
conditional_block
main.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #![deny(unused_imports)]
#![feature(convert)] // For FFI #![allow(non_snake_case, dead_code)] //! The `servo` test application. //! //! Creates a `Browser` instance with a simple implementation of //! the compositor's `WindowMethods` to create a working web browser. //! //! This browser's implementation of `WindowMethods` is built on top //! ...
#![deny(unused_variables)] #![feature(box_syntax)]
random_line_split
addrinfo.rs
// Copyright 2014 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 ...
(host: Option<&str>, servname: Option<&str>, hint: Option<ai::Hint>) -> Result<~[ai::Info], IoError> { assert!(host.is_some() || servname.is_some()); let c_host = host.map_or(unsafe { CString::new(null(), true) }, |x| x.to_c_str()); let c_serv = servname.map_or(unsafe { CString::...
run
identifier_name
addrinfo.rs
// Copyright 2014 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 ...
else { c_host.with_ref(|x| x) }; let cs = if c_serv.is_null() { null() } else { c_serv.with_ref(|x| x) }; getaddrinfo(ch, cs, hint_ptr, &mut res) }; // Error? if s!= 0 { return Err(get_error(s)); } // Collect all the results we found ...
{ null() }
conditional_block
addrinfo.rs
// Copyright 2014 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 ...
{ use std::io; use std::str::raw::from_c_str; let err_str = unsafe { from_c_str(gai_strerror(s)) }; IoError { kind: io::OtherIoError, desc: "unable to resolve host", detail: Some(err_str), } }
identifier_body
addrinfo.rs
// Copyright 2014 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 ...
let mut res = mut_null(); // Make the call let s = unsafe { let ch = if c_host.is_null() { null() } else { c_host.with_ref(|x| x) }; let cs = if c_serv.is_null() { null() } else { c_serv.with_ref(|x| x) }; getaddrinfo(ch, cs, hint_ptr, &mut res) }; ...
}); let hint_ptr = hint.as_ref().map_or(null(), |x| x as *libc::addrinfo);
random_line_split
after.rs
use wtest_basic::dependencies::*; #[cfg( feature = "in_wtools" )] use wtools::former::Former; #[cfg( not( feature = "in_wtools" ) )] use former::Former; #[ derive( Debug, PartialEq, Former ) ] #[ form_after( fn after1< 'a >() -> Option< &'a str > ) ] pub struct Struct1 { #[ default( 31 ) ] pub int_1 : i32, } //...
() -> anyhow::Result< () > { let got = Struct1::former().form(); let expected = Some( "abc" ); assert_eq!( got, expected ); let got = Struct1::former()._form(); let expected = Struct1 { int_1 : 31 }; assert_eq!( got, expected ); Ok( () ) } // #[ test ] fn main_test() -> anyhow::Result< () > { basic...
basic
identifier_name
after.rs
use wtest_basic::dependencies::*; #[cfg( feature = "in_wtools" )] use wtools::former::Former; #[cfg( not( feature = "in_wtools" ) )] use former::Former; #[ derive( Debug, PartialEq, Former ) ] #[ form_after( fn after1< 'a >() -> Option< &'a str > ) ] pub struct Struct1 { #[ default( 31 ) ] pub int_1 : i32, } // ...
} // fn basic() -> anyhow::Result< () > { let got = Struct1::former().form(); let expected = Some( "abc" ); assert_eq!( got, expected ); let got = Struct1::former()._form(); let expected = Struct1 { int_1 : 31 }; assert_eq!( got, expected ); Ok( () ) } // #[ test ] fn main_test() -> anyhow::Result<...
{ fn after1< 'a >( &self ) -> Option< &'a str > { Some( "abc" ) }
random_line_split
allocator.rs
use gccjit::{FunctionType, ToRValue}; use rustc_ast::expand::allocator::{AllocatorKind, AllocatorTy, ALLOCATOR_METHODS}; use rustc_middle::bug; use rustc_middle::ty::TyCtxt; use rustc_span::symbol::sym; use crate::GccContext; pub(crate) unsafe fn codegen(tcx: TyCtxt<'_>, mods: &mut GccContext, _module_name: &str, kin...
}; let i8 = context.new_type::<i8>(); let i8p = i8.make_pointer(); let void = context.new_type::<()>(); for method in ALLOCATOR_METHODS { let mut types = Vec::with_capacity(method.inputs.len()); for ty in method.inputs.iter() { match *ty { AllocatorTy...
64 => context.new_type::<u64>(), tws => bug!("Unsupported target word size for int: {}", tws),
random_line_split
allocator.rs
use gccjit::{FunctionType, ToRValue}; use rustc_ast::expand::allocator::{AllocatorKind, AllocatorTy, ALLOCATOR_METHODS}; use rustc_middle::bug; use rustc_middle::ty::TyCtxt; use rustc_span::symbol::sym; use crate::GccContext; pub(crate) unsafe fn
(tcx: TyCtxt<'_>, mods: &mut GccContext, _module_name: &str, kind: AllocatorKind, has_alloc_error_handler: bool) { let context = &mods.context; let usize = match tcx.sess.target.pointer_width { 16 => context.new_type::<u16>(), 32 => context.new_type::<u32>(), 64 => co...
codegen
identifier_name
allocator.rs
use gccjit::{FunctionType, ToRValue}; use rustc_ast::expand::allocator::{AllocatorKind, AllocatorTy, ALLOCATOR_METHODS}; use rustc_middle::bug; use rustc_middle::ty::TyCtxt; use rustc_span::symbol::sym; use crate::GccContext; pub(crate) unsafe fn codegen(tcx: TyCtxt<'_>, mods: &mut GccContext, _module_name: &str, kin...
} AllocatorTy::Ptr => types.push(i8p), AllocatorTy::Usize => types.push(usize), AllocatorTy::ResultPtr | AllocatorTy::Unit => panic!("invalid allocator arg"), } } let output = match method.output { AllocatorTy::Resu...
{ let context = &mods.context; let usize = match tcx.sess.target.pointer_width { 16 => context.new_type::<u16>(), 32 => context.new_type::<u32>(), 64 => context.new_type::<u64>(), tws => bug!("Unsupported target word size for int: {}", tws), }; ...
identifier_body
terminal.rs
#![macro_use] use io::display; use io::pio::*; use core::fmt; use spin::Mutex; pub struct Terminal { writer: display::Writer, color: u8, x: usize, y: usize, } pub static TERM: Mutex<Terminal> = Mutex::new(Terminal { writer: display::Writer { ptr: 0xb8000 }, color: display::Color::new(display:...
pub fn backspace(&mut self) { self.writer.write_index(display::Entry::new(b' ', self.color), self.y * display::VIDEO_WIDTH + self.x - 1); if self.x == 0 { self.y -= 1; self.x = display::VIDEO_WIDTH; } else { self.x -= 1; ...
{ self.x = 0; self.y = 0; // for i in 0..(display::VIDEO_WIDTH * (display::VIDEO_HEIGHT - 1)) { // self.writer.write_index(self.writer.at(i + display::VIDEO_WIDTH), i); // } }
identifier_body
terminal.rs
#![macro_use] use io::display; use io::pio::*; use core::fmt; use spin::Mutex; pub struct Terminal { writer: display::Writer, color: u8, x: usize, y: usize, } pub static TERM: Mutex<Terminal> = Mutex::new(Terminal { writer: display::Writer { ptr: 0xb8000 }, color: display::Color::new(display:...
() -> Terminal { Terminal { writer: display::Writer::new(0xb8000), color: display::Color::new(display::Color::White, display::Color::Black), x: 0, y: 0, } } pub fn set_color(&mut self, color: u8) { self.color = color; } pub fn adv...
new
identifier_name
terminal.rs
#![macro_use] use io::display; use io::pio::*; use core::fmt; use spin::Mutex; pub struct Terminal { writer: display::Writer, color: u8, x: usize, y: usize, } pub static TERM: Mutex<Terminal> = Mutex::new(Terminal { writer: display::Writer { ptr: 0xb8000 }, color: display::Color::new(display:...
pub fn advance(&mut self) { if self.x <= display::VIDEO_WIDTH { self.x += 1; } else { self.newline(); } } pub fn newline(&mut self) { self.x = 0; self.y += 1; if self.y > display::VIDEO_HEIGHT { self.scroll(); } ...
random_line_split
num.rs
// Adapted from https://github.com/Alexhuszagh/rust-lexical. //! Utilities for Rust numbers. use core::ops; /// Precalculated values of radix**i for i in range [0, arr.len()-1]. /// Each value can be **exactly** represented as that type. const F32_POW10: [f32; 11] = [ 1.0, 10.0, 100.0, 1000.0, 10...
self / F64_POW10[-n as usize] } } #[inline] fn from_bits(u: u64) -> f64 { f64::from_bits(u) } #[inline] fn to_bits(self) -> u64 { f64::to_bits(self) } #[inline] fn is_sign_positive(self) -> bool { f64::is_sign_positive(self) } #[inl...
self * F64_POW10[n as usize] } else {
conditional_block
num.rs
// Adapted from https://github.com/Alexhuszagh/rust-lexical. //! Utilities for Rust numbers. use core::ops; /// Precalculated values of radix**i for i in range [0, arr.len()-1]. /// Each value can be **exactly** represented as that type. const F32_POW10: [f32; 11] = [ 1.0, 10.0, 100.0, 1000.0, 10...
15 } #[inline] fn pow10(self, n: i32) -> f64 { // Check the exponent is within bounds in debug builds. debug_assert!({ let (min, max) = Self::exponent_limit(); n >= min && n <= max }); if n > 0 { self * F64_POW10[n as usize] ...
it() -> i32 {
identifier_name
num.rs
// Adapted from https://github.com/Alexhuszagh/rust-lexical. //! Utilities for Rust numbers. use core::ops; /// Precalculated values of radix**i for i in range [0, arr.len()-1]. /// Each value can be **exactly** represented as that type. const F32_POW10: [f32; 11] = [ 1.0, 10.0, 100.0, 1000.0, 10...
/// Mask to extract the high bits from the integer. const HIMASK: Self; /// Mask to extract the low bits from the integer. const LOMASK: Self; /// Full size of the integer, in bits. const FULL: i32; /// Half size of the integer, in bits. const HALF: i32 = Self::FULL / 2; } impl Mantissa...
pub trait Mantissa: Integer {
random_line_split
num.rs
// Adapted from https://github.com/Alexhuszagh/rust-lexical. //! Utilities for Rust numbers. use core::ops; /// Precalculated values of radix**i for i in range [0, arr.len()-1]. /// Each value can be **exactly** represented as that type. const F32_POW10: [f32; 11] = [ 1.0, 10.0, 100.0, 1000.0, 10...
ne] fn is_sign_negative(self) -> bool { f64::is_sign_negative(self) } }
4::is_sign_positive(self) } #[inli
identifier_body
issue-52126-assign-op-invariance.rs
// Issue 52126: With respect to variance, the assign-op's like += were // accidentally lumped together with other binary op's. In both cases // we were coercing the LHS of the op to the expected supertype. // // The problem is that since the LHS of += is modified, we need the // parameter to be invariant with respect t...
<'l> { map: HashMap<&'l str, usize>, } impl<'l> AddAssign for Counter<'l> { fn add_assign(&mut self, rhs: Counter<'l>) { rhs.map.into_iter().for_each(|(key, val)| { let count = self.map.entry(key).or_insert(0); *count += val; }); } } /// Often crashes, if not prints...
Counter
identifier_name
issue-52126-assign-op-invariance.rs
// Issue 52126: With respect to variance, the assign-op's like += were // accidentally lumped together with other binary op's. In both cases // we were coercing the LHS of the op to the expected supertype. // // The problem is that since the LHS of += is modified, we need the // parameter to be invariant with respect t...
} /// Often crashes, if not prints invalid strings. pub fn panics() { let mut acc = Counter{map: HashMap::new()}; for line in vec!["123456789".to_string(), "12345678".to_string()] { let v: Vec<&str> = line.split_whitespace().collect(); //~^ ERROR `line` does not live long enough // pri...
{ rhs.map.into_iter().for_each(|(key, val)| { let count = self.map.entry(key).or_insert(0); *count += val; }); }
identifier_body
issue-52126-assign-op-invariance.rs
// Issue 52126: With respect to variance, the assign-op's like += were
// we were coercing the LHS of the op to the expected supertype. // // The problem is that since the LHS of += is modified, we need the // parameter to be invariant with respect to the overall type, not // covariant. use std::collections::HashMap; use std::ops::AddAssign; pub fn main() { panics(); } pub struct C...
// accidentally lumped together with other binary op's. In both cases
random_line_split
drawing_area.rs
// This file was generated by gir (https://github.com/gtk-rs/gir) // from gir-files (https://github.com/gtk-rs/gir-files) // DO NOT EDIT use Buildable; use Widget; use ffi; use glib::object::Downcast; use glib::translate::*; use glib_ffi; use gobject_ffi; use std::mem; use std::ptr; glib_wrapper! { pub struct Dra...
} impl Default for DrawingArea { fn default() -> Self { Self::new() } }
assert_initialized_main_thread!(); unsafe { Widget::from_glib_none(ffi::gtk_drawing_area_new()).downcast_unchecked() } }
random_line_split
drawing_area.rs
// This file was generated by gir (https://github.com/gtk-rs/gir) // from gir-files (https://github.com/gtk-rs/gir-files) // DO NOT EDIT use Buildable; use Widget; use ffi; use glib::object::Downcast; use glib::translate::*; use glib_ffi; use gobject_ffi; use std::mem; use std::ptr; glib_wrapper! { pub struct Dra...
() -> DrawingArea { assert_initialized_main_thread!(); unsafe { Widget::from_glib_none(ffi::gtk_drawing_area_new()).downcast_unchecked() } } } impl Default for DrawingArea { fn default() -> Self { Self::new() } }
new
identifier_name
drawing_area.rs
// This file was generated by gir (https://github.com/gtk-rs/gir) // from gir-files (https://github.com/gtk-rs/gir-files) // DO NOT EDIT use Buildable; use Widget; use ffi; use glib::object::Downcast; use glib::translate::*; use glib_ffi; use gobject_ffi; use std::mem; use std::ptr; glib_wrapper! { pub struct Dra...
}
{ Self::new() }
identifier_body
ecp.rs
E; } #[allow(non_snake_case)] /* set from x - calculate y from curve equation */ pub fn new_big(ix: &BIG) -> ECP { let mut E=ECP::new(); E.x.bcopy(ix); E.z.one(); let mut rhs=ECP::rhs(&mut E.x); if rhs.jacobi()==1 { if rom::CURVETYPE!=rom::MONTGOMERY {E.y.copy(&rhs.sqrt())} E.inf=false; } else {...
work[i].mul(&mut P[i-1].z); } t1.copy(&work[m-1]); t1.mul(&mut P[m-1].z); t1.inverse(); t2.copy(&P[m-1].z); work[m-1].mul(&mut t1); let mut i=m-2; loop { if i==0 { work[0].copy(&t1); work[0].mul(&mut t2); break; } work[i].mul(&mut t2); work[i].mul(&mut t1); t2.mul(&mut P[...
for i in 2..m { t1.copy(&work[i-1]); work[i].copy(&t1);
random_line_split
ecp.rs
} impl fmt::Debug for ECP { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "ECP: [ {}, {}, {}, {} ]", self.inf, self.x, self.y, self.z) } } impl PartialEq for ECP { fn eq(&self, other: &ECP) -> bool { return (self.inf == other.inf) && (self.x == other.x) && (self.y == other.y) && (s...
{ write!(f, "ECP: [ {}, {}, {}, {} ]", self.inf, self.x, self.y, self.z) }
identifier_body
ecp.rs
} #[allow(non_snake_case)] /* set from x - calculate y from curve equation */ pub fn new_big(ix: &BIG) -> ECP { let mut E=ECP::new(); E.x.bcopy(ix); E.z.one(); let mut rhs=ECP::rhs(&mut E.x); if rhs.jacobi()==1 { if rom::CURVETYPE!=rom::MONTGOMERY {E.y.copy(&rhs.sqrt())} E.inf=false; } else {E.i...
self.z.copy(&bb); self.z.mul(&mut c); self.x.norm(); self.z.norm(); } return; } /* self+=Q */ pub fn add(&mut self,Q:&mut ECP) { if rom::CURVETYPE==rom::WEIERSTRASS { if self.inf { self.copy(&Q); return; } ...
{ let mut a=FP::new_copy(&self.x); let mut b=FP::new_copy(&self.x); let mut aa=FP::new(); let mut bb=FP::new(); let mut c=FP::new(); if self.inf {return} a.add(&self.z); aa.copy(&a); aa.sqr(); b.sub(&se...
conditional_block
ecp.rs
} #[allow(non_snake_case)] /* set from x - calculate y from curve equation */ pub fn new_big(ix: &BIG) -> ECP { let mut E=ECP::new(); E.x.bcopy(ix); E.z.one(); let mut rhs=ECP::rhs(&mut E.x); if rhs.jacobi()==1 { if rom::CURVETYPE!=rom::MONTGOMERY {E.y.copy(&rhs.sqrt())} E.inf=false; } else {E.i...
(&mut self,e: i32,bts: i32) -> ECP { if rom::CURVETYPE==rom::MONTGOMERY { return self.mul(&mut BIG::new_int(e as isize)); } else { let mut P=ECP::new(); let mut R0=ECP::new(); let mut R1=ECP::new(); R1.copy(&self); for i in (0..bts).rev() { let b=((e>>i)&1) as isize; P.copy(&R1); P.add(...
pinmul
identifier_name
client.rs
use std::sync::{Arc, Mutex, Weak}; use std::time::Duration; use crate::credential::{ Anonymous, CredentialsError, DefaultCredentialsProvider, ProvideAwsCredentials, StaticProvider, }; use crate::encoding::ContentEncoding; use crate::request::{DispatchSignedRequest, HttpClient, HttpDispatchError, HttpResponse}; use...
} else { provider.credentials().await } .map_err(SignAndDispatchError::Credentials)?; if credentials.is_anonymous() { request.complement(); } else { request.sign(&credentials); } } else { request.complement(); } clien...
.and_then(std::convert::identity)
random_line_split
client.rs
use std::sync::{Arc, Mutex, Weak}; use std::time::Duration; use crate::credential::{ Anonymous, CredentialsError, DefaultCredentialsProvider, ProvideAwsCredentials, StaticProvider, }; use crate::encoding::ContentEncoding; use crate::request::{DispatchSignedRequest, HttpClient, HttpDispatchError, HttpResponse}; use...
/// Create a client from a credentials provider and request dispatcher. pub fn new_with<P, D>(credentials_provider: P, dispatcher: D) -> Self where P: ProvideAwsCredentials + Send + Sync +'static, D: DispatchSignedRequest + Send + Sync +'static, { let inner = ClientInner { ...
{ let mut lock = SHARED_CLIENT.lock().unwrap(); if let Some(inner) = lock.upgrade() { return Client { inner }; } let credentials_provider = DefaultCredentialsProvider::new().expect("failed to create credentials provider"); let dispatcher = HttpClient::new(...
identifier_body
client.rs
use std::sync::{Arc, Mutex, Weak}; use std::time::Duration; use crate::credential::{ Anonymous, CredentialsError, DefaultCredentialsProvider, ProvideAwsCredentials, StaticProvider, }; use crate::encoding::ContentEncoding; use crate::request::{DispatchSignedRequest, HttpClient, HttpDispatchError, HttpResponse}; use...
else { provider.credentials().await } .map_err(SignAndDispatchError::Credentials)?; if credentials.is_anonymous() { request.complement(); } else { request.sign(&credentials); } } else { request.complement(); } client ...
{ time::timeout(to, provider.credentials()) .await .map_err(|_| CredentialsError { message: "Timeout getting credentials".to_owned(), }) .and_then(std::convert::identity) }
conditional_block
client.rs
use std::sync::{Arc, Mutex, Weak}; use std::time::Duration; use crate::credential::{ Anonymous, CredentialsError, DefaultCredentialsProvider, ProvideAwsCredentials, StaticProvider, }; use crate::encoding::ContentEncoding; use crate::request::{DispatchSignedRequest, HttpClient, HttpDispatchError, HttpResponse}; use...
{ /// Error was due to bad credentials Credentials(CredentialsError), /// Error was due to http dispatch Dispatch(HttpDispatchError), } #[async_trait] trait SignAndDispatch { async fn sign_and_dispatch( &self, request: SignedRequest, timeout: Option<Duration>, ) -> Resu...
SignAndDispatchError
identifier_name
lint-missing-doc.rs
// Copyright 2013 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 ...
() {} } } enum Baz { BazA { a: isize, b: isize }, BarB } pub enum PubBaz { //~ ERROR: missing documentation for an enum PubBazA { //~ ERROR: missing documentation for a variant a: isize, //~ ERROR: missing documentation for a struct field }, } /// dox pub enum PubBaz2 ...
baz
identifier_name
lint-missing-doc.rs
// Copyright 2013 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 ...
#[allow(missing_docs)] pub enum PubBaz3 { PubBaz3A { b: isize }, } #[doc(hidden)] pub fn baz() {} mod internal_impl { /// dox pub fn documented() {} pub fn undocumented1() {} //~ ERROR: missing documentation for a function pub fn undocumented2() {} //~ ERROR: missing documentation for...
a: isize, }, }
random_line_split
lint-missing-doc.rs
// Copyright 2013 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 ...
#[allow(missing_docs)] pub fn foo3() {} } #[allow(missing_docs)] trait F { fn a(); fn b(&self); } // should need to redefine documentation for implementations of traits impl F for Foo { fn a() {} fn b(&self) {} } // It sure is nice if doc(hidden) implies allow(missing_docs), and that it // appli...
{}
identifier_body
noop.rs
// Copyright 2019 TiKV Project Authors. Licensed under Apache-2.0. use std::io; use std::marker::Unpin; use futures_executor::block_on; use futures_io::AsyncRead; use futures_util::io::{copy, AllowStdIo}; use super::ExternalStorage; /// A storage saves files into void. /// It is mainly for test use. #[derive(Clone,...
fn read(&self, _name: &str) -> Box<dyn AsyncRead + Unpin> { Box::new(AllowStdIo::new(io::empty())) } } #[cfg(test)] mod tests { use super::*; use futures_util::io::AsyncReadExt; #[test] fn test_noop_storage() { let noop = NoopStorage::default(); // Test save_file ...
{ // we must still process the entire reader to run the SHA-256 hasher. block_on(copy(reader, &mut AllowStdIo::new(io::sink()))).map(drop) }
identifier_body
noop.rs
// Copyright 2019 TiKV Project Authors. Licensed under Apache-2.0. use std::io; use std::marker::Unpin; use futures_executor::block_on; use futures_io::AsyncRead; use futures_util::io::{copy, AllowStdIo}; use super::ExternalStorage; /// A storage saves files into void. /// It is mainly for test use. #[derive(Clone,...
} #[test] fn test_url_of_backend() { assert_eq!(url_for().to_string(), "noop:///"); } }
random_line_split
noop.rs
// Copyright 2019 TiKV Project Authors. Licensed under Apache-2.0. use std::io; use std::marker::Unpin; use futures_executor::block_on; use futures_io::AsyncRead; use futures_util::io::{copy, AllowStdIo}; use super::ExternalStorage; /// A storage saves files into void. /// It is mainly for test use. #[derive(Clone,...
() { assert_eq!(url_for().to_string(), "noop:///"); } }
test_url_of_backend
identifier_name
toggle-trait-fn.rs
#![crate_name = "foo"] // Trait methods with documentation should be wrapped in a <details> toggle with an appropriate // summary. Trait methods with no documentation should not be wrapped. // // @has foo/trait.Foo.html // @has - '//details[@class="rustdoc-toggle"]//summary//h4[@class="code-header"]' 'is_documented()...
/// is_documented_optional is documented fn is_documented_optional() {} }
{}
identifier_body
toggle-trait-fn.rs
#![crate_name = "foo"] // Trait methods with documentation should be wrapped in a <details> toggle with an appropriate // summary. Trait methods with no documentation should not be wrapped. // // @has foo/trait.Foo.html // @has - '//details[@class="rustdoc-toggle"]//summary//h4[@class="code-header"]' 'is_documented()...
// @has - '//details[@class="rustdoc-toggle"]//*[@class="docblock"]' 'is_documented_optional is documented' pub trait Foo { fn not_documented(); /// is_documented is documented fn is_documented(); fn not_documented_optional() {} /// is_documented_optional is documented fn is_documented_optio...
random_line_split
toggle-trait-fn.rs
#![crate_name = "foo"] // Trait methods with documentation should be wrapped in a <details> toggle with an appropriate // summary. Trait methods with no documentation should not be wrapped. // // @has foo/trait.Foo.html // @has - '//details[@class="rustdoc-toggle"]//summary//h4[@class="code-header"]' 'is_documented()...
() {} }
is_documented_optional
identifier_name
box_blur.rs
use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion}; use librsvg::{ surface_utils::shared_surface::{ AlphaOnly, Horizontal, NotAlphaOnly, SharedImageSurface, SurfaceType, Vertical, }, IRect, }; const SURFACE_SIDE: i32 = 512; const BOUNDS: IRect = IRect { x0: 64, y0: 64...
(c: &mut Criterion) { let mut group = c.benchmark_group("box_blur 9"); for input in [(false, false), (false, true), (true, false), (true, true)].iter() { group.bench_with_input( BenchmarkId::from_parameter(format!("{:?}", input)), &input, |b, &(vertical, alpha_only)|...
bench_box_blur
identifier_name
box_blur.rs
use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion}; use librsvg::{ surface_utils::shared_surface::{ AlphaOnly, Horizontal, NotAlphaOnly, SharedImageSurface, SurfaceType, Vertical, }, IRect, }; const SURFACE_SIDE: i32 = 512; const BOUNDS: IRect = IRect { x0: 64, y0: 64...
let f = match (vertical, alpha_only) { (true, true) => SharedImageSurface::box_blur_loop::<Vertical, AlphaOnly>, (true, false) => SharedImageSurface::box_blur_loop::<Vertical, NotAlphaOnly>, (false, true) => SharedImageSurface::box_blur_loop::...
{ let mut group = c.benchmark_group("box_blur 9"); for input in [(false, false), (false, true), (true, false), (true, true)].iter() { group.bench_with_input( BenchmarkId::from_parameter(format!("{:?}", input)), &input, |b, &(vertical, alpha_only)| { l...
identifier_body
box_blur.rs
use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion}; use librsvg::{ surface_utils::shared_surface::{ AlphaOnly, Horizontal, NotAlphaOnly, SharedImageSurface, SurfaceType, Vertical, }, IRect, }; const SURFACE_SIDE: i32 = 512; const BOUNDS: IRect = IRect { x0: 64, y0: 64...
KERNEL_SIZE / 2, ) }) }, ); } } criterion_group!(benches, bench_box_blur); criterion_main!(benches);
random_line_split
csskeyframerule.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::codegen::Bindings::CSSKeyframeRuleBinding; use dom::bindings::js::Root; use dom::bindings::refl...
{ cssrule: CSSRule, #[ignore_heap_size_of = "Arc"] keyframerule: Arc<RwLock<Keyframe>>, } impl CSSKeyframeRule { fn new_inherited(parent: Option<&CSSStyleSheet>, keyframerule: Arc<RwLock<Keyframe>>) -> CSSKeyframeRule { CSSKeyframeRule { cssrule: CSSRule::new_inherited(parent), ...
CSSKeyframeRule
identifier_name
csskeyframerule.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::codegen::Bindings::CSSKeyframeRuleBinding; use dom::bindings::js::Root; use dom::bindings::refl...
fn get_css(&self) -> DOMString { self.keyframerule.read().to_css_string().into() } }
{ use dom::bindings::codegen::Bindings::CSSRuleBinding::CSSRuleConstants; CSSRuleConstants::KEYFRAME_RULE }
identifier_body
csskeyframerule.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::codegen::Bindings::CSSKeyframeRuleBinding; use dom::bindings::js::Root; use dom::bindings::refl...
} impl CSSKeyframeRule { fn new_inherited(parent: Option<&CSSStyleSheet>, keyframerule: Arc<RwLock<Keyframe>>) -> CSSKeyframeRule { CSSKeyframeRule { cssrule: CSSRule::new_inherited(parent), keyframerule: keyframerule, } } #[allow(unrooted_must_root)] pub fn new...
random_line_split
mod.rs
use std::sync::atomic::AtomicBool; use std::ptr; use std::ffi::CString; use std::collections::VecDeque; use std::sync::mpsc::Receiver; use libc; use {CreationError, Event, MouseCursor}; use BuilderAttribs; pub use self::headless::HeadlessContext; pub use self::monitor::{MonitorID, get_available_monitors, get_primary_...
, Ok(ev) => Some(ev), Err(_) => None } } } #[unsafe_destructor] impl Drop for Window { fn drop(&mut self) { unsafe { // we don't call MakeCurrent(0, 0) because we are not sure that the context // is still the current one user32::PostMe...
{ use std::sync::atomic::Ordering::Relaxed; self.window.is_closed.store(true, Relaxed); Some(Closed) }
conditional_block
mod.rs
use std::sync::atomic::AtomicBool; use std::ptr; use std::ffi::CString; use std::collections::VecDeque; use std::sync::mpsc::Receiver; use libc; use {CreationError, Event, MouseCursor}; use BuilderAttribs; pub use self::headless::HeadlessContext; pub use self::monitor::{MonitorID, get_available_monitors, get_primary_...
} #[unsafe_destructor] impl Drop for Window { fn drop(&mut self) { unsafe { // we don't call MakeCurrent(0, 0) because we are not sure that the context // is still the current one user32::PostMessageW(self.window.0, winapi::WM_DESTROY, 0, 0); } } }
{ use events::Event::Closed; match self.window.events_receiver.recv() { Ok(Closed) => { use std::sync::atomic::Ordering::Relaxed; self.window.is_closed.store(true, Relaxed); Some(Closed) }, Ok(ev) => Some(ev), ...
identifier_body
mod.rs
use std::sync::atomic::AtomicBool; use std::ptr; use std::ffi::CString; use std::collections::VecDeque; use std::sync::mpsc::Receiver; use libc; use {CreationError, Event, MouseCursor}; use BuilderAttribs; pub use self::headless::HeadlessContext; pub use self::monitor::{MonitorID, get_available_monitors, get_primary_...
impl<'a> Iterator for PollEventsIterator<'a> { type Item = Event; fn next(&mut self) -> Option<Event> { use events::Event::Closed; match self.window.events_receiver.try_recv() { Ok(Closed) => { use std::sync::atomic::Ordering::Relaxed; self.window.i...
pub struct PollEventsIterator<'a> { window: &'a Window, }
random_line_split
mod.rs
use std::sync::atomic::AtomicBool; use std::ptr; use std::ffi::CString; use std::collections::VecDeque; use std::sync::mpsc::Receiver; use libc; use {CreationError, Event, MouseCursor}; use BuilderAttribs; pub use self::headless::HeadlessContext; pub use self::monitor::{MonitorID, get_available_monitors, get_primary_...
(&self) -> WindowProxy { WindowProxy } /// See the docs in the crate root file. pub fn poll_events(&self) -> PollEventsIterator { PollEventsIterator { window: self, } } /// See the docs in the crate root file. pub fn wait_events(&self) -> WaitEventsIterator ...
create_window_proxy
identifier_name
regions-infer-borrow-scope-too-big.rs
// Copyright 2012 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 ...
() {}
main
identifier_name
regions-infer-borrow-scope-too-big.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT.
// option. This file may not be copied, modified, or distributed // except according to those terms. struct point { x: isize, y: isize, } fn x_coord<'r>(p: &'r point) -> &'r isize { return &p.x; } fn foo<'a>(p: Box<point>) -> &'a isize { let xc = x_coord(&*p); //~ ERROR `*p` does not live long enoug...
// // 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
random_line_split
mod.rs
Data<'tcx>) { let mut glcx = GatherLoanCtxt { bccx: bccx, all_loans: Vec::new(), item_ub: region::CodeExtent::from_node_id(body.id), move_data: MoveData::new(), move_error_collector: move_error::MoveErrorCollector::new(), }; let param_env = ty::ParameterEnvironment::...
fn matched_pat(&mut self, matched_pat: &ast::Pat, cmt: mc::cmt<'tcx>, mode: euv::MatchMode) { debug!("matched_pat(matched_pat={}, cmt={}, mode={:?})", matched_pat.repr(self.tcx()), cmt.repr(self.tcx()), mod...
} euv::Copy => { } } }
random_line_split
mod.rs
); } glcx.report_potential_errors(); let GatherLoanCtxt { all_loans, move_data,.. } = glcx; (all_loans, move_data) } struct GatherLoanCtxt<'a, 'tcx: 'a> { bccx: &'a BorrowckCtxt<'a, 'tcx>, move_data: move_data::MoveData<'tcx>, move_error_collector: move_error::MoveErrorCollector<'tcx>, ...
compute_kill_scope
identifier_name
mod.rs
<'tcx>) { let mut glcx = GatherLoanCtxt { bccx: bccx, all_loans: Vec::new(), item_ub: region::CodeExtent::from_node_id(body.id), move_data: MoveData::new(), move_error_collector: move_error::MoveErrorCollector::new(), }; let param_env = ty::ParameterEnvironment::for_...
} /// Implements the A-* rules in README.md. fn check_aliasability<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>, borrow_span: Span, loan_cause: euv::LoanCause, cmt: mc::cmt<'tcx>, req_kind: ty::B...
{ gather_moves::gather_decl(self.bccx, &self.move_data, id, span, id); }
identifier_body
mod.rs
<'tcx>) { let mut glcx = GatherLoanCtxt { bccx: bccx, all_loans: Vec::new(), item_ub: region::CodeExtent::from_node_id(body.id), move_data: MoveData::new(), move_error_collector: move_error::MoveErrorCollector::new(), }; let param_env = ty::ParameterEnvironment::for_...
} } } } pub fn mark_loan_path_as_mutated(&self, loan_path: &LoanPath) { //! For mutable loans of content whose mutability derives //! from a local variable, mark the mutability decl as necessary. match loan_path.kind { LpVar(local_id) | ...
{ Ok(()) }
conditional_block
for-loop-bogosity.rs
// Copyright 2014 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 ...
{ x: int, y: int, } impl MyStruct { fn next(&mut self) -> Option<int> { Some(self.x) } } pub fn main() { let mut bogus = MyStruct { x: 1, y: 2, }; for x in bogus { //~ ERROR has type `MyStruct` which does not implement the `Iterator` trait drop(x); } }
MyStruct
identifier_name
for-loop-bogosity.rs
// Copyright 2014 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 ...
}
drop(x); }
random_line_split
for-loop-bogosity.rs
// Copyright 2014 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 ...
} pub fn main() { let mut bogus = MyStruct { x: 1, y: 2, }; for x in bogus { //~ ERROR has type `MyStruct` which does not implement the `Iterator` trait drop(x); } }
{ Some(self.x) }
identifier_body
filters.rs
// Copyright (C) 2020 Jason Ish // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // ...
CustomFieldFilter(CustomFieldFilter), AddRuleFilter(AddRuleFilter), Filters(Arc<Vec<EveFilter>>), } impl EveFilter { pub fn run(&self, event: &mut EveJson) { match self { EveFilter::GeoIP(geoip) => { geoip.add_geoip_to_eve(event); } EveFilter:...
pub enum EveFilter { GeoIP(crate::geoip::GeoIP), EveBoxMetadataFilter(EveBoxMetadataFilter),
random_line_split
filters.rs
// Copyright (C) 2020 Jason Ish // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // ...
{ pub field: String, pub value: String, } impl CustomFieldFilter { pub fn new(field: &str, value: &str) -> Self { Self { field: field.to_string(), value: value.to_string(), } } pub fn run(&self, event: &mut EveJson) { event[&self.field] = self.value...
CustomFieldFilter
identifier_name
filters.rs
// Copyright (C) 2020 Jason Ish // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // ...
EveFilter::AddRuleFilter(filter) => { filter.run(event); } EveFilter::Filters(filters) => { for filter in filters.iter() { filter.run(event); } } } } } #[derive(Debug, Default)] pub struct E...
{ filter.run(event); }
conditional_block
filters.rs
// Copyright (C) 2020 Jason Ish // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // ...
}
{ if let EveJson::String(_) = event["alert"]["rule"] { return; } if let Some(sid) = &event["alert"]["signature_id"].as_u64() { if let Some(rule) = self.map.find_by_sid(*sid) { event["alert"]["rule"] = rule.into(); } else { trace...
identifier_body
small-enums-with-fields.rs
// Copyright 2013 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 ...
use std::mem::size_of; #[deriving(Eq, Show)] enum Either<T, U> { Left(T), Right(U) } macro_rules! check { ($t:ty, $sz:expr, $($e:expr, $s:expr),*) => {{ assert_eq!(size_of::<$t>(), $sz); $({ static S: $t = $e; let v: $t = $e; assert_eq!(S, v); assert...
// option. This file may not be copied, modified, or distributed // except according to those terms. #![feature(macro_rules)]
random_line_split
small-enums-with-fields.rs
// Copyright 2013 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 ...
<T, U> { Left(T), Right(U) } macro_rules! check { ($t:ty, $sz:expr, $($e:expr, $s:expr),*) => {{ assert_eq!(size_of::<$t>(), $sz); $({ static S: $t = $e; let v: $t = $e; assert_eq!(S, v); assert_eq!(format!("{:?}", v), ~$s); assert_eq!(for...
Either
identifier_name
generator.rs
// This file is part of libfringe, a low-level green threading library. // Copyright (c) whitequark <whitequark@whitequark.org>, // Nathan Zadoks <nathan@nathan7.eu> // Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or // http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE...
let stack = SliceStack(&mut memory); let mut add_one = unsafe { Generator::unsafe_new(stack, add_one_fn) }; assert_eq!(add_one.resume(1), Some(2)); assert_eq!(add_one.resume(2), Some(3)); } #[test] fn with_owned_stack() { let stack = OwnedStack::new(1024); let mut add_one = unsafe { Generator::unsafe_new(s...
fn with_slice_stack() { let mut memory = [0; 1024];
random_line_split
generator.rs
// This file is part of libfringe, a low-level green threading library. // Copyright (c) whitequark <whitequark@whitequark.org>, // Nathan Zadoks <nathan@nathan7.eu> // Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or // http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE...
run_moved(add_one); } #[test] #[should_panic] fn panic_safety() { struct Wrapper { gen: Generator<(), (), OsStack> } impl Drop for Wrapper { fn drop(&mut self) { self.gen.resume(()); } } let stack = OsStack::new(4 << 20).unwrap(); let gen = Generator::new(stack, move |_yielder, ()| {...
{ assert_eq!(add_one.resume(2), Some(3)); assert_eq!(add_one.resume(3), Some(4)); assert_eq!(add_one.resume(0), None); }
identifier_body
generator.rs
// This file is part of libfringe, a low-level green threading library. // Copyright (c) whitequark <whitequark@whitequark.org>, // Nathan Zadoks <nathan@nathan7.eu> // Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or // http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE...
*self.0 = true; } } } let stack = fringe::OsStack::new(1<<16).unwrap(); let mut generator = Generator::new(stack, |yielder, ()| { let mut flag = false; yielder.suspend(Dropper(&mut flag as *mut bool)); }); generator.resume(()); generator.resume(()); }
{ panic!("double drop!") }
conditional_block
generator.rs
// This file is part of libfringe, a low-level green threading library. // Copyright (c) whitequark <whitequark@whitequark.org>, // Nathan Zadoks <nathan@nathan7.eu> // Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or // http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE...
() { let mut add_one = new_add_one(); assert_eq!(add_one.resume(1), Some(2)); #[inline(never)] fn run_moved(mut add_one: Generator<i32, i32, OsStack>) { assert_eq!(add_one.resume(2), Some(3)); assert_eq!(add_one.resume(3), Some(4)); assert_eq!(add_one.resume(0), None); } run_moved(add_one); } ...
move_after_new
identifier_name
build.rs
// Copyright 2016 The Kythe Authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by appli...
{ let out_dir = env::var("OUT_DIR").expect("OUT_DIR variable must be set"); let dep_dir = Path::new(&out_dir).join("../../../deps"); let cargo_home = env::var("CARGO_HOME").expect("CARGO_HOME variable must be set"); let so_folder = Path::new(&cargo_home).join("kythe"); let indexer = fs::read_dir(de...
identifier_body
build.rs
// Copyright 2016 The Kythe Authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by appli...
() { let out_dir = env::var("OUT_DIR").expect("OUT_DIR variable must be set"); let dep_dir = Path::new(&out_dir).join("../../../deps"); let cargo_home = env::var("CARGO_HOME").expect("CARGO_HOME variable must be set"); let so_folder = Path::new(&cargo_home).join("kythe"); let indexer = fs::read_dir...
main
identifier_name
build.rs
// Copyright 2016 The Kythe Authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by appli...
.expect("failed to copy indexer to kythe directory"); }
fs::create_dir_all(so_folder.as_path()).expect("failed to create kythe directory"); fs::copy(indexer.path(), so_folder.join(indexer.file_name()))
random_line_split
count_fast.rs
use crate::word_count::WordCount; use super::WordCountable; #[cfg(any(target_os = "linux", target_os = "android"))] use std::fs::OpenOptions; use std::io::{self, ErrorKind, Read}; #[cfg(unix)] use libc::S_IFREG; #[cfg(unix)] use nix::sys::stat; #[cfg(any(target_os = "linux", target_os = "android"))] use std::os::uni...
<R: Read>( handle: &mut R, ) -> (WordCount, Option<io::Error>) { let mut total = WordCount::default(); let mut buf = [0; BUF_SIZE]; loop { match handle.read(&mut buf) { Ok(0) => return (total, None), Ok(n) => { total.bytes += n; total.lines...
count_bytes_and_lines_fast
identifier_name
count_fast.rs
use crate::word_count::WordCount; use super::WordCountable; #[cfg(any(target_os = "linux", target_os = "android"))] use std::fs::OpenOptions; use std::io::{self, ErrorKind, Read}; #[cfg(unix)] use libc::S_IFREG; #[cfg(unix)] use nix::sys::stat; #[cfg(any(target_os = "linux", target_os = "android"))] use std::os::uni...
Err(ref e) if e.kind() == ErrorKind::Interrupted => continue, Err(e) => return (byte_count, Some(e)), } } } pub(crate) fn count_bytes_and_lines_fast<R: Read>( handle: &mut R, ) -> (WordCount, Option<io::Error>) { let mut total = WordCount::default(); let mut buf = [0; B...
{ byte_count += n; }
conditional_block
count_fast.rs
use crate::word_count::WordCount; use super::WordCountable; #[cfg(any(target_os = "linux", target_os = "android"))] use std::fs::OpenOptions; use std::io::{self, ErrorKind, Read}; #[cfg(unix)] use libc::S_IFREG; #[cfg(unix)] use nix::sys::stat; #[cfg(any(target_os = "linux", target_os = "android"))] use std::os::uni...
// Else, if we're on Linux and our file is a FIFO pipe // (or stdin), we use splice to count the number of bytes. if (stat.st_mode & S_IFIFO)!= 0 { match count_bytes_using_splice(handle) { Ok(n) => return (n, None), ...
{ let mut byte_count = 0; #[cfg(unix)] { let fd = handle.as_raw_fd(); if let Ok(stat) = stat::fstat(fd) { // If the file is regular, then the `st_size` should hold // the file's size in bytes. // If stat.st_size = 0 then // - either the size ...
identifier_body