#[stable(feature = "rust1", since = "1.0.0")]
pub fn from_utf8(vec: Vec<u8>) -> Result<String, FromUtf8Error> {
match str::from_utf8(&vec) {
- Ok(..) => Ok(String { vec: vec }),
+ Ok(..) => Ok(String { vec }),
Err(e) => {
Err(FromUtf8Error {
bytes: vec,
impl DwarfReader {
pub fn new(ptr: *const u8) -> DwarfReader {
- DwarfReader { ptr: ptr }
+ DwarfReader { ptr }
}
// DWARF streams are packed, so e.g. a u32 would not necessarily be aligned
}
pub unsafe fn panic(data: Box<dyn Any + Send>) -> u32 {
- let panic_ctx = Box::new(PanicData { data: data });
+ let panic_ctx = Box::new(PanicData { data });
let params = [Box::into_raw(panic_ctx) as c::ULONG_PTR];
c::RaiseException(RUST_PANIC,
c::EXCEPTION_NONCONTINUABLE,
impl<'a, 'gcx, 'tcx> OpportunisticTypeResolver<'a, 'gcx, 'tcx> {
pub fn new(infcx: &'a InferCtxt<'a, 'gcx, 'tcx>) -> Self {
- OpportunisticTypeResolver { infcx: infcx }
+ OpportunisticTypeResolver { infcx }
}
}
impl<'a, 'gcx, 'tcx> OpportunisticTypeAndRegionResolver<'a, 'gcx, 'tcx> {
pub fn new(infcx: &'a InferCtxt<'a, 'gcx, 'tcx>) -> Self {
- OpportunisticTypeAndRegionResolver { infcx: infcx }
+ OpportunisticTypeAndRegionResolver { infcx }
}
}
// Hack: we only need this so that `types_escaping_snapshot`
// can see what has been unified; see the Delegate impl for
// more details.
- self.values.record(Instantiate { vid: vid });
+ self.values.record(Instantiate { vid });
}
/// Creates a new type variable.
value2.min_vid
};
- Ok(RegionVidKey { min_vid: min_vid })
+ Ok(RegionVidKey { min_vid })
}
}
/// Cross-references the feature names of unstable APIs with enabled
/// features and possibly prints errors.
pub fn check_unstable_api_usage<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
- let mut checker = Checker { tcx: tcx };
+ let mut checker = Checker { tcx };
tcx.hir.krate().visit_all_item_likes(&mut checker.as_deep_visitor());
}
use mir::TerminatorKind::*;
let kind = match self.kind {
- Goto { target } => Goto { target: target },
+ Goto { target } => Goto { target },
SwitchInt {
ref discr,
switch_ty,
impl<'a, 'gcx, 'tcx> PlaceTy<'tcx> {
pub fn from_ty(ty: Ty<'tcx>) -> PlaceTy<'tcx> {
- PlaceTy::Ty { ty: ty }
+ PlaceTy::Ty { ty }
}
pub fn to_ty(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>) -> Ty<'tcx> {
},
Err(err) => {
debug!("project_and_unify_type: equating types encountered error {:?}", err);
- Err(MismatchedProjectionTypes { err: err })
+ Err(MismatchedProjectionTypes { err })
}
}
}
_ => bug!(),
};
- Ok(VtableBuiltinData { nested: nested })
+ Ok(VtableBuiltinData { nested })
}
///////////////////////////////////////////////////////////////////////////
impl<'a, 'gcx, 'tcx> Match<'a, 'gcx, 'tcx> {
pub fn new(tcx: TyCtxt<'a, 'gcx, 'tcx>) -> Match<'a, 'gcx, 'tcx> {
- Match { tcx: tcx }
+ Match { tcx }
}
}
}
fn has_type_flags(&self, flags: TypeFlags) -> bool {
- self.visit_with(&mut HasTypeFlagsVisitor { flags: flags })
+ self.visit_with(&mut HasTypeFlagsVisitor { flags })
}
fn has_projections(&self) -> bool {
self.has_type_flags(TypeFlags::HAS_PROJECTION)
pub fn new(llmb: &'static mut MemoryBuffer) -> Option<ObjectFile> {
unsafe {
let llof = LLVMCreateObjectFile(llmb)?;
- Some(ObjectFile { llof: llof })
+ Some(ObjectFile { llof })
}
}
}
funclet, succ, kind);
match kind {
CleanupKind::NotCleanup => {
- result[succ] = CleanupKind::Internal { funclet: funclet };
+ result[succ] = CleanupKind::Internal { funclet };
}
CleanupKind::Funclet => {
if funclet != succ {
}
tcx.dep_graph.with_ignore(|| {
- let mut visitor = SymbolNamesTest { tcx: tcx };
+ let mut visitor = SymbolNamesTest { tcx };
tcx.hir.krate().visit_all_item_likes(&mut visitor);
})
}
unsafe { libc::close(fd); }
Err(err)
} else {
- Ok(Lock { fd: fd })
+ Ok(Lock { fd })
}
}
}
/// compute the SVH from some HIR, you want the `calculate_svh`
/// function found in `librustc_incremental`.
pub fn new(hash: u64) -> Svh {
- Svh { hash: hash }
+ Svh { hash }
}
pub fn as_u64(&self) -> u64 {
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ImproperCTypes {
fn check_foreign_item(&mut self, cx: &LateContext, it: &hir::ForeignItem) {
- let mut vis = ImproperCTypesVisitor { cx: cx };
+ let mut vis = ImproperCTypesVisitor { cx };
let abi = cx.tcx.hir.get_foreign_abi(it.id);
if abi != Abi::RustIntrinsic && abi != Abi::PlatformIntrinsic {
match it.node {
index.record(DefId::local(CRATE_DEF_INDEX),
IsolatedEncoder::encode_info_for_mod,
FromId(CRATE_NODE_ID, (&krate.module, &krate.attrs, &vis)));
- let mut visitor = EncodeVisitor { index: index };
+ let mut visitor = EncodeVisitor { index };
krate.visit_all_item_likes(&mut visitor.as_deep_visitor());
for macro_def in &krate.exported_macros {
visitor.visit_macro_def(macro_def);
}
let scope = &self.scopes[len - scope_count];
self.cfg.terminate(block, scope.source_info(span),
- TerminatorKind::Goto { target: target });
+ TerminatorKind::Goto { target });
}
/// Creates a path that performs all required cleanup for dropping a generator.
} else {
let block = cfg.start_new_cleanup_block();
cfg.push_end_region(tcx, block, source_info(span), scope.region_scope);
- cfg.terminate(block, source_info(span), TerminatorKind::Goto { target: target });
+ cfg.terminate(block, source_info(span), TerminatorKind::Goto { target });
*cached_block = Some(block);
block
}
impl<'a, 'tcx: 'a> HaveBeenBorrowedLocals<'a, 'tcx> {
pub fn new(mir: &'a Mir<'tcx>)
-> Self {
- HaveBeenBorrowedLocals { mir: mir }
+ HaveBeenBorrowedLocals { mir }
}
pub fn mir(&self) -> &Mir<'tcx> {
impl<'a, 'tcx: 'a> MaybeStorageLive<'a, 'tcx> {
pub fn new(mir: &'a Mir<'tcx>)
-> Self {
- MaybeStorageLive { mir: mir }
+ MaybeStorageLive { mir }
}
pub fn mir(&self) -> &Mir<'tcx> {
}
pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
- tcx.hir.krate().visit_all_item_likes(&mut OuterVisitor { tcx: tcx }.as_deep_visitor());
+ tcx.hir.krate().visit_all_item_likes(&mut OuterVisitor { tcx }.as_deep_visitor());
tcx.sess.abort_if_errors();
}
})
.collect();
- PatternKind::Leaf { subpatterns: subpatterns }
+ PatternKind::Leaf { subpatterns }
}
ty::Error => { // Avoid ICE (#50577)
return Pattern { span: pat.span, ty, kind: Box::new(PatternKind::Wild) };
subpatterns,
}
} else {
- PatternKind::Leaf { subpatterns: subpatterns }
+ PatternKind::Leaf { subpatterns }
}
}
Def::Struct(..) | Def::StructCtor(..) | Def::Union(..) |
Def::TyAlias(..) | Def::AssociatedTy(..) | Def::SelfTy(..) | Def::SelfCtor(..) => {
- PatternKind::Leaf { subpatterns: subpatterns }
+ PatternKind::Leaf { subpatterns }
}
_ => {
let target = self.patch.new_block(BasicBlockData {
statements: vec![assign],
terminator: Some(Terminator {
- kind: TerminatorKind::Goto { target: target },
+ kind: TerminatorKind::Goto { target },
..*terminator
}),
is_cleanup: false,
let map = make_local_map(&mut mir.local_decls, marker.locals);
// Update references to all vars and tmps now
- LocalUpdater { map: map }.visit_mir(mir);
+ LocalUpdater { map }.visit_mir(mir);
mir.local_decls.shrink_to_fit();
}
}
TerminatorKind::Assert {
target, cond: Operand::Constant(ref c), expected, ..
} if (c.literal.assert_bool(tcx) == Some(true)) == expected => {
- TerminatorKind::Goto { target: target }
+ TerminatorKind::Goto { target }
},
TerminatorKind::FalseEdges { real_target, .. } => {
TerminatorKind::Goto { target: real_target }
is_banned: false,
}, krate);
- visit::walk_crate(&mut AstValidator { session: session }, krate)
+ visit::walk_crate(&mut AstValidator { session }, krate)
}
// declared as public (due to pruning, we don't explore
// outside crate private modules => no need to check this)
if !in_module_is_extern || name_binding.vis == ty::Visibility::Public {
- candidates.push(ImportSuggestion { path: path });
+ candidates.push(ImportSuggestion { path });
}
}
}
span: name_binding.span,
segments: path_segments,
};
- result = Some((module, ImportSuggestion { path: path }));
+ result = Some((module, ImportSuggestion { path }));
} else {
// add the module to the lookup
if seen_modules.insert(module.def_id().unwrap()) {
config: Config,
) -> JsonDumper<CallbackOutput<'b>> {
JsonDumper {
- output: CallbackOutput { callback: callback },
+ output: CallbackOutput { callback },
config: config.clone(),
result: Analysis::new(config),
}
AdtField { ty: field_ty, span: field.span }
})
.collect();
- AdtVariant { fields: fields }
+ AdtVariant { fields }
}
fn enum_variants(&self, enum_def: &hir::EnumDef) -> Vec<AdtVariant<'tcx>> {
use rustc::hir;
pub fn check<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
- let mut orphan = OrphanChecker { tcx: tcx };
+ let mut orphan = OrphanChecker { tcx };
tcx.hir.krate().visit_all_item_likes(&mut orphan);
}
use rustc::hir::{self, Unsafety};
pub fn check<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
- let mut unsafety = UnsafetyChecker { tcx: tcx };
+ let mut unsafety = UnsafetyChecker { tcx };
tcx.hir.krate().visit_all_item_likes(&mut unsafety);
}
// Main entry point
pub fn collect_item_types<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
- let mut visitor = CollectItemTypesVisitor { tcx: tcx };
+ let mut visitor = CollectItemTypesVisitor { tcx };
tcx.hir
.krate()
.visit_all_item_likes(&mut visitor.as_deep_visitor());
// We will tag this as part of the WF check -- logically, it is,
// but it's one that we must perform earlier than the rest of
// WfCheck.
- tcx.hir.krate().visit_all_item_likes(&mut ImplWfCheck { tcx: tcx });
+ tcx.hir.krate().visit_all_item_likes(&mut ImplWfCheck { tcx });
}
struct ImplWfCheck<'a, 'tcx: 'a> {
source: cx.tcx.def_span(self.did).clean(cx),
visibility: Some(Inherited),
def_id: self.did,
- inner: VariantItem(Variant { kind: kind }),
+ inner: VariantItem(Variant { kind }),
stability: get_stability(cx, self.did),
deprecation: get_deprecation(cx, self.did),
}
slot.borrow_mut()[k] += 1;
});
- Droppable { k: k }
+ Droppable { k }
}
}
fn _open(&self, path: &Path) -> io::Result<File> {
let inner = fs_imp::File::open(path, &self.0)?;
- Ok(File { inner: inner })
+ Ok(File { inner })
}
}
/// assert_eq!(buffer, [0b101, 0b101, 0b101]);
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
-pub fn repeat(byte: u8) -> Repeat { Repeat { byte: byte } }
+pub fn repeat(byte: u8) -> Repeat { Repeat { byte } }
#[stable(feature = "rust1", since = "1.0.0")]
impl Read for Repeat {
impl<T> SyncSender<T> {
fn new(inner: Arc<sync::Packet<T>>) -> SyncSender<T> {
- SyncSender { inner: inner }
+ SyncSender { inner }
}
/// Sends a value on this synchronous channel.
let mut t = mem::uninitialized();
let ret = abi::clock_time_get(abi::clockid::MONOTONIC, 0, &mut t);
assert_eq!(ret, abi::errno::SUCCESS);
- Instant { t: t }
+ Instant { t }
}
}
let mut t = mem::uninitialized();
let ret = abi::clock_time_get(abi::clockid::REALTIME, 0, &mut t);
assert_eq!(ret, abi::errno::SUCCESS);
- SystemTime { t: t }
+ SystemTime { t }
}
}
impl FileDesc {
pub fn new(fd: usize) -> FileDesc {
- FileDesc { fd: fd }
+ FileDesc { fd }
}
pub fn raw(&self) -> usize { self.fd }
pub fn file_attr(&self) -> io::Result<FileAttr> {
let mut stat = syscall::Stat::default();
cvt(syscall::fstat(self.0.raw(), &mut stat))?;
- Ok(FileAttr { stat: stat })
+ Ok(FileAttr { stat })
}
pub fn fsync(&self) -> io::Result<()> {
impl Error {
pub fn new(errno: i32) -> Error {
- Error { errno: errno }
+ Error { errno }
}
pub fn mux(result: Result<usize>) -> usize {
panic!("thread failed to exit");
} else {
mem::forget(p);
- Ok(Thread { id: id })
+ Ok(Thread { id })
}
}
impl From<syscall::TimeSpec> for SystemTime {
fn from(t: syscall::TimeSpec) -> SystemTime {
- SystemTime { t: Timespec { t: t } }
+ SystemTime { t: Timespec { t } }
}
}
impl FileDesc {
pub fn new(fd: c_int) -> FileDesc {
- FileDesc { fd: fd }
+ FileDesc { fd }
}
pub fn raw(&self) -> c_int { self.fd }
cvt(unsafe {
fstatat64(fd, self.entry.d_name.as_ptr(), &mut stat, libc::AT_SYMLINK_NOFOLLOW)
})?;
- Ok(FileAttr { stat: stat })
+ Ok(FileAttr { stat })
}
#[cfg(not(any(target_os = "linux", target_os = "emscripten", target_os = "android")))]
cvt(unsafe {
fstat64(self.0.raw(), &mut stat)
})?;
- Ok(FileAttr { stat: stat })
+ Ok(FileAttr { stat })
}
pub fn fsync(&self) -> io::Result<()> {
cvt(unsafe {
stat64(p.as_ptr(), &mut stat)
})?;
- Ok(FileAttr { stat: stat })
+ Ok(FileAttr { stat })
}
pub fn lstat(p: &Path) -> io::Result<FileAttr> {
cvt(unsafe {
lstat64(p.as_ptr(), &mut stat)
})?;
- Ok(FileAttr { stat: stat })
+ Ok(FileAttr { stat })
}
pub fn canonicalize(p: &Path) -> io::Result<PathBuf> {
impl From<libc::timespec> for SystemTime {
fn from(t: libc::timespec) -> SystemTime {
- SystemTime { t: Timespec { t: t } }
+ SystemTime { t: Timespec { t } }
}
}
impl From<libc::timespec> for SystemTime {
fn from(t: libc::timespec) -> SystemTime {
- SystemTime { t: Timespec { t: t } }
+ SystemTime { t: Timespec { t } }
}
}
fn new(lock: &'a Mutex) -> DropGuard<'a> {
unsafe {
lock.lock();
- DropGuard { lock: lock }
+ DropGuard { lock }
}
}
}
impl From<c::FILETIME> for SystemTime {
fn from(t: c::FILETIME) -> SystemTime {
- SystemTime { t: t }
+ SystemTime { t }
}
}
/// [`RwLock::read`]: ../../std/sync/struct.RwLock.html#method.read
#[stable(feature = "sync_poison", since = "1.2.0")]
pub fn new(guard: T) -> PoisonError<T> {
- PoisonError { guard: guard }
+ PoisonError { guard }
}
/// Consumes this error indicating that a lock is poisoned, returning the
/// Only use when `value` is known to be less than or equal to 0x10FFFF.
#[inline]
pub unsafe fn from_u32_unchecked(value: u32) -> CodePoint {
- CodePoint { value: value }
+ CodePoint { value }
}
/// Creates a new `CodePoint` if the value is a valid code point.
#[inline]
pub fn from_u32(value: u32) -> Option<CodePoint> {
match value {
- 0 ..= 0x10FFFF => Some(CodePoint { value: value }),
+ 0 ..= 0x10FFFF => Some(CodePoint { value }),
_ => None
}
}
}
}
- Box::new(ExpandResult { p: p })
+ Box::new(ExpandResult { p })
}
// include_str! : read the given file, insert it as a literal string expr
ItemKind::Enum(enum_definition, generics) => {
let generics = folder.fold_generics(generics);
let variants = enum_definition.variants.move_map(|x| folder.fold_variant(x));
- ItemKind::Enum(ast::EnumDef { variants: variants }, generics)
+ ItemKind::Enum(ast::EnumDef { variants }, generics)
}
ItemKind::Struct(struct_def, generics) => {
let generics = folder.fold_generics(generics);
_ => ()
}
- Ok(ast::EnumDef { variants: variants })
+ Ok(ast::EnumDef { variants })
}
/// Parse an "enum" declaration