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 |
|---|---|---|---|---|
task.rs | //! Helpers to program the task state segment.
//! See Intel 3a, Chapter 7, Section 7
use crate::Ring;
/// Although hardware task-switching is not supported in 64-bit mode,
/// a 64-bit task state segment (TSS) must exist.
///
/// The TSS holds information important to 64-bit mode and that is not
/// directly related... | /// The 16-bit offset to the I/O permission bit map from the 64-bit TSS base.
pub iomap_base: u16,
}
impl TaskStateSegment {
/// Creates a new empty TSS.
pub const fn new() -> TaskStateSegment {
TaskStateSegment {
reserved: 0,
rsp: [0; 3],
reserved2: 0,
... | pub ist: [u64; 7],
pub reserved3: u64,
pub reserved4: u16, | random_line_split |
task.rs | //! Helpers to program the task state segment.
//! See Intel 3a, Chapter 7, Section 7
use crate::Ring;
/// Although hardware task-switching is not supported in 64-bit mode,
/// a 64-bit task state segment (TSS) must exist.
///
/// The TSS holds information important to 64-bit mode and that is not
/// directly related... |
/// Sets the stack pointer (`stack_ptr`) to be used when
/// an interrupt with a corresponding IST entry in the Interrupt
/// Descriptor table pointing to the given `index` is raised.
pub fn set_ist(&mut self, index: usize, stack_ptr: u64) {
match index {
0 => self.ist[0] = stack_p... | {
match pl {
Ring::Ring0 => self.rsp[0] = stack_ptr,
Ring::Ring1 => self.rsp[1] = stack_ptr,
Ring::Ring2 => self.rsp[2] = stack_ptr,
Ring::Ring3 => unreachable!("Can't set stack for PL3"),
}
} | identifier_body |
task.rs | //! Helpers to program the task state segment.
//! See Intel 3a, Chapter 7, Section 7
use crate::Ring;
/// Although hardware task-switching is not supported in 64-bit mode,
/// a 64-bit task state segment (TSS) must exist.
///
/// The TSS holds information important to 64-bit mode and that is not
/// directly related... | (&mut self, pl: Ring, stack_ptr: u64) {
match pl {
Ring::Ring0 => self.rsp[0] = stack_ptr,
Ring::Ring1 => self.rsp[1] = stack_ptr,
Ring::Ring2 => self.rsp[2] = stack_ptr,
Ring::Ring3 => unreachable!("Can't set stack for PL3"),
}
}
/// Sets the sta... | set_rsp | identifier_name |
expr.rs | use crate::position::Pos;
use crate::tokenizer::{Kind, TokenStream};
/// Error of expression checking
///
/// See [check][].
#[derive(Debug, thiserror::Error)]
pub enum Error {
#[error("{}: tokenizer error: {}", _1, _0)]
Tokenizer(String, Pos),
#[error(
"{}: closing bracket mismatch, opened {:?} at... | pub fn check(text: &str) -> Result<(), Error> {
use crate::tokenizer::Kind::*;
use Error::*;
let mut brackets = Vec::new();
let mut parser = &mut TokenStream::new(text);
let mut empty = true;
for token in &mut parser {
let (token, pos) = match token {
Ok(t) => (t.token, t.st... | /// semicolon `;` outside of brackets.
///
/// This is NOT a security measure. | random_line_split |
expr.rs | use crate::position::Pos;
use crate::tokenizer::{Kind, TokenStream};
/// Error of expression checking
///
/// See [check][].
#[derive(Debug, thiserror::Error)]
pub enum Error {
#[error("{}: tokenizer error: {}", _1, _0)]
Tokenizer(String, Pos),
#[error(
"{}: closing bracket mismatch, opened {:?} at... | (tok: Kind) -> Kind {
use crate::tokenizer::Kind::*;
match tok {
OpenBracket => CloseBracket,
OpenBrace => CloseBrace,
OpenParen => CloseParen,
_ => unreachable!("token is not a bracket"),
}
}
/// Minimal validation of expression
///
/// This is used for substitutions in mi... | matching_bracket | identifier_name |
expr.rs | use crate::position::Pos;
use crate::tokenizer::{Kind, TokenStream};
/// Error of expression checking
///
/// See [check][].
#[derive(Debug, thiserror::Error)]
pub enum Error {
#[error("{}: tokenizer error: {}", _1, _0)]
Tokenizer(String, Pos),
#[error(
"{}: closing bracket mismatch, opened {:?} at... |
Ok(())
}
| {
return Err(Empty);
} | conditional_block |
expr.rs | use crate::position::Pos;
use crate::tokenizer::{Kind, TokenStream};
/// Error of expression checking
///
/// See [check][].
#[derive(Debug, thiserror::Error)]
pub enum Error {
#[error("{}: tokenizer error: {}", _1, _0)]
Tokenizer(String, Pos),
#[error(
"{}: closing bracket mismatch, opened {:?} at... | match token.kind {
Comma | Semicolon if brackets.is_empty() => {
return Err(UnexpectedToken(token.value.to_string(), pos));
}
OpenParen | OpenBracket | OpenBrace => {
brackets.push((token.kind, pos));
}
CloseParen | Clos... | {
use crate::tokenizer::Kind::*;
use Error::*;
let mut brackets = Vec::new();
let mut parser = &mut TokenStream::new(text);
let mut empty = true;
for token in &mut parser {
let (token, pos) = match token {
Ok(t) => (t.token, t.start),
Err(combine::easy::Error::Un... | identifier_body |
archive.rs | //! Creation of ar archives like for the lib and staticlib crate type
use std::collections::BTreeMap;
use std::convert::TryFrom;
use std::fs::File;
use std::io::{self, Read, Seek};
use std::path::{Path, PathBuf};
use rustc_codegen_ssa::back::archive::ArchiveBuilder;
use rustc_session::Session;
use object::read::arch... |
fn add_file(&mut self, file: &Path) {
self.entries.push((
file.file_name().unwrap().to_str().unwrap().to_string().into_bytes(),
ArchiveEntry::File(file.to_owned()),
));
}
fn add_archive<F>(&mut self, archive_path: &Path, mut skip: F) -> std::io::Result<()>
wher... | {
let index = self
.entries
.iter()
.position(|(entry_name, _)| entry_name == name.as_bytes())
.expect("Tried to remove file not existing in src archive");
self.entries.remove(index);
} | identifier_body |
archive.rs | //! Creation of ar archives like for the lib and staticlib crate type
use std::collections::BTreeMap;
use std::convert::TryFrom;
use std::fs::File;
use std::io::{self, Read, Seek};
use std::path::{Path, PathBuf};
use rustc_codegen_ssa::back::archive::ArchiveBuilder;
use rustc_session::Session;
use object::read::arch... |
}
}
}
entries.push((entry_name, data));
}
let mut builder = if self.use_gnu_style_archive {
BuilderKind::Gnu(
ar::GnuBuilder::new(
File::create(&self.dst).unwrap_or_else(|err| {
... | {
sess.fatal(&format!(
"error parsing `{}` during archive creation: {}",
String::from_utf8_lossy(&entry_name),
err
));
} | conditional_block |
archive.rs | //! Creation of ar archives like for the lib and staticlib crate type
use std::collections::BTreeMap;
use std::convert::TryFrom;
use std::fs::File;
use std::io::{self, Read, Seek};
use std::path::{Path, PathBuf};
use rustc_codegen_ssa::back::archive::ArchiveBuilder;
use rustc_session::Session;
use object::read::arch... | ));
}
(vec![read_cache.into_inner()], entries)
} else {
(vec![], Vec::new())
};
ArArchiveBuilder {
sess,
dst: output.to_path_buf(),
use_gnu_style_archive: sess.target.archive_format == "gnu",
//... | ArchiveEntry::FromArchive { archive_index: 0, file_range: entry.file_range() }, | random_line_split |
archive.rs | //! Creation of ar archives like for the lib and staticlib crate type
use std::collections::BTreeMap;
use std::convert::TryFrom;
use std::fs::File;
use std::io::{self, Read, Seek};
use std::path::{Path, PathBuf};
use rustc_codegen_ssa::back::archive::ArchiveBuilder;
use rustc_session::Session;
use object::read::arch... | (
&mut self,
_lib_name: &str,
_dll_imports: &[rustc_session::cstore::DllImport],
_tmpdir: &rustc_data_structures::temp_dir::MaybeTempDir,
) {
bug!("injecting dll imports is not supported");
}
}
| inject_dll_import_lib | identifier_name |
borrowck-newtype-issue-2573.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 ... |
}
// Override default mode so that we are passing by value
fn really_impure(++bar: baz) {
bar.baz = 3;
}
pub fn main() {}
| {
really_impure(self.bar);
} | identifier_body |
borrowck-newtype-issue-2573.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 ... |
impl frob for foo {
fn frob(&self) {
really_impure(self.bar);
}
}
// Override default mode so that we are passing by value
fn really_impure(++bar: baz) {
bar.baz = 3;
}
pub fn main() {} | fn frob(&self);
} | random_line_split |
borrowck-newtype-issue-2573.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) {
really_impure(self.bar);
}
}
// Override default mode so that we are passing by value
fn really_impure(++bar: baz) {
bar.baz = 3;
}
pub fn main() {}
| frob | identifier_name |
func.rs | //! Module for working with `Function`s
//!
//! This module contains a type alias for `Rc<Fn(f64) -> f64>`,
//! which is used in many other modules, and functions for
//! working with the alias.
pub use std::rc::Rc;
/// Type alias used to represent functions.
///
/// A `Function` is a `Fn` that takes a single `f64`,
... | /// ```
/// # #[macro_use]
/// # extern crate reikna;
/// # fn main() {
/// use reikna::func::*;
/// let f: Function = func!(|x| x * x);
/// assert_eq!(f(5.0), 25.0);
/// # }
/// ```
#[macro_export]
macro_rules! func {
($e:expr) => (Rc::new($e) as Function);
} | /// More idiomatic than calling `Rc::new()`.
///
/// # Examples
/// | random_line_split |
expr-alt-struct.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 ... | () {
let rs = match true { true => R {i: 100}, _ => fail!() };
assert!((rs.i == 100));
}
enum mood { happy, sad, }
impl cmp::Eq for mood {
fn eq(&self, other: &mood) -> bool {
((*self) as uint) == ((*other) as uint)
}
fn ne(&self, other: &mood) -> bool {!(*self).eq(other) }
}
fn test_tag(... | test_rec | identifier_name |
expr-alt-struct.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 ... | { test_rec(); test_tag(); } | identifier_body | |
expr-alt-struct.rs | // Copyright 2012 The Rust Project Developers. See the 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 http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// -*- rust -*-
... | // file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
// | random_line_split |
container.rs | #![macro_use]
pub trait FromEcs<E: ContainsSystem> where Self: Sized {
fn from_ecs(ecs: &E) -> &Self;
}
pub trait FromEcsMut<E: ContainsMutSystem>: FromEcs<E> {
fn from_ecs_mut(ecs: &mut E) -> &mut Self;
}
pub trait ContainsSystem where Self: Sized {
fn get_system<S>(&self) -> &S
where S: FromEcs... |
pub struct EcsContainer {
pub entity_factory: EntityFactory,
$(pub $sys_id: $sys_type,)+
$(pub $upd_id: $upd_type,)+
}
impl EcsContainer {
pub fn new_entity(&mut self) -> EntityConfiguration<Self> {
let entity = self.entity_factory.new_entity();
self... |
pub trait ConfiguresComponent<C> {
fn with_component(self, component: C) -> Self;
} | random_line_split |
location.rs | header! {
/// `Location` header, defined in
/// [RFC7231](http://tools.ietf.org/html/rfc7231#section-7.1.2)
///
/// The `Location` header field is used in some responses to refer to a
/// specific resource in relation to the response. The type of
/// relationship is defined by the combination o... | test_header!(test2, vec![b"http://www.example.net/index.html"]);
}
}
bench_header!(bench, Location, { vec![b"http://foo.com/hello:3000".to_vec()] }); | // Testcase from RFC
test_header!(test1, vec![b"/People.html#tim"]); | random_line_split |
domrect.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::DOMRectBinding;
use dom::bindings::codegen::Bindings::DOMRectBinding::DOMRec... |
}
| {
self.rect.set_height(value);
} | identifier_body |
domrect.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::DOMRectBinding;
use dom::bindings::codegen::Bindings::DOMRectBinding::DOMRec... | (&self) -> f64 {
self.rect.Width()
}
// https://drafts.fxtf.org/geometry/#dom-domrect-width
fn SetWidth(&self, value: f64) {
self.rect.set_width(value);
}
// https://drafts.fxtf.org/geometry/#dom-domrect-height
fn Height(&self) -> f64 {
self.rect.Height()
}
// ... | Width | identifier_name |
domrect.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::DOMRectBinding;
use dom::bindings::codegen::Bindings::DOMRectBinding::DOMRec... | impl DOMRect {
fn new_inherited(x: f64, y: f64, width: f64, height: f64) -> DOMRect {
DOMRect {
rect: DOMRectReadOnly::new_inherited(x, y, width, height),
}
}
pub fn new(global: &GlobalScope, x: f64, y: f64, width: f64, height: f64) -> DomRoot<DOMRect> {
reflect_dom_obje... | rect: DOMRectReadOnly,
}
| random_line_split |
woff_metadata_license_generated.rs | // automatically generated by the FlatBuffers compiler, do not modify
extern crate flatbuffers;
use std::mem;
use std::cmp::Ordering;
use self::flatbuffers::{EndianScalar, Follow};
use super::*;
pub enum WoffMetadataLicenseOffset {}
#[derive(Copy, Clone, PartialEq)]
| pub struct WoffMetadataLicense<'a> {
pub _tab: flatbuffers::Table<'a>,
}
impl<'a> flatbuffers::Follow<'a> for WoffMetadataLicense<'a> {
type Inner = WoffMetadataLicense<'a>;
#[inline]
fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
Self { _tab: flatbuffers::Table { buf, loc } }
}
}
impl<'a> WoffMe... | random_line_split | |
woff_metadata_license_generated.rs | // automatically generated by the FlatBuffers compiler, do not modify
extern crate flatbuffers;
use std::mem;
use std::cmp::Ordering;
use self::flatbuffers::{EndianScalar, Follow};
use super::*;
pub enum WoffMetadataLicenseOffset {}
#[derive(Copy, Clone, PartialEq)]
pub struct WoffMetadataLicense<'a> {
pub _tab: fla... |
builder.finish()
}
#[inline]
pub fn url(&self) -> Option<&'a str> {
self._tab.get::<flatbuffers::ForwardsUOffset<&str>>(WoffMetadataLicense::VT_URL, None)
}
#[inline]
pub fn id(&self) -> Option<&'a str> {
self._tab.get::<flatbuffers::ForwardsUOffset<&str>>(WoffMetadataLicense::VT_ID, None)
... | { builder.add_url(x); } | conditional_block |
woff_metadata_license_generated.rs | // automatically generated by the FlatBuffers compiler, do not modify
extern crate flatbuffers;
use std::mem;
use std::cmp::Ordering;
use self::flatbuffers::{EndianScalar, Follow};
use super::*;
pub enum WoffMetadataLicenseOffset {}
#[derive(Copy, Clone, PartialEq)]
pub struct WoffMetadataLicense<'a> {
pub _tab: fla... |
}
pub struct WoffMetadataLicenseArgs<'a> {
pub url: Option<flatbuffers::WIPOffset<&'a str>>,
pub id: Option<flatbuffers::WIPOffset<&'a str>>,
pub text: Option<flatbuffers::WIPOffset<flatbuffers::Vector<'a, flatbuffers::ForwardsUOffset<WoffMetadataText<'a>>>>>,
}
impl<'a> Default for WoffMetadataLicenseArgs... | {
use self::flatbuffers::Verifiable;
v.visit_table(pos)?
.visit_field::<flatbuffers::ForwardsUOffset<&str>>("url", Self::VT_URL, false)?
.visit_field::<flatbuffers::ForwardsUOffset<&str>>("id", Self::VT_ID, false)?
.visit_field::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'_, flatbuffers::F... | identifier_body |
woff_metadata_license_generated.rs | // automatically generated by the FlatBuffers compiler, do not modify
extern crate flatbuffers;
use std::mem;
use std::cmp::Ordering;
use self::flatbuffers::{EndianScalar, Follow};
use super::*;
pub enum WoffMetadataLicenseOffset {}
#[derive(Copy, Clone, PartialEq)]
pub struct WoffMetadataLicense<'a> {
pub _tab: fla... | (self) -> flatbuffers::WIPOffset<WoffMetadataLicense<'a>> {
let o = self.fbb_.end_table(self.start_);
flatbuffers::WIPOffset::new(o.value())
}
}
impl std::fmt::Debug for WoffMetadataLicense<'_> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let mut ds = f.debug_struct("WoffMetad... | finish | identifier_name |
managed-pointer-within-unique.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 ... | () {()}
| zzz | identifier_name |
managed-pointer-within-unique.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 ... |
// compile-flags:-Z extra-debug-info
// debugger:set print pretty off
// debugger:rbreak zzz
// debugger:run
// debugger:finish
// debugger:print *ordinary_unique
// check:$1 = {-1, -2}
// debugger:print managed_within_unique.val->x
// check:$2 = -3
// debugger:print managed_within_unique.val->y->val
// check:$3 = ... |
// xfail-android: FIXME(#10381)
#[feature(managed_boxes)]; | random_line_split |
translation.rs | use register::{Word, SysResult, Original, Modified, StackPointer};
use kernel::{enter, exit};
use process::proot::InfoBag;
use process::tracee::{TraceeStatus, TraceeRestartMethod, Tracee};
pub trait SyscallTranslator {
fn translate_syscall(&mut self, info_bag: &InfoBag);
fn translate_syscall_enter(&mut self, i... | // status = notify_extensions(tracee, SYSCALL_EXIT_START, 0, 0);
// if (status < 0) {
// poke_reg(tracee, SYSARG_RESULT, (word_t) status);
// goto end;
// }
// if (status > 0)
// return;
if self.status.is_ok() {
exit::translate(sel... | fn translate_syscall_exit(&mut self) {
// By default, restore original register values at the end of this stage.
self.regs.set_restore_original_regs(true);
//TODO: notify extensions for SYSCALL_EXIT_START event | random_line_split |
translation.rs | use register::{Word, SysResult, Original, Modified, StackPointer};
use kernel::{enter, exit};
use process::proot::InfoBag;
use process::tracee::{TraceeStatus, TraceeRestartMethod, Tracee};
pub trait SyscallTranslator {
fn translate_syscall(&mut self, info_bag: &InfoBag);
fn translate_syscall_enter(&mut self, i... |
//TODO: notify extensions for SYSCALL_EXIT_END event
// status = notify_extensions(tracee, SYSCALL_EXIT_END, 0, 0);
// if (status < 0)
// poke_reg(tracee, SYSARG_RESULT, (word_t) status);
// reset the tracee's status
self.status = TraceeStatus::SysEnter;
}
}
| {
self.regs.set(
SysResult,
self.status.get_errno() as Word,
"following previous error in enter stage, setting errno",
);
} | conditional_block |
translation.rs | use register::{Word, SysResult, Original, Modified, StackPointer};
use kernel::{enter, exit};
use process::proot::InfoBag;
use process::tracee::{TraceeStatus, TraceeRestartMethod, Tracee};
pub trait SyscallTranslator {
fn translate_syscall(&mut self, info_bag: &InfoBag);
fn translate_syscall_enter(&mut self, i... | // status2 = notify_extensions(tracee, SYSCALL_ENTER_END, status, 0);
// if (status2 < 0)
// status = status2;
// Saving the registers potentially modified by the translation.
// It's useful in order to know what the translation did to the registers.
self.regs.save_c... | {
// Never restore original register values at the end of this stage.
self.regs.set_restore_original_regs(false);
// Saving the original registers here.
// It is paramount in order to restore the regs after the exit stage,
// and also as memory in order to remember the original ... | identifier_body |
translation.rs | use register::{Word, SysResult, Original, Modified, StackPointer};
use kernel::{enter, exit};
use process::proot::InfoBag;
use process::tracee::{TraceeStatus, TraceeRestartMethod, Tracee};
pub trait SyscallTranslator {
fn translate_syscall(&mut self, info_bag: &InfoBag);
fn translate_syscall_enter(&mut self, i... | (&mut self, info_bag: &InfoBag) {
if let Err(error) = self.regs.fetch_regs() {
eprintln!("proot error: Error while fetching regs: {}", error);
return;
}
match self.status {
TraceeStatus::SysEnter => self.translate_syscall_enter(info_bag),
TraceeSt... | translate_syscall | identifier_name |
main.rs | extern crate regex;
extern crate rustc_demangle;
mod dol;
mod assembler;
use std::fs::File;
use std::io::{BufWriter, BufReader};
use std::io::prelude::*;
use assembler::Assembler;
use regex::Regex;
use rustc_demangle::demangle;
use dol::DolFile;
use assembler::Instruction;
use std::env::args;
const FRAMEWORK_MAP: &'... |
}
write!(file, "{}", FRAMEWORK_MAP).unwrap();
}
fn main() {
let mut asm = String::new();
let _ = File::open("../../src/patch.asm")
.expect("Couldn't find \"src/patch.asm\". If you don't need to patch the dol, just \
create an empty file.")
.read_to_string(&mut asm);
... | {
writeln!(file,
" 00000000 {:06x} {} 4 {} \t{}",
length,
address,
fn_name,
source_file)
.unwrap();
} | conditional_block |
main.rs | extern crate regex;
extern crate rustc_demangle;
mod dol;
mod assembler;
use std::fs::File;
use std::io::{BufWriter, BufReader};
use std::io::prelude::*;
use assembler::Assembler;
use regex::Regex;
use rustc_demangle::demangle;
use dol::DolFile;
use assembler::Instruction;
use std::env::args;
const FRAMEWORK_MAP: &'... | () {
let mut asm = String::new();
let _ = File::open("../../src/patch.asm")
.expect("Couldn't find \"src/patch.asm\". If you don't need to patch the dol, just \
create an empty file.")
.read_to_string(&mut asm);
let lines = &asm.lines().collect::<Vec<_>>();
let mut assem... | main | identifier_name |
main.rs | extern crate rustc_demangle;
mod dol;
mod assembler;
use std::fs::File;
use std::io::{BufWriter, BufReader};
use std::io::prelude::*;
use assembler::Assembler;
use regex::Regex;
use rustc_demangle::demangle;
use dol::DolFile;
use assembler::Instruction;
use std::env::args;
const FRAMEWORK_MAP: &'static str = include... | extern crate regex; | random_line_split | |
main.rs | extern crate regex;
extern crate rustc_demangle;
mod dol;
mod assembler;
use std::fs::File;
use std::io::{BufWriter, BufReader};
use std::io::prelude::*;
use assembler::Assembler;
use regex::Regex;
use rustc_demangle::demangle;
use dol::DolFile;
use assembler::Instruction;
use std::env::args;
const FRAMEWORK_MAP: &'... | .unwrap();
let line_ender = if section.data.len() % 8 > 0 {
8 - (section.data.len() % 8)
} else {
0
};
for (i, byte) in section.data
.iter()
.chain(std::iter::repeat(&0).take(line_ender))
.enumerate() {
if i ... | {
let mut file = File::create("../../cheat.txt")
.expect("Couldn't create \"cheat.txt\". You might need to provide higher \
privileges.");
writeln!(file, "A8000000 00000001").unwrap();
for instruction in instructions {
writeln!(file,
"{:08X} {:08X}",
... | identifier_body |
dropck-eyepatch-extern-crate.rs | // Copyright 2016 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 ... |
extern crate dropck_eyepatch_extern_crate as other;
use other::{Dt,Dr,Pt,Pr,St,Sr};
fn main() {
use std::cell::RefCell;
struct CheckOnDrop(RefCell<String>, &'static str);
impl Drop for CheckOnDrop {
fn drop(&mut self) { assert_eq!(*self.0.borrow(), self.1); }
}
let c_long;
let (c, d... | // except according to those terms.
// run-pass
// aux-build:dropck_eyepatch_extern_crate.rs | random_line_split |
dropck-eyepatch-extern-crate.rs | // Copyright 2016 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 c_long;
let (c, dt, dr, pt, pr, st, sr)
: (CheckOnDrop, Dt<_>, Dr<_>, Pt<_, _>, Pr<_>, St<_>, Sr<_>);
c_long = CheckOnDrop(RefCell::new("c_long".to_string()),
"c_long|pr|pt|dr|dt");
c = CheckOnDrop(RefCell::new("c".to_string()),
"c");
... | { assert_eq!(*self.0.borrow(), self.1); } | identifier_body |
dropck-eyepatch-extern-crate.rs | // Copyright 2016 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 ... | (&mut self) { assert_eq!(*self.0.borrow(), self.1); }
}
let c_long;
let (c, dt, dr, pt, pr, st, sr)
: (CheckOnDrop, Dt<_>, Dr<_>, Pt<_, _>, Pr<_>, St<_>, Sr<_>);
c_long = CheckOnDrop(RefCell::new("c_long".to_string()),
"c_long|pr|pt|dr|dt");
c = CheckOnDrop(RefCell:... | drop | identifier_name |
method-ambig-one-trait-unknown-int-type.rs | // Copyright 2012-2015 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... | (&self) -> isize {2}
}
// This is very hokey: we have heuristics to suppress messages about
// type annotations required. But placing these two bits of code into
// distinct functions, in this order, causes us to print out both
// errors I'd like to see.
fn m1() {
// we couldn't infer the type of the vector just ... | foo | identifier_name |
method-ambig-one-trait-unknown-int-type.rs | // Copyright 2012-2015 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 foo for Vec<isize> {
fn foo(&self) -> isize {2}
}
// This is very hokey: we have heuristics to suppress messages about
// type annotations required. But placing these two bits of code into
// distinct functions, in this order, causes us to print out both
// errors I'd like to see.
fn m1() {
// we cou... | {1} | identifier_body |
method-ambig-one-trait-unknown-int-type.rs | // Copyright 2012-2015 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... |
// This is very hokey: we have heuristics to suppress messages about
// type annotations required. But placing these two bits of code into
// distinct functions, in this order, causes us to print out both
// errors I'd like to see.
fn m1() {
// we couldn't infer the type of the vector just based on calling foo().... |
impl foo for Vec<isize> {
fn foo(&self) -> isize {2}
} | random_line_split |
small-enum-range-edge.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 ... |
// this is for the wrapping_add call below.
#![feature(core)]
/*!
* Tests the range assertion wraparound case in trans::middle::adt::load_discr.
*/
#[repr(u8)]
#[derive(Copy, Clone)]
enum Eu { Lu = 0, Hu = 255 }
static CLu: Eu = Eu::Lu;
static CHu: Eu = Eu::Hu;
#[repr(i8)]
#[derive(Copy, Clone)]
enum Es { Ls = -... | // except according to those terms.
| random_line_split |
small-enum-range-edge.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 ... | { Lu = 0, Hu = 255 }
static CLu: Eu = Eu::Lu;
static CHu: Eu = Eu::Hu;
#[repr(i8)]
#[derive(Copy, Clone)]
enum Es { Ls = -128, Hs = 127 }
static CLs: Es = Es::Ls;
static CHs: Es = Es::Hs;
pub fn main() {
assert_eq!((Eu::Hu as u8).wrapping_add(1), Eu::Lu as u8);
assert_eq!((Es::Hs as i8).wrapping_add(1), Es... | Eu | identifier_name |
small-enum-range-edge.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 ... | {
assert_eq!((Eu::Hu as u8).wrapping_add(1), Eu::Lu as u8);
assert_eq!((Es::Hs as i8).wrapping_add(1), Es::Ls as i8);
assert_eq!(CLu as u8, Eu::Lu as u8);
assert_eq!(CHu as u8, Eu::Hu as u8);
assert_eq!(CLs as i8, Es::Ls as i8);
assert_eq!(CHs as i8, Es::Hs as i8);
} | identifier_body | |
hello_canvas.rs | //! Basic hello world example, drawing
//! to a canvas.
use ggez::event;
use ggez::graphics::{self, Color};
use ggez::{Context, GameResult};
use glam::*;
use std::env;
use std::path;
struct MainState {
text: graphics::Text,
canvas: graphics::Canvas,
frames: usize,
draw_with_canvas: bool,
}
impl MainS... | else {
path::PathBuf::from("./resources")
};
let cb = ggez::ContextBuilder::new("hello_canvas", "ggez").add_resource_path(resource_dir);
let (mut ctx, event_loop) = cb.build()?;
let state = MainState::new(&mut ctx)?;
event::run(ctx, event_loop, state)
}
| {
let mut path = path::PathBuf::from(manifest_dir);
path.push("resources");
path
} | conditional_block |
hello_canvas.rs | //! Basic hello world example, drawing
//! to a canvas.
use ggez::event;
use ggez::graphics::{self, Color};
use ggez::{Context, GameResult};
use glam::*;
use std::env;
use std::path;
struct MainState {
text: graphics::Text,
canvas: graphics::Canvas,
frames: usize,
draw_with_canvas: bool,
}
impl MainS... |
fn draw(&mut self, ctx: &mut Context) -> GameResult {
let dest_point = Vec2::new(10.0, 10.0);
if self.draw_with_canvas {
println!("Drawing with canvas");
graphics::clear(ctx, graphics::Color::from((64, 0, 0, 0)));
graphics::set_canvas(ctx, Some(&self.canvas));... | {
Ok(())
} | identifier_body |
hello_canvas.rs | //! Basic hello world example, drawing
//! to a canvas.
use ggez::event;
use ggez::graphics::{self, Color};
use ggez::{Context, GameResult};
use glam::*;
use std::env;
use std::path;
struct MainState {
text: graphics::Text,
canvas: graphics::Canvas,
frames: usize,
draw_with_canvas: bool,
}
impl MainS... | (
&mut self,
_ctx: &mut Context,
_keycode: ggez::event::KeyCode,
_keymod: ggez::event::KeyMods,
repeat: bool,
) {
if!repeat {
self.draw_with_canvas =!self.draw_with_canvas;
println!("Canvas on: {}", self.draw_with_canvas);
}
}
}
pu... | key_down_event | identifier_name |
hello_canvas.rs | //! Basic hello world example, drawing
//! to a canvas.
use ggez::event;
use ggez::graphics::{self, Color};
use ggez::{Context, GameResult};
use glam::*;
use std::env;
use std::path;
struct MainState {
text: graphics::Text,
canvas: graphics::Canvas,
frames: usize,
draw_with_canvas: bool,
}
impl MainS... | println!("Canvas on: {}", self.draw_with_canvas);
}
}
}
pub fn main() -> GameResult {
let resource_dir = if let Ok(manifest_dir) = env::var("CARGO_MANIFEST_DIR") {
let mut path = path::PathBuf::from(manifest_dir);
path.push("resources");
path
} else {
pat... | repeat: bool,
) {
if !repeat {
self.draw_with_canvas = !self.draw_with_canvas; | random_line_split |
relative-mouse-state.rs | extern crate sdl2;
use sdl2::event::Event;
use sdl2::mouse::MouseButton;
use std::time::Duration;
pub fn | () {
let sdl_context = sdl2::init().unwrap();
let video_subsystem = sdl_context.video().unwrap();
let _window = video_subsystem.window("Mouse", 800, 600)
.position_centered()
.build()
.unwrap();
let mut events = sdl_context.event_pump().unwrap();
let mut state;
'running: ... | main | identifier_name |
relative-mouse-state.rs | extern crate sdl2;
use sdl2::event::Event;
use sdl2::mouse::MouseButton;
use std::time::Duration;
pub fn main() {
let sdl_context = sdl2::init().unwrap();
let video_subsystem = sdl_context.video().unwrap();
let _window = video_subsystem.window("Mouse", 800, 600)
.position_centered()
.build(... | } | } | random_line_split |
relative-mouse-state.rs | extern crate sdl2;
use sdl2::event::Event;
use sdl2::mouse::MouseButton;
use std::time::Duration;
pub fn main() | // get a mouse state using mouse_state() so as not to call
// relative_mouse_state() twice and get a false position reading
if events.mouse_state().is_mouse_button_pressed(MouseButton::Left) {
state = events.relative_mouse_state();
println!("Relative - X = {:?}, Y = {:?}"... | {
let sdl_context = sdl2::init().unwrap();
let video_subsystem = sdl_context.video().unwrap();
let _window = video_subsystem.window("Mouse", 800, 600)
.position_centered()
.build()
.unwrap();
let mut events = sdl_context.event_pump().unwrap();
let mut state;
'running: ... | identifier_body |
main.rs | use std::collections::HashMap;
fn main() {
let mut scores = HashMap::new();
scores.insert(String::from("Blue"), 10);
scores.insert(String::from("Yellow"), 50);
let teams = vec![String::from("Blue"), String::from("Yellow")];
let initial_scores = vec![10, 50];
let different_scores: HashMap<_, _... |
for word in text.split_whitespace() {
let count = map.entry(word).or_insert(0)
*count += 1;
}
println!("{:?}", map);
// It's possible to use different hasher than default one
} |
let text = "hello wonderful world world";
let mut map = HashMap::new(); | random_line_split |
main.rs | use std::collections::HashMap;
fn main() |
scores.entry(String::from("Blue")).or_insert(100);
scores.entry(String::from("Red")).or_insert(200);
println!("{:?}", scores);
let text = "hello wonderful world world";
let mut map = HashMap::new();
for word in text.split_whitespace() {
let count = map.entry(word).or_insert(0)
... | {
let mut scores = HashMap::new();
scores.insert(String::from("Blue"), 10);
scores.insert(String::from("Yellow"), 50);
let teams = vec![String::from("Blue"), String::from("Yellow")];
let initial_scores = vec![10, 50];
let different_scores: HashMap<_, _> = teams.iter().zip(initial_scores.iter()... | identifier_body |
main.rs | use std::collections::HashMap;
fn | () {
let mut scores = HashMap::new();
scores.insert(String::from("Blue"), 10);
scores.insert(String::from("Yellow"), 50);
let teams = vec![String::from("Blue"), String::from("Yellow")];
let initial_scores = vec![10, 50];
let different_scores: HashMap<_, _> = teams.iter().zip(initial_scores.ite... | main | identifier_name |
host.rs | use std::convert::TryFrom;
use std::fmt;
use std::net::{IpAddr, Ipv4Addr, Ipv6Addr};
use std::str::FromStr;
use super::EndpointError;
use crate::ZmqError;
/// Represents a host address. Does not include the port, and may be either an
/// ip address or a domain name
#[derive(Debug, Clone, Hash, PartialEq, Eq)]
pub enu... | (s: String) -> Result<Self, Self::Error> {
if s.is_empty() {
return Err(EndpointError::Syntax("Host string should not be empty"));
}
if let Ok(addr) = s.parse::<Ipv4Addr>() {
return Ok(Host::Ipv4(addr));
}
// Attempt to parse ipv6 from either ::1 or [::1]... | try_from | identifier_name |
host.rs | use std::convert::TryFrom;
use std::fmt;
use std::net::{IpAddr, Ipv4Addr, Ipv6Addr};
use std::str::FromStr;
use super::EndpointError;
use crate::ZmqError;
/// Represents a host address. Does not include the port, and may be either an
/// ip address or a domain name
#[derive(Debug, Clone, Hash, PartialEq, Eq)]
pub enu... |
}
#[cfg(test)]
mod tests {
use super::*;
// These two tests on std are more for reference than any real test of
// functionality
#[test]
fn std_ipv6_parse() {
assert_eq!(Ipv6Addr::LOCALHOST, "::1".parse::<Ipv6Addr>().unwrap());
assert!("[::1]".parse::<Ipv6Addr>().is_err());
}
... | {
let s = s.to_string();
Self::try_from(s)
} | identifier_body |
host.rs | use std::convert::TryFrom;
use std::fmt;
use std::net::{IpAddr, Ipv4Addr, Ipv6Addr};
use std::str::FromStr;
use super::EndpointError;
use crate::ZmqError;
/// Represents a host address. Does not include the port, and may be either an
/// ip address or a domain name
#[derive(Debug, Clone, Hash, PartialEq, Eq)]
pub enu... | let parsed_host = parsed_host.unwrap();
if let Host::Domain(_) = parsed_host {
continue;
}
panic!(
"Expected that \"{}\" would not parse as Ipv6 or Ipv4, but instead it parsed as {:?}",
invalid, parsed_host
);
... | continue;
} | random_line_split |
cksum.rs | #![crate_name = "cksum"]
#![feature(collections, core, old_io, old_path, rustc_private)]
/*
* This file is part of the uutils coreutils package.
*
* (c) Michael Gehring <mg@ebfe.org>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/... | Ok((crc, size)) => println!("{} {}", crc, size),
Err(err) => {
show_error!("{}", err);
return 2;
}
}
return 0;
}
let mut exit_code = 0;
for fname in files.iter() {
match cksum(fname.as_slice()) {
Ok((crc... | match cksum("-") { | random_line_split |
cksum.rs | #![crate_name = "cksum"]
#![feature(collections, core, old_io, old_path, rustc_private)]
/*
* This file is part of the uutils coreutils package.
*
* (c) Michael Gehring <mg@ebfe.org>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/... | (crc: u32, input: u8) -> u32 {
(crc << 8) ^ CRC_TABLE[((crc >> 24) as usize ^ input as usize) & 0xFF]
}
#[inline]
fn crc_final(mut crc: u32, mut length: usize) -> u32 {
while length!= 0 {
crc = crc_update(crc, length as u8);
length >>= 8;
}
!crc
}
#[inline]
fn cksum(fname: &str) -> IoR... | crc_update | identifier_name |
cksum.rs | #![crate_name = "cksum"]
#![feature(collections, core, old_io, old_path, rustc_private)]
/*
* This file is part of the uutils coreutils package.
*
* (c) Michael Gehring <mg@ebfe.org>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/... | Ok(num_bytes) => {
for &b in bytes[..num_bytes].iter() {
crc = crc_update(crc, b);
}
size += num_bytes;
}
Err(IoError { kind: EndOfFile,.. }) => return Ok((crc_final(crc, size), size)),
Err(err) => return... | {
let mut crc = 0u32;
let mut size = 0usize;
let mut stdin_buf;
let mut file_buf;
let rd = match fname {
"-" => {
stdin_buf = stdin_raw();
&mut stdin_buf as &mut Reader
}
_ => {
file_buf = try!(File::open(&Path::new(fname)));
&... | identifier_body |
early-vtbl-resolution.rs | // 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 http://opensource.org/licenses/MIT>, at your
// option. This file... | // Copyright 2012 The Rust Project Developers. See the COPYRIGHT | random_line_split | |
early-vtbl-resolution.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 ... | {
let _x: Option<f64> = foo_func(0);
} | identifier_body | |
early-vtbl-resolution.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 ... | { a: int }
pub fn main() {
let _x: Option<f64> = foo_func(0);
}
| A | identifier_name |
lib.rs | // Copyright (c) 2013-2015 Sandstorm Development Group, Inc. and contributors
// Licensed under the MIT License:
//
// 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, inc... | impl ::std::fmt::Display for NotInSchema {
fn fmt(&self, fmt : &mut ::std::fmt::Formatter) -> ::std::result::Result<(), ::std::fmt::Error> {
write!(fmt, "Enum value or union discriminant {} was not present in the schema.", self.0)
}
}
impl ::std::error::Error for NotInSchema {
fn description(&self)... | random_line_split | |
lib.rs | // Copyright (c) 2013-2015 Sandstorm Development Group, Inc. and contributors
// Licensed under the MIT License:
//
// 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, inc... | (&self, fmt : &mut ::std::fmt::Formatter) -> ::std::result::Result<(), ::std::fmt::Error> {
write!(fmt, "Enum value or union discriminant {} was not present in the schema.", self.0)
}
}
impl ::std::error::Error for NotInSchema {
fn description(&self) -> &str {
"Enum value or union disriminant w... | fmt | identifier_name |
lib.rs | // Copyright (c) 2013-2015 Sandstorm Development Group, Inc. and contributors
// Licensed under the MIT License:
//
// 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, inc... | ,
Error::Decode { ref description,.. } => write!(fmt, "{}", description),
Error::Io(ref io) => io.fmt(fmt),
}
}
}
impl ::std::error::Error for Error {
fn description(&self) -> &str {
match *self {
Error::Decode { ref description,.. } => description,
... | {
write!(fmt, "{} {}", description, detail)
} | conditional_block |
lib.rs | // Copyright (c) 2013-2015 Sandstorm Development Group, Inc. and contributors
// Licensed under the MIT License:
//
// 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, inc... |
pub fn bytes_to_words<'a>(bytes: &'a [u8]) -> &'a [Word] {
unsafe {
::std::slice::from_raw_parts(bytes.as_ptr() as *const Word, bytes.len() / 8)
}
}
pub fn words_to_bytes<'a>(words: &'a [Word]) -> &'a [u8] {
unsafe {
::std::slice::from_raw_parts(words.as_pt... | {
let mut result : Vec<Word> = Vec::with_capacity(length);
unsafe {
result.set_len(length);
let p : *mut u8 = result.as_mut_ptr() as *mut u8;
::std::ptr::write_bytes(p, 0u8, length * ::std::mem::size_of::<Word>());
}
return result;
} | identifier_body |
issue-30079.rs | struct SemiPriv;
mod m1 {
struct Priv;
impl ::SemiPriv {
pub fn f(_: Priv) {} //~ WARN private type `m1::Priv` in public interface
//~^ WARNING hard error
}
impl Priv {
pub fn f(_: Priv) {} // ok
}
}
mod m2 {
struct Priv;
impl ::std::ops::Deref for ::SemiPriv {
... | {} | identifier_body | |
issue-30079.rs | struct | ;
mod m1 {
struct Priv;
impl ::SemiPriv {
pub fn f(_: Priv) {} //~ WARN private type `m1::Priv` in public interface
//~^ WARNING hard error
}
impl Priv {
pub fn f(_: Priv) {} // ok
}
}
mod m2 {
struct Priv;
impl ::std::ops::Deref for ::SemiPriv {
type Targe... | SemiPriv | identifier_name |
issue-30079.rs | struct SemiPriv;
mod m1 {
struct Priv;
impl ::SemiPriv {
pub fn f(_: Priv) {} //~ WARN private type `m1::Priv` in public interface
//~^ WARNING hard error
}
impl Priv {
pub fn f(_: Priv) {} // ok
}
}
mod m2 {
struct Priv;
impl ::std::ops::Deref for ::SemiPriv {
... | impl ::std::ops::Deref for Priv {
type Target = Priv; // ok
fn deref(&self) -> &Self::Target { unimplemented!() }
}
}
trait SemiPrivTrait {
type Assoc;
}
mod m3 {
struct Priv;
impl ::SemiPrivTrait for () {
type Assoc = Priv; //~ ERROR private type `m3::Priv` in public inter... | random_line_split | |
atomic_load.rs | #![feature(core, core_intrinsics)]
extern crate core;
#[cfg(test)]
mod tests {
use core::intrinsics::atomic_load;
use core::cell::UnsafeCell;
use std::sync::Arc;
use std::thread;
// pub fn atomic_load<T>(src: *const T) -> T;
struct A<T> {
v: UnsafeCell<T>
}
unsafe impl Sync for A... | () {
atomic_load_test!( 68 );
}
}
| atomic_load_test1 | identifier_name |
atomic_load.rs | #![feature(core, core_intrinsics)]
extern crate core;
#[cfg(test)]
mod tests {
use core::intrinsics::atomic_load;
use core::cell::UnsafeCell;
use std::sync::Arc;
use std::thread;
// pub fn atomic_load<T>(src: *const T) -> T;
struct A<T> {
v: UnsafeCell<T>
}
unsafe impl Sync for A... |
}
type T = usize;
macro_rules! atomic_load_test {
($value:expr) => ({
let value: T = $value;
let a: A<T> = A::<T>::new(value);
let data: Arc<A<T>> = Arc::<A<T>>::new(a);
let clone: Arc<A<T>> = data.clone();
thread::spawn(move || {
let src: *mut T = clone.v.get();
let resul... | {
A { v: UnsafeCell::<T>::new(v) }
} | identifier_body |
atomic_load.rs | #![feature(core, core_intrinsics)]
extern crate core;
#[cfg(test)]
mod tests {
use core::intrinsics::atomic_load;
use core::cell::UnsafeCell;
use std::sync::Arc;
use std::thread;
// pub fn atomic_load<T>(src: *const T) -> T;
struct A<T> {
v: UnsafeCell<T>
}
| fn new(v: T) -> A<T> {
A { v: UnsafeCell::<T>::new(v) }
}
}
type T = usize;
macro_rules! atomic_load_test {
($value:expr) => ({
let value: T = $value;
let a: A<T> = A::<T>::new(value);
let data: Arc<A<T>> = Arc::<A<T>>::new(a);
let clone: Arc<A<T>> = data.clone();
thread... | unsafe impl Sync for A<T> {}
impl<T> A<T> { | random_line_split |
utils.rs | // Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
use std::io;
use super::{RemoveRegionError, MAX_PAGE_COMPACT_BUFFER};
use logger::error;
use vm_memory::{GuestAddress, GuestMemory, GuestMemoryMmap, GuestMemoryRegion};
/// This takes a vector of page fr... | result.push((v[previous], length));
result
}
pub(crate) fn remove_range(
guest_memory: &GuestMemoryMmap,
range: (GuestAddress, u64),
restored: bool,
) -> std::result::Result<(), RemoveRegionError> {
let (guest_address, range_len) = range;
if let Some(region) = guest_memory.find_region(gue... | // Don't forget to push the last range to the result. | random_line_split |
utils.rs | // Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
use std::io;
use super::{RemoveRegionError, MAX_PAGE_COMPACT_BUFFER};
use logger::error;
use vm_memory::{GuestAddress, GuestMemory, GuestMemoryMmap, GuestMemoryRegion};
/// This takes a vector of page fr... | ;
// Madvise the region in order to mark it as not used.
let ret = unsafe {
libc::madvise(
phys_address as *mut _,
range_len as usize,
libc::MADV_DONTNEED,
)
};
if ret < 0 {
return Err(RemoveRegionError:... | {
let ret = unsafe {
libc::mmap(
phys_address as *mut _,
range_len as usize,
libc::PROT_READ | libc::PROT_WRITE,
libc::MAP_FIXED | libc::MAP_ANONYMOUS | libc::MAP_PRIVATE,
-1,
... | conditional_block |
utils.rs | // Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
use std::io;
use super::{RemoveRegionError, MAX_PAGE_COMPACT_BUFFER};
use logger::error;
use vm_memory::{GuestAddress, GuestMemory, GuestMemoryMmap, GuestMemoryRegion};
/// This takes a vector of page fr... | () {
let page_size: usize = 0x1000;
let mem = vm_memory::test_utils::create_anon_guest_memory(
&[(GuestAddress(0), 2 * page_size)],
false,
)
.unwrap();
// Fill the memory with ones.
let ones = vec![1u8; 2 * page_size];
mem.write(&ones[..], ... | test_remove_range_on_restored | identifier_name |
utils.rs | // Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
use std::io;
use super::{RemoveRegionError, MAX_PAGE_COMPACT_BUFFER};
use logger::error;
use vm_memory::{GuestAddress, GuestMemory, GuestMemoryMmap, GuestMemoryRegion};
/// This takes a vector of page fr... |
fn random_pfn_100() -> impl Strategy<Value = Vec<u32>> {
// Create a randomly sized vec (max MAX_PAGE_COMPACT_BUFFER/8) filled with random u32 elements (0 - 100).
prop::collection::vec(0..100u32, 0..MAX_PAGE_COMPACT_BUFFER / 8)
}
// The uncompactor will output deduplicated and sorted elem... | {
// Create a randomly sized vec (max MAX_PAGE_COMPACT_BUFFER elements) filled with random u32 elements.
prop::collection::vec(0..std::u32::MAX, 0..MAX_PAGE_COMPACT_BUFFER)
} | identifier_body |
stability.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 ... | (&mut self, var: &Variant, g: &'v Generics) {
self.annotate(var.node.id, &var.node.attrs, |v| visit::walk_variant(v, var, g))
}
fn visit_struct_field(&mut self, s: &StructField) {
self.annotate(s.node.id, &s.node.attrs, |v| visit::walk_struct_field(v, s));
}
}
impl Index {
/// Construc... | visit_variant | identifier_name |
stability.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 lookup(tcx: &ty::ctxt, id: DefId) -> Option<Stability> {
// is this definition the implementation of a trait method?
match ty::trait_item_of_item(tcx, id) {
Some(ty::MethodTraitItemId(trait_method_id))
if trait_method_id!= id => {
lookup(tcx, trait_method_id)
}... | /// metadata as necessary. | random_line_split |
stability.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 stab = csearch::get_stability(&tcx.sess.cstore, id);
let mut index = tcx.stability.borrow_mut();
(*index).extern_cache.insert(id, stab.clone());
stab
} | conditional_block |
stability.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 ... |
}
impl Index {
/// Construct the stability index for a crate being compiled.
pub fn build(krate: &Crate) -> Index {
let mut annotator = Annotator {
index: Index {
local: NodeMap::new(),
extern_cache: DefIdMap::new()
},
parent: None
... | {
self.annotate(s.node.id, &s.node.attrs, |v| visit::walk_struct_field(v, s));
} | identifier_body |
build.rs | #[macro_use]
extern crate quick_error;
extern crate chrono;
use std::env;
use chrono::*;
use std::convert::AsRef;
use std::fs::{File, create_dir_all};
use std::io::{Write, Read, BufWriter};
use std::path::{Path};
use std::process::{Command, Output};
use std::collections::HashMap;
quick_error! {
#[derive(Debug)]
... | }
}
fn fetch_env(key: &str, result_required: bool, empty_is_missing: bool) -> Option<String>{
if result_required {
match env::var(key) {
Ok(ref v) if v.len() == 0 && empty_is_missing => {
panic!("Required env var {} is present - but empty - in the build environment", key);
... | {
let mut args: Vec<&str> = cmd.split(" ").collect::<Vec<&str>>();
if args.len() < 1 {
panic!("");
}
let exe = args.remove(0);
let output: Output = Command::new(exe)
.args(&args)
.output()?;
if !output.status.success() {
return Err(Error::CommandFailed(output));
... | identifier_body |
build.rs | #[macro_use]
extern crate quick_error;
extern crate chrono;
use std::env;
use chrono::*;
use std::convert::AsRef;
use std::fs::{File, create_dir_all};
use std::io::{Write, Read, BufWriter};
use std::path::{Path};
use std::process::{Command, Output};
use std::collections::HashMap;
quick_error! {
#[derive(Debug)]
... | info
}
fn what_to_collect() -> Vec<EnvTidbit>{
let mut c = Vec::new();
c.push(EnvTidbit::CmdOrEnvReq {key: "GIT_COMMIT", cmd: "git rev-parse HEAD"});
c.push(EnvTidbit::CmdOrEnv{key: "GIT_COMMIT_SHORT", cmd: "git rev-parse --short HEAD"});
c.push(EnvTidbit::CmdOrEnv{key: "GIT_DESCRIBE_ALWAYS", cmd: "... | EnvTidbit::CmdOrEnv{key, cmd} => (key, command(key, cmd, false, true)),
EnvTidbit::EnvOrCmdInconsistent{key, cmd} => (key, env_or_cmd(key, cmd)),
};
info.insert(k.to_owned(),v);
} | random_line_split |
build.rs | #[macro_use]
extern crate quick_error;
extern crate chrono;
use std::env;
use chrono::*;
use std::convert::AsRef;
use std::fs::{File, create_dir_all};
use std::io::{Write, Read, BufWriter};
use std::path::{Path};
use std::process::{Command, Output};
use std::collections::HashMap;
quick_error! {
#[derive(Debug)]
... | () {
let todo = what_to_collect();
let utcnow_val =Utc::now();
let mut results = collect_info(todo);
results.insert("GENERATED_DATETIME_UTC".to_owned(), Some(utcnow_val.to_rfc3339()));
results.insert("GENERATED_DATE_UTC".to_owned(), Some(utcnow_val.format("%Y-%m-%d").to_string()));
let mut con... | main | identifier_name |
build.rs | #[macro_use]
extern crate quick_error;
extern crate chrono;
use std::env;
use chrono::*;
use std::convert::AsRef;
use std::fs::{File, create_dir_all};
use std::io::{Write, Read, BufWriter};
use std::path::{Path};
use std::process::{Command, Output};
use std::collections::HashMap;
quick_error! {
#[derive(Debug)]
... |
}
}else{
env::var(key).ok().and_then(|v| if v.len() == 0 && empty_is_missing { None } else { Some(v) })
}
}
fn command(key: &str, cmd: &str, result_required: bool, fallback_to_env: bool) -> Option<String>{
//Panic only if non-UTF-8 output is sent
let output = run(cmd);
//Don't pani... | { panic!("Required env var {} missing in the build environment: {:?}", key, e); } | conditional_block |
020.rs | extern crate num;
extern crate test;
extern crate time;
use num::bigint::{BigUint,ToBigUint};
use std::iter::{AdditiveIterator,MultiplicativeIterator,range_inclusive};
use std::num::One;
use std::os::args;
use test::black_box;
use time::precise_time_ns;
fn factorial(n: uint) -> BigUint {
range_inclusive(One::one(... |
fn main() {
match args().as_slice() {
[_] => {
println!("{}", f());
},
[_, ref iters] => {
let iters: u64 = from_str(iters.as_slice()).unwrap();
let start = precise_time_ns();
for _ in range(0, iters) {
black_box(f());
... | {
factorial(100).to_str().as_slice()
.chars()
.filter_map(|c| c.to_digit(10))
.sum()
} | identifier_body |
020.rs | extern crate num;
extern crate test;
extern crate time;
use num::bigint::{BigUint,ToBigUint};
use std::iter::{AdditiveIterator,MultiplicativeIterator,range_inclusive};
use std::num::One;
use std::os::args;
use test::black_box;
use time::precise_time_ns;
fn factorial(n: uint) -> BigUint {
range_inclusive(One::one(... |
let start = precise_time_ns();
for _ in range(0, iters) {
black_box(f());
}
let end = precise_time_ns();
println!("{}", end - start);
},
_ => unreachable!(),
}
} | },
[_, ref iters] => {
let iters: u64 = from_str(iters.as_slice()).unwrap(); | random_line_split |
020.rs | extern crate num;
extern crate test;
extern crate time;
use num::bigint::{BigUint,ToBigUint};
use std::iter::{AdditiveIterator,MultiplicativeIterator,range_inclusive};
use std::num::One;
use std::os::args;
use test::black_box;
use time::precise_time_ns;
fn | (n: uint) -> BigUint {
range_inclusive(One::one(), n.to_biguint().unwrap()).product()
}
#[inline]
fn f() -> uint {
factorial(100).to_str().as_slice()
.chars()
.filter_map(|c| c.to_digit(10))
.sum()
}
fn main() {
match args().as_slice() {
[_] => {
... | factorial | identifier_name |
activation_manager.rs | use crate::joint::{JointConstraint, JointConstraintSet};
use crate::object::{Body, BodyHandle, BodySet, ColliderSet};
use crate::utils::union_find;
use crate::utils::union_find::UnionFindSet;
use crate::world::GeometricalWorld;
use na::{self, RealField};
/// Structure that monitors island-based activation/deactivation... |
for (_, c1, _, c2, _, manifold) in gworld.contact_pairs(colliders, false) {
if manifold.len() > 0 {
make_union(bodies, c1.body(), c2.body(), &mut self.ufind)
}
}
constraints.foreach(|_, c| {
if!c.is_broken() {
let (b1, b2) = ... | {
let b1 = try_ret!(bodies.get(b1));
let b2 = try_ret!(bodies.get(b2));
if (b1.status_dependent_ndofs() != 0 || b1.is_kinematic())
&& (b2.status_dependent_ndofs() != 0 || b2.is_kinematic())
{
union_find::union(b1.companion_id(), b2.companio... | identifier_body |
activation_manager.rs | use crate::joint::{JointConstraint, JointConstraintSet};
use crate::object::{Body, BodyHandle, BodySet, ColliderSet};
use crate::utils::union_find;
use crate::utils::union_find::UnionFindSet;
use crate::world::GeometricalWorld;
use na::{self, RealField};
/// Structure that monitors island-based activation/deactivation... | <N: RealField, Handle: BodyHandle> {
mix_factor: N,
ufind: Vec<UnionFindSet>,
can_deactivate: Vec<bool>,
to_activate: Vec<Handle>,
id_to_body: Vec<Handle>,
}
impl<N: RealField, Handle: BodyHandle> ActivationManager<N, Handle> {
/// Creates a new `ActivationManager2`.
///
/// # Arguments... | ActivationManager | identifier_name |
activation_manager.rs | use crate::joint::{JointConstraint, JointConstraintSet};
use crate::object::{Body, BodyHandle, BodySet, ColliderSet};
use crate::utils::union_find;
use crate::utils::union_find::UnionFindSet;
use crate::world::GeometricalWorld;
use na::{self, RealField};
/// Structure that monitors island-based activation/deactivation... | self.can_deactivate[root] = match status.deactivation_threshold() {
Some(threshold) => self.can_deactivate[root] && status.energy() < threshold,
None => false,
};
}
// Activate/deactivate islands.
for i in 0usize..self.ufind.len() {
... | // FIXME: avoid the Copy when NLL lands ?
let status = *body.activation_status();
| random_line_split |
activation_manager.rs | use crate::joint::{JointConstraint, JointConstraintSet};
use crate::object::{Body, BodyHandle, BodySet, ColliderSet};
use crate::utils::union_find;
use crate::utils::union_find::UnionFindSet;
use crate::world::GeometricalWorld;
use na::{self, RealField};
/// Structure that monitors island-based activation/deactivation... | else if!body.is_kinematic() {
// Everybody in this set must be reactivated.
active_bodies.push(handle);
// FIXME: avoid the Copy when NLL lands?
let status = *body.activation_status();
if!status.is_active() && status.deactivation_thresho... | {
// Everybody in this set can be deactivacted.
if body.is_active() {
body.deactivate();
}
} | conditional_block |
issue-2804.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-M... | (table: json::Object, key: String, default: String) -> String
{
match table.find(&key.to_string()) {
option::Option::Some(&Json::String(ref s)) => {
s.to_string()
}
option::Option::Some(value) => {
println!("{} was expected to be a string but is a {}", key, value);
... | lookup | identifier_name |
issue-2804.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-M... | {} | identifier_body | |
issue-2804.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-M... |
}
}
fn add_interfaces(store: int, managed_ip: String, device: HashMap<String, json::Json>)
-> Vec<(String, object)> {
match device["interfaces".to_string()]
{
Json::Array(ref interfaces) =>
{
interfaces.iter().map(|interface| {
add_interface(store, managed_ip.clon... | {
println!("Expected dict for {} interfaces, found {}", managed_ip, data);
("gnos:missing-interface".to_string(), object::bool_value(true))
} | conditional_block |
issue-2804.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... | }
fn lookup(table: json::Object, key: String, default: String) -> String
{
match table.find(&key.to_string()) {
option::Option::Some(&Json::String(ref s)) => {
s.to_string()
}
option::Option::Some(value) => {
println!("{} was expected to be a string but is a {}", key... | use std::option;
enum object {
bool_value(bool),
int_value(i64), | random_line_split |
sdiv.rs | use num::Num;
#[inline]
pub fn sdiv<'a, 'b, T: Copy + Num>(out: &'a mut [T; 9], a: &'b [T; 9], s: T) -> &'a mut [T; 9] {
let not_zero = s!= T::zero();
out[0] = if not_zero {a[0] / s} else {T::zero()};
out[1] = if not_zero {a[1] / s} else | ;
out[2] = if not_zero {a[2] / s} else {T::zero()};
out[3] = if not_zero {a[3] / s} else {T::zero()};
out[4] = if not_zero {a[4] / s} else {T::zero()};
out[5] = if not_zero {a[5] / s} else {T::zero()};
out[6] = if not_zero {a[6] / s} else {T::zero()};
out[7] = if not_zero {a[7] / s} else {... | {T::zero()} | conditional_block |
sdiv.rs | use num::Num;
#[inline] | out[1] = if not_zero {a[1] / s} else {T::zero()};
out[2] = if not_zero {a[2] / s} else {T::zero()};
out[3] = if not_zero {a[3] / s} else {T::zero()};
out[4] = if not_zero {a[4] / s} else {T::zero()};
out[5] = if not_zero {a[5] / s} else {T::zero()};
out[6] = if not_zero {a[6] / s} else {T:... | pub fn sdiv<'a, 'b, T: Copy + Num>(out: &'a mut [T; 9], a: &'b [T; 9], s: T) -> &'a mut [T; 9] {
let not_zero = s != T::zero();
out[0] = if not_zero {a[0] / s} else {T::zero()}; | random_line_split |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.