{"_id":"q-en-rust-000b59b247fe72240ce2ced6fe809c3f2182e217a66df18b14c5e9d0c1ab5a24","text":" // build-pass // compile-flags:-Zmir-opt-level=3 struct D; trait Tr { type It; fn foo(self) -> Option; } impl<'a> Tr for &'a D { type It = (); fn foo(self) -> Option<()> { None } } fn run(f: F) where for<'a> &'a D: Tr, F: Fn(<&D as Tr>::It), { let d = &D; while let Some(i) = d.foo() { f(i); } } fn main() { run(|_| {}); } "}
{"_id":"q-en-rust-000c2406674e4044c9e19b75240b92706e8f483e4aababcee5ec6195563cf982","text":" // edition:2021 #![allow(incomplete_features)] #![feature(async_fn_in_trait)] pub trait Foo { async fn woopsie_async(&self) -> String { 42 //~^ ERROR mismatched types } } fn main() {} "}
{"_id":"q-en-rust-0017db5581aa46c8b0c0fe879064730dd5bb916643b06adec2109a7c8186c92b","text":"E0782: include_str!(\"./error_codes/E0782.md\"), E0783: include_str!(\"./error_codes/E0783.md\"), E0784: include_str!(\"./error_codes/E0784.md\"), E0785: include_str!(\"./error_codes/E0785.md\"), ; // E0006, // merged with E0005 // E0008, // cannot bind by-move into a pattern guard"}
{"_id":"q-en-rust-002de4c29bca3dc5fd86c5cd6db3720205251d29db448b71d7ae63c489fdb85d","text":" error: `..` can only be used once per slice pattern --> $DIR/issue-69103-extra-binding-subslice.rs:6:22 | LL | let [a @ .., b @ ..] = &mut [1, 2]; | -- ^^ can only be used once per slice pattern | | | previously used here error: `..` can only be used once per slice pattern --> $DIR/issue-69103-extra-binding-subslice.rs:10:18 | LL | let [.., c @ ..] = [1, 2]; | -- ^^ can only be used once per slice pattern | | | previously used here error: `..` patterns are not allowed here --> $DIR/issue-69103-extra-binding-subslice.rs:15:18 | LL | let (.., d @ ..) = (1, 2); | ^^ | = note: only allowed in tuple, tuple struct, and slice patterns error: aborting due to 3 previous errors "}
{"_id":"q-en-rust-0045e7b39278999745b8bc4588c2868c6d059de079599ab20f233f68fe74573b","text":"type_param_def.space, type_param_def.index, ty.repr(cx.tcx)); check_typaram_bounds(cx, e.span, ty, type_param_def) } // Check the vtable. let vtable_map = cx.tcx.vtable_map.borrow(); let vtable_res = match vtable_map.find(&method_call) { None => return, Some(vtable_res) => vtable_res, }; check_type_parameter_bounds_in_vtable_result(cx, e.span, vtable_res); } fn check_type_parameter_bounds_in_vtable_result("}
{"_id":"q-en-rust-005fa47b99f2fe2aeded13570c931e8ff853fd2064001c664b5d4bc07bf8575d","text":"} }).peekable(); if fields.peek().is_some() { write!(w, \"
\")?; for (field, ty) in fields { write!(w, \"{name}: {ty}\","}
{"_id":"q-en-rust-009305f76969313311a135309eb681ea35c0b3de903c6c7f8a218038f07476ec","text":" error[E0590]: `break` or `continue` with no label in the condition of a `while` loop --> $DIR/issue-50802.rs:15:21 | LL | break while continue { //~ ERROR E0590 | ^^^^^^^^ unlabeled `continue` in the condition of a `while` loop error: aborting due to previous error For more information about this error, try `rustc --explain E0590`. "}
{"_id":"q-en-rust-0101595a15b45d15c4ac268147c85c447b7a886b27496c38e1fb31ffad0c74f8","text":"used_trait_imports.extend(imports.iter()); } for id in tcx.hir().items() { if matches!(tcx.def_kind(id.def_id), DefKind::Use) { if tcx.visibility(id.def_id).is_public() { continue; } let item = tcx.hir().item(id); if item.span.is_dummy() { continue; } if let hir::ItemKind::Use(path, _) = item.kind { check_import(tcx, &mut used_trait_imports, item.item_id(), path.span); } for &id in tcx.maybe_unused_trait_imports(()) { debug_assert_eq!(tcx.def_kind(id), DefKind::Use); if tcx.visibility(id).is_public() { continue; } if used_trait_imports.contains(&id) { continue; } let item = tcx.hir().expect_item(id); if item.span.is_dummy() { continue; } let hir::ItemKind::Use(path, _) = item.kind else { unreachable!() }; tcx.struct_span_lint_hir(lint::builtin::UNUSED_IMPORTS, item.hir_id(), path.span, |lint| { let msg = if let Ok(snippet) = tcx.sess.source_map().span_to_snippet(path.span) { format!(\"unused import: `{}`\", snippet) } else { \"unused import\".to_owned() }; lint.build(&msg).emit(); }); } unused_crates_lint(tcx); } fn check_import<'tcx>( tcx: TyCtxt<'tcx>, used_trait_imports: &mut FxHashSet, item_id: hir::ItemId, span: Span, ) { if !tcx.maybe_unused_trait_import(item_id.def_id) { return; } if used_trait_imports.contains(&item_id.def_id) { return; } tcx.struct_span_lint_hir(lint::builtin::UNUSED_IMPORTS, item_id.hir_id(), span, |lint| { let msg = if let Ok(snippet) = tcx.sess.source_map().span_to_snippet(span) { format!(\"unused import: `{}`\", snippet) } else { \"unused import\".to_owned() }; lint.build(&msg).emit(); }); } fn unused_crates_lint(tcx: TyCtxt<'_>) { let lint = lint::builtin::UNUSED_EXTERN_CRATES;"}
{"_id":"q-en-rust-010a7dda86dbc7d94aff92302d4fd01089656e021988847660ef6a4996612f9f","text":"None } /// This function checks if the specified expression is a built-in range literal. /// (See: `LoweringContext::lower_expr()` in `src/librustc/hir/lowering.rs`). fn is_range_literal(&self, expr: &hir::Expr) -> bool { use hir::{Path, QPath, ExprKind, TyKind}; // We support `::std::ops::Range` and `::core::ops::Range` prefixes let is_range_path = |path: &Path| { let mut segs = path.segments.iter() .map(|seg| seg.ident.as_str()); if let (Some(root), Some(std_core), Some(ops), Some(range), None) = (segs.next(), segs.next(), segs.next(), segs.next(), segs.next()) { // \"{{root}}\" is the equivalent of `::` prefix in Path root == \"{{root}}\" && (std_core == \"std\" || std_core == \"core\") && ops == \"ops\" && range.starts_with(\"Range\") } else { false } }; let span_is_range_literal = |span: &Span| { // Check whether a span corresponding to a range expression // is a range literal, rather than an explicit struct or `new()` call. let source_map = self.tcx.sess.source_map(); let end_point = source_map.end_point(*span); if let Ok(end_string) = source_map.span_to_snippet(end_point) { !(end_string.ends_with(\"}\") || end_string.ends_with(\")\")) } else { false } }; match expr.node { // All built-in range literals but `..=` and `..` desugar to Structs ExprKind::Struct(QPath::Resolved(None, ref path), _, _) | // `..` desugars to its struct path ExprKind::Path(QPath::Resolved(None, ref path)) => { return is_range_path(&path) && span_is_range_literal(&expr.span); } // `..=` desugars into `::std::ops::RangeInclusive::new(...)` ExprKind::Call(ref func, _) => { if let ExprKind::Path(QPath::TypeRelative(ref ty, ref segment)) = func.node { if let TyKind::Path(QPath::Resolved(None, ref path)) = ty.node { let call_to_new = segment.ident.as_str() == \"new\"; return is_range_path(&path) && span_is_range_literal(&expr.span) && call_to_new; } } } _ => {} } false } pub fn check_for_cast(&self, err: &mut DiagnosticBuilder<'tcx>, expr: &hir::Expr,"}
{"_id":"q-en-rust-0121ceaad090ad80a68516f216651f671f2e6297b8e8884fea78ab5467748b03","text":"ENV TARGETS=$TARGETS,wasm32-wasi ENV TARGETS=$TARGETS,sparcv9-sun-solaris ENV TARGETS=$TARGETS,x86_64-pc-solaris ENV TARGETS=$TARGETS,x86_64-sun-solaris ENV TARGETS=$TARGETS,x86_64-unknown-linux-gnux32 ENV TARGETS=$TARGETS,x86_64-fortanix-unknown-sgx ENV TARGETS=$TARGETS,nvptx64-nvidia-cuda"}
{"_id":"q-en-rust-01423a2d7f2e4e799d7e8db660b55b2ed6b246469ee5da6f72b09a66a58ee8ff","text":") => { // For shortcircuiting operators, mark the RHS as a terminating // scope since it only executes conditionally. terminating(r.hir_id.local_id); } // `Let` expressions (in a let-chain) shouldn't be terminating, as their temporaries // should live beyond the immediate expression if !matches!(r.kind, hir::ExprKind::Let(_)) { terminating(r.hir_id.local_id); } } hir::ExprKind::If(_, ref then, Some(ref otherwise)) => { terminating(then.hir_id.local_id); terminating(otherwise.hir_id.local_id);"}
{"_id":"q-en-rust-0156cc5cd56ac885cbbc7d4368094ba5cc684ca78f2805bb8ad1cdfc096e2187","text":"} pub enum timezone {} pub type sighandler_t = size_t; } pub mod bsd44 {"}
{"_id":"q-en-rust-016685476a62622310251de040610fe56e03ebee04acd84b80532bca1cbca340","text":"BorrowViolation(euv::OverloadedOperator) | BorrowViolation(euv::AddrOf) | BorrowViolation(euv::AutoRef) | BorrowViolation(euv::RefBinding) => { BorrowViolation(euv::RefBinding) | BorrowViolation(euv::MatchDiscriminant) => { \"cannot borrow data mutably\" }"}
{"_id":"q-en-rust-0170da7efd658b9ef237beaee07021577ba0a8ea25fef80cfb198efe31151c0a","text":"fn suggest_moving_args_from_assoc_fn_to_trait_for_method_call( &self, err: &mut Diagnostic, trait_: DefId, trait_def_id: DefId, expr: &'tcx hir::Expr<'tcx>, msg: String, num_assoc_fn_excess_args: usize, num_trait_generics_except_self: usize, ) { if let hir::ExprKind::MethodCall(_, receiver, args, ..) = expr.kind { assert_eq!(args.len(), 0); if num_assoc_fn_excess_args == num_trait_generics_except_self { if let Some(gen_args) = self.gen_args.span_ext() && let Ok(gen_args) = self.tcx.sess.source_map().span_to_snippet(gen_args) && let Ok(receiver) = self.tcx.sess.source_map().span_to_snippet(receiver.span) { let sugg = format!(\"{}::{}::{}({})\", self.tcx.item_name(trait_), gen_args, self.tcx.item_name(self.def_id), receiver); err.span_suggestion(expr.span, msg, sugg, Applicability::MaybeIncorrect); } } let sm = self.tcx.sess.source_map(); let hir::ExprKind::MethodCall(_, rcvr, args, _) = expr.kind else { return; }; if num_assoc_fn_excess_args != num_trait_generics_except_self { return; } let Some(gen_args) = self.gen_args.span_ext() else { return; }; let Ok(generics) = sm.span_to_snippet(gen_args) else { return; }; let Ok(rcvr) = sm.span_to_snippet( rcvr.span.find_ancestor_inside(expr.span).unwrap_or(rcvr.span) ) else { return; }; let Ok(rest) = (match args { [] => Ok(String::new()), [arg] => sm.span_to_snippet( arg.span.find_ancestor_inside(expr.span).unwrap_or(arg.span), ), [first, .., last] => { let first_span = first.span.find_ancestor_inside(expr.span).unwrap_or(first.span); let last_span = last.span.find_ancestor_inside(expr.span).unwrap_or(last.span); sm.span_to_snippet(first_span.to(last_span)) } }) else { return; }; let comma = if args.len() > 0 { \", \" } else { \"\" }; let trait_path = self.tcx.def_path_str(trait_def_id); let method_name = self.tcx.item_name(self.def_id); err.span_suggestion( expr.span, msg, format!(\"{trait_path}::{generics}::{method_name}({rcvr}{comma}{rest})\"), Applicability::MaybeIncorrect, ); } /// Suggests to remove redundant argument(s):"}
{"_id":"q-en-rust-0171650462e4b54ca96211827890dfed43585caa9d06c87d9b38aa84282859f0","text":" // aux-build: issue_67893.rs // edition:2018 // dont-check-compiler-stderr // FIXME(#71222): Add above flag because of the difference of stderrs on some env. extern crate issue_67893; fn g(_: impl Send) {} fn main() { g(issue_67893::run()) //~^ ERROR: `std::sync::MutexGuard<'_, ()>` cannot be sent between threads safely } "}
{"_id":"q-en-rust-01b442ed645a89986e9a6a8e6db711505701346f192c00a865c0904d3daf4ccd","text":" error[E0594]: cannot assign to `*foo` which is behind a `&` reference --> $DIR/issue-51515.rs:17:5 | LL | let foo = &16; | --- help: consider changing this to be a mutable reference: `&mut 16` ... LL | *foo = 32; | ^^^^^^^^^ `foo` is a `&` reference, so the data it refers to cannot be written error[E0594]: cannot assign to `*bar` which is behind a `&` reference --> $DIR/issue-51515.rs:22:5 | LL | let bar = foo; | --- help: consider changing this to be a mutable reference: `&mut i32` ... LL | *bar = 64; | ^^^^^^^^^ `bar` is a `&` reference, so the data it refers to cannot be written error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0594`. "}
{"_id":"q-en-rust-01e4d028e684deab1c37ae62b5a65e1cf4fe041c325ce62c61a43561689b7c30","text":"use rustc::hir::intravisit::{self, NestedVisitorMap, Visitor}; use rustc::infer::InferCtxt; use rustc::ty::{self, Ty, TyCtxt}; use rustc::ty::adjustment::{Adjust, Adjustment}; use rustc::ty::fold::{TypeFoldable, TypeFolder}; use rustc::util::nodemap::DefIdSet; use syntax::ast;"}
{"_id":"q-en-rust-0209c8f3cc58a2d0888214e4ae0bde83a3e96692e08d3f46c98ec5d3ad080f88","text":"if is_fn { ty_to_fn .entry(ty.clone()) .and_modify(|e| *e = (Some(poly_trait.clone()), e.1.clone())) .or_insert(((Some(poly_trait.clone())), None)); .and_modify(|e| *e = (poly_trait.clone(), e.1.clone())) .or_insert(((poly_trait.clone()), None)); ty_to_bounds.entry(ty.clone()).or_default(); } else {"}
{"_id":"q-en-rust-020a68f1aa5049a8f9b4e2d6b14bed831f8e2a6b20685f8ab5067efcfda9ad28","text":"//! found or is otherwise invalid. use crate::check::FnCtxt; use crate::errors; use rustc_ast::ast::Mutability; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_errors::{"}
{"_id":"q-en-rust-020af17902d05fd7d367825e21f5cbbb4758c60af749209bd84a1d60e1697bfa","text":" //! Build a dist manifest, hash and sign everything. //! This gets called by `promote-release` //! (https://github.com/rust-lang/rust-central-station/tree/master/promote-release) //! via `x.py dist hash-and-sign`; the cmdline arguments are set up //! by rustbuild (in `src/bootstrap/dist.rs`). use toml; use serde::Serialize; use std::collections::BTreeMap; use std::env; use std::fs; use std::io::{self, Read, Write, BufRead, BufReader}; use std::io::{self, Read, Write}; use std::path::{PathBuf, Path}; use std::process::{Command, Stdio}; use std::collections::HashMap; static HOSTS: &[&str] = &[ \"aarch64-unknown-linux-gnu\","}
{"_id":"q-en-rust-021f77a423b75699f5dfb5380a21055183077b5c6a75d21c17cae75f56c922a9","text":"| ^^^ type aliases cannot be used as traits | help: you might have meant to use `#![feature(trait_alias)]` instead of a `type` alias --> $DIR/two_files_data.rs:5:1 | LL | type Bar = dyn Foo; | ^^^^^^^^^^^^^^^^^^^ LL | trait Bar = dyn Foo; | error: aborting due to previous error"}
{"_id":"q-en-rust-02374f0d4708135d578419c352d2a5357dfb969d242efd00eaf4e874b841123a","text":"use std::rc::Rc; use syntax::ast; use syntax::codemap::Span; use util::common::ErrorReported; use util::ppaux::{UserString, Repr, ty_to_string}; pub fn check_object_cast<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,"}
{"_id":"q-en-rust-02487e83bc8755547f39575e30543e56ae320dc6c30eda69627ead3d11734f83","text":"} } if digit_count == 0 { None } else { Some(result) } if digit_count == 0 { None } else if !allow_zero_prefix && has_leading_zero && digit_count > 1 { None } else { Some(result) } }) }"}
{"_id":"q-en-rust-024fa20b175c6b3e4f8ef0de7a3976df60c39cc33c90c2bc9c14ef2051cdb484","text":"lpFilePart: *mut LPWSTR, ) -> DWORD; pub fn GetFileAttributesW(lpFileName: LPCWSTR) -> DWORD; pub fn MultiByteToWideChar( CodePage: UINT, dwFlags: DWORD, lpMultiByteStr: LPCCH, cbMultiByte: c_int, lpWideCharStr: LPWSTR, cchWideChar: c_int, ) -> c_int; pub fn WideCharToMultiByte( CodePage: UINT, dwFlags: DWORD, lpWideCharStr: LPCWCH, cchWideChar: c_int, lpMultiByteStr: LPSTR, cbMultiByte: c_int, lpDefaultChar: LPCCH, lpUsedDefaultChar: LPBOOL, ) -> c_int; } #[link(name = \"ws2_32\")]"}
{"_id":"q-en-rust-025ea29ae28d0f61d51fa340f73be015bb70250f64c6cc9918cdc5fcf715779f","text":"let mut result = match self.source_map().span_to_unmapped_path(callsite) { FileName::Real(path) => path, FileName::DocTest(path, _) => path, other => panic!(\"cannot resolve relative path in non-file source `{}`\", other), other => return Err(self.struct_span_err( span, &format!(\"cannot resolve relative path in non-file source `{}`\", other), )), }; result.pop(); result.push(path); result Ok(result) } else { path Ok(path) } } }"}
{"_id":"q-en-rust-026e2505d5dd76a72cbb3865496e6698a295043b3cdd23f62c0e5188cbd5e0c9","text":" // Copyright 2017 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 or the MIT license // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. fn main() { extern crate libc; //~ ERROR use of unstable use libc::*; //~ ERROR unresolved import } "}
{"_id":"q-en-rust-0276d8dac2b7f88c5249cd99a3cf76c2ca4f922345994bf841c2225de8821661","text":" // check-pass // edition:2021 #![deny(opaque_hidden_inferred_bound)] trait Repository /* : ?Sized */ { async fn new() -> Self; } struct MyRepository {} impl Repository for MyRepository { async fn new() -> Self { todo!() } } fn main() {} "}
{"_id":"q-en-rust-027bb79db20f1f6ddcc01c9e216457c78c38a0e75215fc5e4a5299d8d084b59c","text":" const fn f() -> usize { //~^ ERROR mismatched types const FIELD: usize = loop { 0 //~^ ERROR mismatched types }; } fn main() {} "}
{"_id":"q-en-rust-028bfc317c36ba40abc737e2b51e52642dd34194b4f9320fe508749df35982d2","text":") -> Option> { let param_env = ParamEnv::empty(); let repr_type = self.repr.discr_type(); let bit_size = layout::Integer::from_attr(tcx, repr_type).size().bits(); let substs = Substs::identity_for_item(tcx.global_tcx(), expr_did); let instance = ty::Instance::new(expr_did, substs); let cid = GlobalId {"}
{"_id":"q-en-rust-02fb1cd8ecae2bbe15a514b21616029b61347d7d221957f82d815b741e6897f9","text":" // Test that existential types are allowed to contain late-bound regions. // compile-pass // edition:2018 #![feature(async_await, existential_type)] use std::future::Future; pub existential type Func: Sized; // Late bound region should be allowed to escape the function, since it's bound // in the type. fn null_function_ptr() -> Func { None:: fn(&'a ())> } async fn async_nop(_: &u8) {} pub existential type ServeFut: Future"}
{"_id":"q-en-rust-0306ed9a5bf03b13233720211661c7e793c0c70982404382779829c357ea2721","text":"let is_anonymous = item.ident.name == kw::Empty; let repr = if is_anonymous { tcx.adt_def(tcx.local_parent(def_id)).repr() let parent = tcx.local_parent(def_id); if let Node::Item(item) = tcx.hir_node_by_def_id(parent) && item.is_struct_or_union() { tcx.adt_def(parent).repr() } else { tcx.dcx().span_delayed_bug(item.span, \"anonymous field inside non struct/union\"); ty::ReprOptions::default() } } else { tcx.repr_options_of_def(def_id.to_def_id()) };"}
{"_id":"q-en-rust-03422920e7bb6eda1ae94b33bd6bcede3ed1e297eff08cd7afe3c500c4fdc09f","text":" // Copyright 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 or the MIT license // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. trait Trait<'a> { type A; type B; } fn foo<'a, T: Trait<'a>>(value: T::A) { let new: T::B = unsafe { std::mem::transmute(value) }; //~^ ERROR: cannot transmute to or from a type that contains type parameters in its interior [E0139] } fn main() { } "}
{"_id":"q-en-rust-03691cbb739e01aaa529e796485fdab0a918922d3d0c34e95b4ae5bac7fde485","text":"declare_clippy_lint! { /// **What it does:** This lint warns when you use `print!()` with a format /// string that ends in a newline. /// string that /// ends in a newline. /// /// **Why is this bad?** You should use `println!()` instead, which appends the /// newline."}
{"_id":"q-en-rust-0376a56141d464e279991d74f19c046f9e34688a6a2c569642dd742c6abf76b2","text":"// Only inline impl if the implementing type is // reachable in rustdoc generated documentation if !did.is_local() { if let Some(did) = for_.def_id(&cx.cache) { if !cx.cache.effective_visibilities.is_directly_public(tcx, did) { return; } if !tcx.features().rustc_private && !cx.render_options.force_unstable_if_unmarked { if let Some(stab) = tcx.lookup_stability(did) && stab.is_unstable() && stab.feature == sym::rustc_private { return; } } } if !did.is_local() && let Some(did) = for_.def_id(&cx.cache) && !is_directly_public(cx, did) { return; } let document_hidden = cx.render_options.document_hidden;"}
{"_id":"q-en-rust-038317c06ec33f8d8023c6978fb4f0fd7c0e1ee6252b6a4aff5049eaf68ba6e3","text":"Inspect | Copy | Move | PlaceMention | SharedBorrow | ShallowBorrow | UniqueBorrow | AddressOf | Projection, ) => ty::Covariant, PlaceContext::NonUse(AscribeUserTy) => ty::Covariant, PlaceContext::NonUse(AscribeUserTy(variance)) => variance, } }"}
{"_id":"q-en-rust-03a9cd51a6229b4ada8eca395fe1007a26d01c74198f33006f8b6ef7a4ebd4fd","text":"#![doc(html_root_url = \"https://doc.rust-lang.org/nightly/nightly-rustc/\")] #![feature(lazy_cell)] #![feature(decl_macro)] #![feature(ice_to_disk)] #![feature(panic_update_hook)] #![feature(let_chains)] #![recursion_limit = \"256\"] #![allow(rustc::potential_query_instability)]"}
{"_id":"q-en-rust-04318686e73abf45f991f67bdb42f8b9948c9a827564146ab0cb3c89cbae925a","text":"pub has_pub_restricted: bool, pub access_levels: AccessLevels, pub extern_crate_map: FxHashMap, pub maybe_unused_trait_imports: FxHashSet, pub maybe_unused_trait_imports: FxIndexSet, pub maybe_unused_extern_crates: Vec<(LocalDefId, Span)>, pub reexport_map: FxHashMap>, pub glob_map: FxHashMap>,"}
{"_id":"q-en-rust-0440909e1e72289fc26744bc626f8d668347b04c26a55fdc64b796bff058369c","text":" // aux-build:issue-61963.rs // aux-build:issue-61963-1.rs #![deny(bare_trait_objects)] #[macro_use] extern crate issue_61963; #[macro_use] extern crate issue_61963_1; // This test checks that the bare trait object lint does not trigger on macro attributes that // generate code which would trigger the lint. pub struct Baz; pub trait Bar { } pub struct Qux(T); #[dom_struct] pub struct Foo { qux: Qux>, bar: Box, //~^ ERROR trait objects without an explicit `dyn` are deprecated [bare_trait_objects] } fn main() {} "}
{"_id":"q-en-rust-04778e0273cbb25a45f6e5c3f6694dafa24fbcf967b0c6218198a6ae38fb172c","text":"} } // PGO does not work reliably with panic=unwind on Windows. Let's make it // an error to combine the two for now. It always runs into an assertions // if LLVM is built with assertions, but without assertions it sometimes // does not crash and will probably generate a corrupted binary. // We should only display this error if we're actually going to run PGO. // If we're just supposed to print out some data, don't show the error (#61002). if sess.opts.cg.profile_generate.enabled() && sess.target.is_like_msvc && sess.panic_strategy() == PanicStrategy::Unwind && sess.opts.prints.iter().all(|&p| p == PrintRequest::NativeStaticLibs) { sess.err( \"Profile-guided optimization does not yet work in conjunction with `-Cpanic=unwind` on Windows when targeting MSVC. See issue #61002 for more information.\", ); } // Sanitizers can only be used on platforms that we know have working sanitizer codegen. let supported_sanitizers = sess.target.options.supported_sanitizers; let unsupported_sanitizers = sess.opts.debugging_opts.sanitizer - supported_sanitizers;"}
{"_id":"q-en-rust-049ee7c06d8c91af91704040d1f986d31347066cf5391b437caabef5b67b5e8a","text":"LL | | LL | | |x| println!(\"doubling {}\", x); LL | | Some(x * 2) | | ----------- | | ----------- this tail expression is of type `std::option::Option<_>` LL | | LL | | }); | |_____^ expected an `FnOnce<({integer},)>` closure, found `Option<_>`"}
{"_id":"q-en-rust-04a945ffcf7259709651152864ab26090d5beb101fa2f87d08c19f0c4bd78f8e","text":"query upvars_mentioned(def_id: DefId) -> Option<&'tcx FxIndexMap> { desc { |tcx| \"collecting upvars mentioned in `{}`\", tcx.def_path_str(def_id) } } query maybe_unused_trait_import(def_id: LocalDefId) -> bool { desc { |tcx| \"maybe_unused_trait_import for `{}`\", tcx.def_path_str(def_id.to_def_id()) } query maybe_unused_trait_imports(_: ()) -> &'tcx FxIndexSet { desc { \"fetching potentially unused trait imports\" } } query maybe_unused_extern_crates(_: ()) -> &'tcx [(LocalDefId, Span)] { desc { \"looking up all possibly unused extern crates\" }"}
{"_id":"q-en-rust-04b7b125047e8759f35793882d12acc676e524565f6d35a1edc942067005b887","text":"let out = p.wait_with_output().unwrap(); assert!(!out.status.success()); let s = str::from_utf8(&out.stderr).unwrap(); assert!(s.contains(\"stack backtrace\") && s.contains(\"foo::h\"), assert!(s.contains(\"stack backtrace\") && s.contains(\" - foo\"), \"bad output: {}\", s); // Make sure the stack trace is *not* printed"}
{"_id":"q-en-rust-04c64768fdcf1fcca84851d142ce4d9e3e5dbe654f007d4310a7cd4918f64ae5","text":"if let ObligationCauseCode::WhereClause(_, span) | ObligationCauseCode::WhereClauseInExpr(_, span, ..) = &trace.cause.code().peel_derives() && !span.is_dummy() { let span = *span; self.report_concrete_failure(generic_param_scope, placeholder_origin, sub, sup) .with_span_note(span, \"the lifetime requirement is introduced here\") let mut err = self.report_concrete_failure( generic_param_scope, placeholder_origin, sub, sup, ); if !span.is_dummy() { err = err.with_span_note(span, \"the lifetime requirement is introduced here\"); } err } else { unreachable!( \"control flow ensures we have a `BindingObligation` or `WhereClauseInExpr` here...\""}
{"_id":"q-en-rust-04d1d0806d1d16cab2ab4dc68892cd14bbd90c50a6003bebae0b0beb46cb850d","text":" mod machine { pub struct A { pub b: B, } pub struct B {} impl B { pub fn f(&self) {} } } pub struct Context { pub a: machine::A, } pub fn ctx() -> Context { todo!(); } "}
{"_id":"q-en-rust-04d6001b7ed9f321de40799c1baadfc3a915d3e5f9abe9198feee0b08527ec28","text":"ns: Namespace, binding: &'a NameBinding<'a>) -> Result<(), &'a NameBinding<'a>> { let ident = ident.unhygienize(); self.update_resolution(module, ident, ns, |this, resolution| { if let Some(old_binding) = resolution.binding { if binding.is_glob_import() {"}
{"_id":"q-en-rust-0505ef8f5972c0a1615236150a282f0909650b6e45a4ed5d41b83b0342f5823e","text":"let cloned_shared = Rc::clone(&cx.shared); let cache = &cloned_shared.cache; let mut extern_crates = FxHashSet::default(); if !t.is_object_safe(cx.tcx()) { write_small_section_header( w, \"object-safety\", \"Object Safety\", &format!( \"
\", base = crate::clean::utils::DOC_RUST_LANG_ORG_CHANNEL ), ); } if let Some(implementors) = cache.implementors.get(&it.item_id.expect_def_id()) { // The DefId is for the first Type found with that name. The bool is // if any Types with the same name but different DefId have been found."}
{"_id":"q-en-rust-05504e3dc179da753bc32429f249ec4f814a9b7ffedee5ad8e9078f3ce08c0d0","text":"node_to_hir_id: IndexVec::new(), macro_def_scopes: FxHashMap(), expansions: FxHashMap(), keys_created: FxHashSet(), next_disambiguator: FxHashMap(), } }"}
{"_id":"q-en-rust-059292bf71e7c2c37efe9deef8479e255e6b9845def86772fb4eafb5203e3c7a","text":"v.iter().any(|&x| x == 0) } #[inline(always)] fn from_utf8_with_replacement(mut v: &[u8]) -> ~str { // FIXME (#9516): Don't decode utf-8 manually here once we have a good way to do it in str // This is a truly horrifically bad implementation, done as a functionality stopgap until // we have a proper utf-8 decoder. I don't really want to write one here. static REPLACEMENT_CHAR: char = 'uFFFD'; let mut s = str::with_capacity(v.len()); while !v.is_empty() { let w = str::utf8_char_width(v[0]); if w == 0u { s.push_char(REPLACEMENT_CHAR); v = v.slice_from(1); } else if v.len() < w || !str::is_utf8(v.slice_to(w)) { s.push_char(REPLACEMENT_CHAR); v = v.slice_from(1); } else { s.push_str(unsafe { ::cast::transmute(v.slice_to(w)) }); v = v.slice_from(w); } } s } #[cfg(test)] mod tests { use prelude::*;"}
{"_id":"q-en-rust-0596629883c6e6d03fc031390ed75132ca7a1ad6f9344fc827dada40dc906f75","text":".map(|(item, renamed)| clean_maybe_renamed_foreign_item(cx, item, *renamed)), ); items.extend(self.mods.iter().map(|x| x.clean(cx))); items.extend( self.items .iter() .flat_map(|(item, renamed)| clean_maybe_renamed_item(cx, item, *renamed)), ); // Split up imports from all other items. // // This covers the case where somebody does an import which should pull in an item, // but there's already an item with the same namespace and same name. Rust gives // priority to the not-imported one, so we should, too. let mut inserted = FxHashSet::default(); items.extend(self.items.iter().flat_map(|(item, renamed)| { // First, lower everything other than imports. if matches!(item.kind, hir::ItemKind::Use(..)) { return Vec::new(); } let v = clean_maybe_renamed_item(cx, item, *renamed); for item in &v { if let Some(name) = item.name { inserted.insert((item.type_(), name)); } } v })); items.extend(self.items.iter().flat_map(|(item, renamed)| { // Now we actually lower the imports, skipping everything else. if !matches!(item.kind, hir::ItemKind::Use(..)) { return Vec::new(); } let mut v = clean_maybe_renamed_item(cx, item, *renamed); v.drain_filter(|item| { if let Some(name) = item.name { // If an item with the same type and name already exists, // it takes priority over the inlined stuff. !inserted.insert((item.type_(), name)) } else { false } }); v })); // determine if we should display the inner contents or // the outer `mod` item for the source code."}
{"_id":"q-en-rust-05b89db50f5a519eb3fa9a4096583c2da9026144b5069fcc8c4e45e7ee096631","text":"cargo.arg(\"--release\"); } if mode != Mode::Libstd && // FIXME(#45320) mode != Mode::Libtest && // FIXME(#45511) self.config.rust_codegen_units.is_none() && if self.config.rust_codegen_units.is_none() && self.build.is_rust_llvm(compiler.host) { cargo.env(\"RUSTC_THINLTO\", \"1\");"}
{"_id":"q-en-rust-05e11ec0954551b622fbeee9b634c6275d8a2d59ac8853f8aac915f7d0fc9886","text":"} impl Attribute { /// Returns `true` if the attribute's path matches the argument. If it matches, then the /// attribute is marked as used. /// /// To check the attribute name without marking it used, use the `path` field directly. pub fn check_name(&self, name: &str) -> bool { let matches = self.path == name; if matches {"}
{"_id":"q-en-rust-0615114be5d2a4b1e068ccae956222570a7b1c14a6fa621181e624a3a93cd4cf","text":"#![feature(const_fn)] #![feature(const_fn_union)] #![feature(const_generics)] #![cfg_attr(not(bootstrap), feature(const_ptr_offset_from))] #![cfg_attr(not(bootstrap), feature(const_type_name))] #![feature(custom_inner_attributes)] #![feature(decl_macro)] #![feature(doc_cfg)]"}
{"_id":"q-en-rust-0624b60cba69892b0c0495e8e1c9e34ab79b14c07a166bc0188f0f74bf2f07d8","text":"fn visit_foreign_item(&mut self, fi: &'tcx hir::ForeignItem) { if self.should_warn_about_foreign_item(fi) { self.warn_dead_code(fi.id, fi.span, fi.name, fi.node.descriptive_variant()); self.warn_dead_code(fi.id, fi.span, fi.name, fi.node.descriptive_variant(), \"used\"); } intravisit::walk_foreign_item(self, fi); } fn visit_struct_field(&mut self, field: &'tcx hir::StructField) { if self.should_warn_about_field(&field) { self.warn_dead_code(field.id, field.span, field.name, \"field\"); self.warn_dead_code(field.id, field.span, field.name, \"field\", \"used\"); } intravisit::walk_struct_field(self, field); }"}
{"_id":"q-en-rust-062fb5111e8ce5585c237619d90aad3785fec0d490349fcf6d01a7c21cbd72ce","text":"} _ => { let tt = TokenTree::Token(self.token.take()); let is_joint = self.bump(); let mut is_joint = self.bump(); if !self.token.is_op() { is_joint = NonJoint; } Ok((tt, is_joint)) } }"}
{"_id":"q-en-rust-064cb92de7efe8859fb5035f9bc2fa0b464e76363a03d3a3f96b7012eaee46a1","text":"version = \"0.6.0\" dependencies = [ \"clippy_lints\", \"env_logger 0.6.2\", \"env_logger 0.7.0\", \"failure\", \"futures\", \"log\", \"rand 0.6.1\", \"rand 0.7.0\", \"rls-data\", \"rls-ipc\", \"serde\","}
{"_id":"q-en-rust-06acc0079b7fb7643ba9febdd1c5e81d7b200f0187da700d3be6d2520c4e7042","text":"use std::env; use std::ffi::OsString; use std::fmt::Write as _; use std::fs; use std::fs::{self, File}; use std::io::{self, IsTerminal, Read, Write}; use std::panic::{self, catch_unwind}; use std::panic::{self, catch_unwind, PanicInfo}; use std::path::PathBuf; use std::process::{self, Command, Stdio}; use std::str;"}
{"_id":"q-en-rust-0765fa8c30e10c65e7558509253bfccc0766bf737f6d9125adf1c04379b5c12b","text":"/// } /// ``` #[stable(feature = \"io_error_inner\", since = \"1.3.0\")] #[inline] pub fn get_mut(&mut self) -> Option<&mut (dyn error::Error + Send + Sync + 'static)> { match self.repr { Repr::Os(..) => None,"}
{"_id":"q-en-rust-077a14bdb96c38330901dbaf11a6c307152ed97d6f108f73dda05329dea690a3","text":"} } /// If a tool does not pass its tests, don't ship it. /// Right now, we do this only for Miri. fn check_toolstate(&mut self) { let toolstates: Option> = File::open(self.input.join(\"toolstates-linux.json\")).ok() .and_then(|f| serde_json::from_reader(&f).ok()); let toolstates = toolstates.unwrap_or_else(|| { println!(\"WARNING: `toolstates-linux.json` missing/malformed; assuming all tools failed\"); HashMap::default() // Use empty map if anything went wrong. }); // Mark some tools as missing based on toolstate. if toolstates.get(\"miri\").map(|s| &*s as &str) != Some(\"test-pass\") { println!(\"Miri tests are not passing, removing component\"); self.miri_version = None; self.miri_git_commit_hash = None; } } /// Hash all files, compute their signatures, and collect the hashes in `self.digests`. fn digest_and_sign(&mut self) { for file in t!(self.input.read_dir()).map(|e| t!(e).path()) {"}
{"_id":"q-en-rust-0781237e70abe4f915ba8863a241155d5f0989b5fae8683778a3fe0931c54bcd","text":" //@ edition: 2021 #![feature(must_not_suspend, allocator_api)] #![deny(must_not_suspend)] use std::alloc::*; use std::ptr::NonNull; #[must_not_suspend] struct MyAllocatorWhichMustNotSuspend; unsafe impl Allocator for MyAllocatorWhichMustNotSuspend { fn allocate(&self, l: Layout) -> Result, AllocError> { Global.allocate(l) } unsafe fn deallocate(&self, p: NonNull, l: Layout) { Global.deallocate(p, l) } } async fn suspend() {} async fn foo() { let x = Box::new_in(1i32, MyAllocatorWhichMustNotSuspend); //~^ ERROR allocator `MyAllocatorWhichMustNotSuspend` held across a suspend point, but should not be suspend().await; drop(x); } fn main() {} "}
{"_id":"q-en-rust-078f3efcf1bc6f3c2f04c809d865f5fdd83b72cef11a62132e8524418e5f3925","text":"self.with_context(LabeledBlock, |v| v.visit_block(&b)); } hir::ExprBreak(label, ref opt_expr) => { opt_expr.as_ref().map(|e| self.visit_expr(e)); if self.require_label_in_labeled_block(e.span, &label, \"break\") { // If we emitted an error about an unlabeled break in a labeled // block, we don't need any further checking for this break any more"}
{"_id":"q-en-rust-07dc4d41da5e9893b4da20461609b0d56f954171a5277c294e1396c6ef352b78","text":" // error-pattern: aborting due to 6 previous errors fn i(n{...,f # "}
{"_id":"q-en-rust-07fab6a97850f94513361b895fb993e91d2f714ee35eed75f69215cafbef0278","text":" error[E0425]: cannot find function `missing` in this scope --> $DIR/error-body.rs:5:5 | LL | missing(); | ^^^^^^^ not found in this scope error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0425`. "}
{"_id":"q-en-rust-080ad75c526d9e8464188361ed2f495a3024da27fb3e2f8c70636502b0637fe1","text":"let msg = \"asm template must be a string literal\"; let template_sp = template_expr.span; let template_is_mac_call = matches!(template_expr.kind, ast::ExprKind::MacCall(_)); let (template_str, template_style, template_span) = { let ExpandResult::Ready(mac) = expr_to_spanned_string(ecx, template_expr, msg) else { return ExpandResult::Retry(());"}
{"_id":"q-en-rust-08397d50ba5f576c8d4a89de62fd440c43b75b074c0d4e0230f1d5f85568c977","text":"return } // Package save-analysis from stage1 if not doing a full bootstrap, as the // stage2 artifacts is simply copied from stage1 in that case. let compiler = if build.force_use_stage1(compiler, target) { Compiler::new(1, compiler.host) } else { compiler.clone() }; let name = format!(\"rust-analysis-{}\", package_vers(build)); let image = tmpdir(build).join(format!(\"{}-{}-image\", name, target)); let src = build.stage_out(compiler, Mode::Libstd).join(target).join(\"release\").join(\"deps\"); let src = build.stage_out(&compiler, Mode::Libstd).join(target).join(\"release\").join(\"deps\"); let image_src = src.join(\"save-analysis\"); let dst = image.join(\"lib/rustlib\").join(target).join(\"analysis\");"}
{"_id":"q-en-rust-083bf167cf591079cbc271a482354c67235865023b2c0f8ab3ec704be1dbe720","text":"version = \"0.11.0\" source = \"registry+https://github.com/rust-lang/crates.io-index\" dependencies = [ \"backtrace 0.3.25 (registry+https://github.com/rust-lang/crates.io-index)\", \"backtrace 0.3.29 (registry+https://github.com/rust-lang/crates.io-index)\", ] [[package]]"}
{"_id":"q-en-rust-087d406d62d6bd7140f6aeaf0ab01673cb0527fe2065e7ef826a31ae59569cbc","text":"[[package]] name = \"rand\" version = \"0.4.6\" source = \"registry+https://github.com/rust-lang/crates.io-index\" dependencies = [ \"fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)\", \"libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)\", \"rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)\", \"rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)\", \"winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)\", ] [[package]] name = \"rand\" version = \"0.6.1\" source = \"registry+https://github.com/rust-lang/crates.io-index\" dependencies = ["}
{"_id":"q-en-rust-08c526bfe1021f72717ddd00139c19a01b3f83d2562772f42f15631bc88da929","text":"return value else: return \"'\" + value + \"'\" elif isinstance(value, dict): return \"{\" + \", \".join(map(lambda a: \"{} = {}\".format(to_toml(a[0]), to_toml(a[1])), value.items())) + \"}\" else: raise RuntimeError('no toml')"}
{"_id":"q-en-rust-08c6d5830c8f622f87f1fcc397ae55a9b761b4f03e2f39d7a4653d41225c318a","text":"adjusted_ty, index_ty); // First, try built-in indexing. match (adjusted_ty.builtin_index(), &index_ty.sty) { (Some(ty), &ty::TyUint(ast::UintTy::Usize)) | (Some(ty), &ty::TyInfer(ty::IntVar(_))) => { debug!(\"try_index_step: success, using built-in indexing\"); let adjustments = autoderef.adjust_steps(lvalue_pref); self.apply_adjustments(base_expr, adjustments); return Some((self.tcx.types.usize, ty)); } _ => {} } for &unsize in &[false, true] { let mut self_ty = adjusted_ty; if unsize {"}
{"_id":"q-en-rust-0907a819d5b5b932331d275422b7652cf44e913ef819d550218f99ee5469ebfe","text":"} fn parse_borrowed_pointee(&mut self) -> PResult<'a, TyKind> { let opt_lifetime = if self.check_lifetime() { Some(self.expect_lifetime()) } else { None }; let and_span = self.prev_token.span; let mut opt_lifetime = if self.check_lifetime() { Some(self.expect_lifetime()) } else { None }; let mutbl = self.parse_mutability(); if self.token.is_lifetime() && mutbl == Mutability::Mut && opt_lifetime.is_none() { // A lifetime is invalid here: it would be part of a bare trait bound, which requires // it to be followed by a plus, but we disallow plus in the pointee type. // So we can handle this case as an error here, and suggest `'a mut`. // If there *is* a plus next though, handling the error later provides better suggestions // (like adding parentheses) if !self.look_ahead(1, |t| t.is_like_plus()) { let lifetime_span = self.token.span; let span = and_span.to(lifetime_span); let mut err = self.struct_span_err(span, \"lifetime must precede `mut`\"); if let Ok(lifetime_src) = self.span_to_snippet(lifetime_span) { err.span_suggestion( span, \"place the lifetime before `mut`\", format!(\"&{} mut\", lifetime_src), Applicability::MaybeIncorrect, ); } err.emit(); opt_lifetime = Some(self.expect_lifetime()); } } let ty = self.parse_ty_no_plus()?; Ok(TyKind::Rptr(opt_lifetime, MutTy { ty, mutbl })) }"}
{"_id":"q-en-rust-091465819d50f49a135edc714329c86d718d36f1bd14fd5574ea5e5a5cd59c80","text":" // Copyright 2017 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 or the MIT license // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. // #39872, #39553 #![feature(conservative_impl_trait)] fn will_ice(something: &u32) -> impl Iterator { //~^ ERROR the trait bound `(): std::iter::Iterator` is not satisfied [E0277] } fn main() {} "}
{"_id":"q-en-rust-091bd2f6db1be4329ae9cbb098be49b8d0bf3457d068eda330ef69c0f6f28a4d","text":"# (to avoid spending a lot of time cloning llvm) if [ \"$EXTERNAL_LLVM\" = \"\" ]; then RUST_CONFIGURE_ARGS=\"$RUST_CONFIGURE_ARGS --set build.optimized-compiler-builtins\" # Likewise, only demand we test all LLVM components if we know we built LLVM with them export COMPILETEST_NEEDS_ALL_LLVM_COMPONENTS=1 elif [ \"$DEPLOY$DEPLOY_ALT\" = \"1\" ]; then echo \"error: dist builds should always use optimized compiler-rt!\" >&2 exit 1"}
{"_id":"q-en-rust-092600fc6f5fddd99db1cc81a104b101cb94a10d82e6aa581d69d6d9edbf441c","text":"[true] `{$param_name}` *[false] `fn` parameter } has {$lifetime_kind -> [named] lifetime `{$lifetime}` *[anon] an anonymous lifetime `'_` } but calling `{assoc_item}` introduces an implicit `'static` lifetime requirement [true] lifetime `{$lifetime}` *[false] an anonymous lifetime `'_` } but calling `{$assoc_item}` introduces an implicit `'static` lifetime requirement .label1 = {$has_lifetime -> [named] lifetime `{$lifetime}` *[anon] an anonymous lifetime `'_` [true] lifetime `{$lifetime}` *[false] an anonymous lifetime `'_` } .label2 = ...is used and required to live as long as `'static` here because of an implicit lifetime bound on the {$has_impl_path -> [named] `impl` of `{$impl_path}` *[anon] inherent `impl` [true] `impl` of `{$impl_path}` *[false] inherent `impl` } infer_but_needs_to_satisfy = {$has_param_name -> [true] `{$param_name}` *[false] `fn` parameter } has {$has_lifetime -> [named] lifetime `{$lifetime}` *[anon] an anonymous lifetime `'_` [true] lifetime `{$lifetime}` *[false] an anonymous lifetime `'_` } but it needs to satisfy a `'static` lifetime requirement .influencer = this data with {$has_lifetime -> [named] lifetime `{$lifetime}` *[anon] an anonymous lifetime `'_` [true] lifetime `{$lifetime}` *[false] an anonymous lifetime `'_` }... .require = {$spans_empty -> *[true] ...is used and required to live as long as `'static` here"}
{"_id":"q-en-rust-093841aec65603bf55a91a1a8ac41b41dcd134fdd770cfdd543b83860cc338d3","text":"} } const LOADERS: &Vec<&'static u8> = &Vec::new(); pub fn break_code() -> Option<&'static u8> { for loader in &*LOADERS { //~ ERROR cannot move out of a shared reference return Some(loader); } None } fn main() {}"}
{"_id":"q-en-rust-093eedd162ee5fabd981670a0e9cc5258ca7f63790303d923af732852ed50946","text":"ArenaSet(vec![], &Z) } unsafe { use std::sync::{Once, ONCE_INIT}; use std::sync::Once; fn require_sync(_: &T) { } unsafe fn __stability() -> &'static ArenaSet> { use std::mem::transmute; static mut DATA: *const ArenaSet> = 0 as *const ArenaSet>; static mut ONCE: Once = ONCE_INIT; static mut ONCE: Once = Once::new(); ONCE.call_once(|| { DATA = transmute ::>>, *const ArenaSet>>"}
{"_id":"q-en-rust-09695ce653b585dfdf5a7dad776fc273a16991f3365db78a1664b059b40a64b5","text":" // 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 or the MIT license // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. // Test that we don't ICE due to encountering unsubstituted type // parameters when untupling FnOnce parameters during translation of // an unboxing shim. #![feature(unboxed_closures)] fn main() { let _: Box> = box move |&mut:| {}; } "}
{"_id":"q-en-rust-09a06697fbc4231a846de2c13d7cd29f61f5b8aad2cfd53cf82133cd865a5f3e","text":" error: `#[panic_handler]` function required, but not found error[E0308]: mismatched types --> $DIR/issue-54505-no-std.rs:28:16 | LL | take_range(0..1); | ^^^^ | | | expected reference, found struct `core::ops::Range` | help: consider borrowing here: `&(0..1)` | = note: expected type `&_` found type `core::ops::Range<{integer}>` error[E0308]: mismatched types --> $DIR/issue-54505-no-std.rs:33:16 | LL | take_range(1..); | ^^^ | | | expected reference, found struct `core::ops::RangeFrom` | help: consider borrowing here: `&(1..)` | = note: expected type `&_` found type `core::ops::RangeFrom<{integer}>` error[E0308]: mismatched types --> $DIR/issue-54505-no-std.rs:38:16 | LL | take_range(..); | ^^ | | | expected reference, found struct `core::ops::RangeFull` | help: consider borrowing here: `&(..)` | = note: expected type `&_` found type `core::ops::RangeFull` error[E0308]: mismatched types --> $DIR/issue-54505-no-std.rs:43:16 | LL | take_range(0..=1); | ^^^^^ | | | expected reference, found struct `core::ops::RangeInclusive` | help: consider borrowing here: `&(0..=1)` | = note: expected type `&_` found type `core::ops::RangeInclusive<{integer}>` error[E0308]: mismatched types --> $DIR/issue-54505-no-std.rs:48:16 | LL | take_range(..5); | ^^^ | | | expected reference, found struct `core::ops::RangeTo` | help: consider borrowing here: `&(..5)` | = note: expected type `&_` found type `core::ops::RangeTo<{integer}>` error[E0308]: mismatched types --> $DIR/issue-54505-no-std.rs:53:16 | LL | take_range(..=42); | ^^^^^ | | | expected reference, found struct `core::ops::RangeToInclusive` | help: consider borrowing here: `&(..=42)` | = note: expected type `&_` found type `core::ops::RangeToInclusive<{integer}>` error: aborting due to 7 previous errors For more information about this error, try `rustc --explain E0308`. "}
{"_id":"q-en-rust-09a49dd53445ec08d475fd66091d3e0171b903d15e6a928bd220dd113f79f998","text":"/// # Examples /// /// ```no_run /// # #![feature(bufreader_buffer)] /// use std::io::BufWriter; /// use std::net::TcpStream; ///"}
{"_id":"q-en-rust-09b2d11ff31be2bcaa15fd59b396afbf7e06c12a242bc34ed970e09824eabba0","text":"exact_paths: DefIdMap>, modules: Vec>, is_importable_from_parent: bool, inside_body: bool, } impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {"}
{"_id":"q-en-rust-09c468ee097af6484eb74f0285d64f671ec6328274bb0253f927da9288fa6a4a","text":" // 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 or the MIT license // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. // xfail-test fn function() -> &mut [int] { let mut x: &'static mut [int] = &[1,2,3]; x[0] = 12345; x //~ ERROR bad } fn main() { let x = function(); error!(\"%?\", x); } "}
{"_id":"q-en-rust-09c53182b7266b440ece70652e9fe24ced85919fe8fa43270aed3180ef6bb6b7","text":"crate mod sidebar { /// File script to handle sidebar. crate static SOURCE_SCRIPT: &str = include_str!(\"static/source-script.js\"); /// Top Level sidebar items script which will load a sidebar without items. crate static ITEMS: &str = include_str!(\"static/sidebar-items.js\"); }"}
{"_id":"q-en-rust-0a57ba1d10f0ca9155f1ade2bd26cf6c8fda813dbcac26b54f111be4cbac32ee","text":" // run-pass // compile-flags: --edition 2018 #![feature(try_blocks)] fn main() { match try { false } { _ => {} } //~ ERROR expected expression, found reserved keyword `try` match try { } { Err(()) => (), Ok(()) => (), } }"}
{"_id":"q-en-rust-0a67a51a1604f9d6961997930abf0e1110377934e322c3fe1f0ee026f7b0b269","text":"GenericArgs::Parenthesized { inputs, output } => (inputs, output), }; let output = output.as_ref().cloned().map(Box::new); if old_output.is_some() && old_output != output { panic!(\"Output mismatch for {:?} {:?} {:?}\", ty, old_output, data.1); panic!(\"Output mismatch for {:?} {:?} {:?}\", ty, old_output, output); } let new_params = GenericArgs::Parenthesized { inputs: old_input, output };"}
{"_id":"q-en-rust-0a6b4bc2cd5befec0820b67418aa0d9e993588b8bd86097b74f427359bc74eb6","text":" error[E0597]: borrowed value does not live long enough --> $DIR/issue-52049.rs:16:10 | LL | foo(&unpromotable(5u32)); | ^^^^^^^^^^^^^^^^^^ temporary value does not live long enough LL | } | - temporary value only lives until here | = note: borrowed value must be valid for the static lifetime... error: aborting due to previous error For more information about this error, try `rustc --explain E0597`. "}
{"_id":"q-en-rust-0a879985da1f6513a75e1b27672012468ee0dda4c115afc5cd9778180230fa15","text":"}; use crate::traits::{Obligation, PredicateObligations}; use rustc_middle::ty::relate::{Relate, RelateResult, TypeRelation}; use rustc_middle::ty::relate::{ relate_args_invariantly, relate_args_with_variances, Relate, RelateResult, TypeRelation, }; use rustc_middle::ty::TyVar; use rustc_middle::ty::{self, Ty, TyCtxt}; use rustc_span::Span;"}
{"_id":"q-en-rust-0ac7c305aa238a34a8fc5c3339a6a8c6346f7394507e02190bf08a46ed434e5a","text":" // edition:2021 #![feature(rustc_attrs)] // Test that we can't move out of struct that impls `Drop`. use std::rc::Rc; // Test that we restrict precision when moving not-`Copy` types, if any of the parent paths // implement `Drop`. This is to ensure that we don't move out of a type that implements Drop. pub fn test1() { struct Foo(Rc); impl Drop for Foo { fn drop(self: &mut Foo) {} } let f = Foo(Rc::new(1)); let x = #[rustc_capture_analysis] move || { //~^ ERROR: attributes on expressions are experimental //~| NOTE: see issue #15701 //~| ERROR: First Pass analysis includes: //~| ERROR: Min Capture analysis includes: println!(\"{:?}\", f.0); //~^ NOTE: Capturing f[(0, 0)] -> ImmBorrow //~| NOTE: Min Capture f[] -> ByValue }; x(); } // Test that we don't restrict precision when moving `Copy` types(i.e. when copying), // even if any of the parent paths implement `Drop`. fn test2() { struct Character { hp: u32, name: String, } impl Drop for Character { fn drop(&mut self) {} } let character = Character { hp: 100, name: format!(\"A\") }; let c = #[rustc_capture_analysis] move || { //~^ ERROR: attributes on expressions are experimental //~| NOTE: see issue #15701 //~| ERROR: First Pass analysis includes: //~| ERROR: Min Capture analysis includes: println!(\"{}\", character.hp) //~^ NOTE: Capturing character[(0, 0)] -> ImmBorrow //~| NOTE: Min Capture character[(0, 0)] -> ByValue }; c(); println!(\"{}\", character.name); } fn main() {} "}
{"_id":"q-en-rust-0ad5eeea7dcd8a526da01faa2450157331942b276da72e5b9406bd3e9010da58","text":" // check-pass // Minimized case from #62767. mod m { pub enum Same { Same,"}
{"_id":"q-en-rust-0ae3cf940eed91e0d0d0c5203da5116132ab14d770d30ee277eba03f2aa69e02","text":"/// \"self-confirming\" import resolutions during import validation. unusable_binding: Option<&'a NameBinding<'a>>, // Spans for local variables found during pattern resolution. // Used for suggestions during error reporting. pat_span_map: NodeMap, /// Resolutions for nodes that have a single resolution. partial_res_map: NodeMap, /// Resolutions for import nodes, which have multiple resolutions in different namespaces."}
{"_id":"q-en-rust-0ae9b987c6ead91333d36653976a71c8a3fc9c3b905fc83f9a20110316c5a1ed","text":"Some(e) => e, }; let mut bytes = Vec::new(); let mut err = false; for expr in exprs.iter() { match expr.node {"}
{"_id":"q-en-rust-0af8a55d375784e0dccdc08f4cc746fe4638b252fa298683317a0a1fba3b696f","text":" error[E0599]: no method named `some_function` found for struct `SmallVec` in the current scope --> $DIR/hash-tyvid-regression-3.rs:17:19 | LL | node.keys.some_function(); | ^^^^^^^^^^^^^ method not found in `SmallVec<{ D * 2 }>` ... LL | struct SmallVec {} | ------------------------------- method `some_function` not found for this error: aborting due to previous error For more information about this error, try `rustc --explain E0599`. "}
{"_id":"q-en-rust-0b124ffdfd14fdd479733156f37704b83c4439b5d787891d344f9e382cf66566","text":" warning: unnecessary parentheses around function argument --> $DIR/try-block-unused-delims.rs:10:13 | LL | consume((try {})); | ^^^^^^^^ help: remove these parentheses | note: the lint level is defined here --> $DIR/try-block-unused-delims.rs:5:9 | LL | #![warn(unused_parens, unused_braces)] | ^^^^^^^^^^^^^ warning: unnecessary braces around function argument --> $DIR/try-block-unused-delims.rs:13:13 | LL | consume({ try {} }); | ^^^^^^^^^^ help: remove these braces | note: the lint level is defined here --> $DIR/try-block-unused-delims.rs:5:24 | LL | #![warn(unused_parens, unused_braces)] | ^^^^^^^^^^^^^ warning: unnecessary parentheses around `match` scrutinee expression --> $DIR/try-block-unused-delims.rs:16:11 | LL | match (try {}) { | ^^^^^^^^ help: remove these parentheses warning: unnecessary parentheses around `let` scrutinee expression --> $DIR/try-block-unused-delims.rs:21:22 | LL | if let Err(()) = (try {}) {} | ^^^^^^^^ help: remove these parentheses warning: unnecessary parentheses around `match` scrutinee expression --> $DIR/try-block-unused-delims.rs:24:11 | LL | match (try {}) { | ^^^^^^^^ help: remove these parentheses warning: 5 warnings emitted "}
{"_id":"q-en-rust-0b12e8a0d5147776d82fc88e8a27269ed861e56da23423747d75251805b2e8bc","text":"} // Visit everything except for private impl items. hir::ItemKind::Impl(ref impl_) => { for impl_item_ref in impl_.items { if impl_.of_trait.is_some() || self.tcx.visibility(impl_item_ref.id.def_id) == ty::Visibility::Public { self.update(impl_item_ref.id.def_id, item_level); } } if item_level.is_some() { self.reach(item.def_id, item_level).generics().predicates().ty().trait_ref();"}
{"_id":"q-en-rust-0b12f2e045aec4116645066fe2376d9be2db657f13320869e8e6c2329f31a7a7","text":"pub(crate) no_emit_shared: bool, /// If `true`, HTML source code pages won't be generated. pub(crate) html_no_source: bool, /// Whether `-Zforce-unstable-if-unmarked` unstable option is set pub(crate) force_unstable_if_unmarked: bool, } #[derive(Copy, Clone, Debug, PartialEq, Eq)]"}
{"_id":"q-en-rust-0b24c7d3674feecb6fc764eba08f99f7b7926edee270140f7a19d8b606506c66","text":".collect::>() .into(), id: fld.new_id(id), ident: ident, ident: fld.fold_ident(ident), bounds: fld.fold_bounds(bounds), default: default.map(|x| fld.fold_ty(x)), span: span"}
{"_id":"q-en-rust-0b97621eaf84db45156579ddbd2abced90b73a9a50d43bc1a5913a014d6fcf82","text":"match tcx.const_eval(param_env.and(cid)) { Ok(&ty::Const { val: ConstVal::Value(Value::ByVal(PrimVal::Bytes(b))), .. ty, }) => { trace!(\"discriminants: {} ({:?})\", b, repr_type); let ty = repr_type.to_ty(tcx); if repr_type.is_signed() { let val = b as i128; // sign extend to i128 let amt = 128 - bit_size; let val = (val << amt) >> amt; Some(Discr { val: val as u128, ty, }) } else { Some(Discr { val: b, ty, }) } Some(Discr { val: b, ty, }) }, Ok(&ty::Const { val: ConstVal::Value(other),"}
{"_id":"q-en-rust-0c60e8026ddb3ee674f7ef3215f1834dddc429734d480118eedc35c1689dd396","text":"\"once_cell\", \"opener\", \"pretty_assertions\", \"semver\", \"serde\", \"serde_derive\", \"serde_json\","}
{"_id":"q-en-rust-0cd44c1d5ea03b892da9374ca764bba3ef3193f34a7ba503fb8aadacde3cd691","text":"use abi::Abi; use ast::{self, Ident, Generics, Expr, BlockCheckMode, UnOp, PatKind}; use attr; use syntax_pos::{Span, DUMMY_SP, Pos}; use syntax_pos::{Span, DUMMY_SP}; use codemap::{dummy_spanned, respan, Spanned}; use ext::base::ExtCtxt; use ptr::P;"}
{"_id":"q-en-rust-0cf9911a94939ae63db7fb8ee64f46fe4be4a993da914d80b8bce8f5014ba25f","text":" // run-pass #![feature(backtrace)] #[derive(Clone, Copy)] struct Foo { array: [u64; 10240], } impl Foo { const fn new() -> Self { Self { array: [0x1122_3344_5566_7788; 10240] } } } static BAR: [Foo; 10240] = [Foo::new(); 10240]; fn main() { let bt = std::backtrace::Backtrace::force_capture(); println!(\"Hello, world! {:?}\", bt); println!(\"{:x}\", BAR[0].array[0]); } "}
{"_id":"q-en-rust-0cffb512b092c8f87a6a8c837ecba6362a56465baa85ca60dd8f4eaaca2bd514","text":"impl LintPass for TypeLimits { fn get_lints(&self) -> LintArray { lint_array!(UNSIGNED_NEGATION, UNUSED_COMPARISONS, OVERFLOWING_LITERALS) lint_array!(UNSIGNED_NEGATION, UNUSED_COMPARISONS, OVERFLOWING_LITERALS, EXCEEDING_BITSHIFTS) } fn check_expr(&mut self, cx: &Context, e: &ast::Expr) {"}
{"_id":"q-en-rust-0d1e5604b0a135ab2153e948f4f058e03fb8669756d026394e44e75005d0275a","text":"trait Foo { type Bar<'a>: Deref::Bar>; //~^ ERROR this associated type takes 1 lifetime argument but 0 lifetime arguments were supplied //~| ERROR associated type bindings are not allowed here //~| HELP add missing }"}
{"_id":"q-en-rust-0d40d92a20d6d58b6f2ace737ae19a16f1bc90e0a3f411bda0f7e250d4edc612","text":"fn main() { let _: &dyn const Trait; //~ ERROR const trait bounds are not allowed in trait object types let _: &dyn ~const Trait; //~ ERROR `~const` is not allowed here } // Regression test for issue #119525. trait NonConst {} const fn handle(_: &dyn const NonConst) {} //~^ ERROR const trait bounds are not allowed in trait object types const fn take(_: &dyn ~const NonConst) {} //~^ ERROR `~const` is not allowed here "}
{"_id":"q-en-rust-0d593c183b59a3680335d739bbcae553f14c42bfbdd565da8982685411755be1","text":"\"checksum pest_generator 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)\" = \"63120576c4efd69615b5537d3d052257328a4ca82876771d6944424ccfd9f646\" \"checksum pest_meta 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)\" = \"f5a3492a4ed208ffc247adcdcc7ba2a95be3104f58877d0d02f0df39bf3efb5e\" \"checksum petgraph 0.4.13 (registry+https://github.com/rust-lang/crates.io-index)\" = \"9c3659d1ee90221741f65dd128d9998311b0e40c5d3c23a62445938214abce4f\" \"checksum phf 0.7.22 (registry+https://github.com/rust-lang/crates.io-index)\" = \"7d37a244c75a9748e049225155f56dbcb98fe71b192fd25fd23cb914b5ad62f2\" \"checksum phf_codegen 0.7.22 (registry+https://github.com/rust-lang/crates.io-index)\" = \"4e4048fe7dd7a06b8127ecd6d3803149126e9b33c7558879846da3a63f734f2b\" \"checksum phf_generator 0.7.22 (registry+https://github.com/rust-lang/crates.io-index)\" = \"05a079dd052e7b674d21cb31cbb6c05efd56a2cd2827db7692e2f1a507ebd998\" \"checksum phf_shared 0.7.22 (registry+https://github.com/rust-lang/crates.io-index)\" = \"c2261d544c2bb6aa3b10022b0be371b9c7c64f762ef28c6f5d4f1ef6d97b5930\" \"checksum phf 0.7.24 (registry+https://github.com/rust-lang/crates.io-index)\" = \"b3da44b85f8e8dfaec21adae67f95d93244b2ecf6ad2a692320598dcc8e6dd18\" \"checksum phf_codegen 0.7.24 (registry+https://github.com/rust-lang/crates.io-index)\" = \"b03e85129e324ad4166b06b2c7491ae27fe3ec353af72e72cd1654c7225d517e\" \"checksum phf_generator 0.7.24 (registry+https://github.com/rust-lang/crates.io-index)\" = \"09364cc93c159b8b06b1f4dd8a4398984503483891b0c26b867cf431fb132662\" \"checksum phf_shared 0.7.24 (registry+https://github.com/rust-lang/crates.io-index)\" = \"234f71a15de2288bcb7e3b6515828d22af7ec8598ee6d24c3b526fa0a80b67a0\" \"checksum pkg-config 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)\" = \"676e8eb2b1b4c9043511a9b7bea0915320d7e502b0a079fb03f9635a5252b18c\" \"checksum polonius-engine 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)\" = \"8b24942fee141ea45628484a453762bb7e515099c3ec05fbeb76b7bf57b1aeed\" \"checksum precomputed-hash 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)\" = \"925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c\""}
{"_id":"q-en-rust-0d5d2ab69064cdbd025c4c5d2270adaaa5ef7a590f858771f82c16b6062bd972","text":"ty::TraitContainer(_) => self.defaultness.has_value() }; if provided { let constness = if cx.tcx.is_const_fn(self.def_id) { let constness = if cx.tcx.is_min_const_fn(self.def_id) { hir::Constness::Const } else { hir::Constness::NotConst"}
{"_id":"q-en-rust-0d7a72d871636e51fc349786c4f6f28aec22acd790411e7806823ce95560878a","text":" // check-pass #![feature(const_fn)] #![feature(type_alias_impl_trait)] type Foo = impl Fn() -> usize; const fn bar() -> Foo { || 0usize } const BAZR: Foo = bar(); fn main() {} "}
{"_id":"q-en-rust-0d7b1e199626ef25e771cbb39a590020bc0b5b836b6fc5abc85e8e179df80898","text":"error: repetition matches empty token tree --> $DIR/issue-5067.rs:4:8 --> $DIR/issue-5067.rs:9:8 | LL | ( $()* ) => {}; | ^^ error: repetition matches empty token tree --> $DIR/issue-5067.rs:6:8 --> $DIR/issue-5067.rs:11:8 | LL | ( $()+ ) => {}; | ^^ error: repetition matches empty token tree --> $DIR/issue-5067.rs:12:9 --> $DIR/issue-5067.rs:13:8 | LL | ( $()? ) => {}; | ^^ error: repetition matches empty token tree --> $DIR/issue-5067.rs:18:9 | LL | ( [$()*] ) => {}; | ^^ error: repetition matches empty token tree --> $DIR/issue-5067.rs:14:9 --> $DIR/issue-5067.rs:20:9 | LL | ( [$()+] ) => {}; | ^^ error: repetition matches empty token tree --> $DIR/issue-5067.rs:20:8 --> $DIR/issue-5067.rs:22:9 | LL | ( [$()?] ) => {}; | ^^ error: repetition matches empty token tree --> $DIR/issue-5067.rs:27:8 | LL | ( $($()* $(),* $(a)* $(a),* )* ) => {}; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: repetition matches empty token tree --> $DIR/issue-5067.rs:22:8 --> $DIR/issue-5067.rs:29:8 | LL | ( $($()* $(),* $(a)* $(a),* )+ ) => {}; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: repetition matches empty token tree --> $DIR/issue-5067.rs:28:12 --> $DIR/issue-5067.rs:31:8 | LL | ( $($()* $(),* $(a)* $(a),* )? ) => {}; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: repetition matches empty token tree --> $DIR/issue-5067.rs:33:8 | LL | ( $($()? $(),* $(a)? $(a),* )* ) => {}; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: repetition matches empty token tree --> $DIR/issue-5067.rs:35:8 | LL | ( $($()? $(),* $(a)? $(a),* )+ ) => {}; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: repetition matches empty token tree --> $DIR/issue-5067.rs:37:8 | LL | ( $($()? $(),* $(a)? $(a),* )? ) => {}; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: repetition matches empty token tree --> $DIR/issue-5067.rs:47:12 | LL | ( $(a $()+)* ) => {}; | ^^ error: repetition matches empty token tree --> $DIR/issue-5067.rs:30:12 --> $DIR/issue-5067.rs:49:12 | LL | ( $(a $()*)+ ) => {}; | ^^ error: repetition matches empty token tree --> $DIR/issue-5067.rs:38:18 --> $DIR/issue-5067.rs:51:12 | LL | ( $(a $()+)? ) => {}; | ^^ error: repetition matches empty token tree --> $DIR/issue-5067.rs:53:12 | LL | ( $(a $()?)+ ) => {}; | ^^ error: repetition matches empty token tree --> $DIR/issue-5067.rs:60:18 | LL | (a $e1:expr $($(, a $e2:expr)*)*) => ([$e1 $($(, $e2)*)*]); | ^^^^^^^^^^^^^^^^^^ error: repetition matches empty token tree --> $DIR/issue-5067.rs:50:8 --> $DIR/issue-5067.rs:71:8 | LL | ( $()* ) => {} LL | ( $()* ) => {}; | ^^ error: aborting due to 10 previous errors error: aborting due to 18 previous errors "}
{"_id":"q-en-rust-0dd6be5c9f16f74bf1a6c6da6236f0916245febcfb33ea12cbb9815fab824779","text":" // 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 or the MIT license // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. fn main() { let a = if true { 0 } else if false { //~^ ERROR if may be missing an else clause: expected `()`, found `` 1 }; } "}
{"_id":"q-en-rust-0df8e653ed055651c4371f93c833b2f4b415d168fcda8bb9b24acc150cdd97c7","text":"let incr_comp_session_dir: PathBuf = sess.incr_comp_session_dir().clone(); if sess.has_errors() { if sess.has_errors_or_delayed_span_bugs() { // If there have been any errors during compilation, we don't want to // publish this session directory. Rather, we'll just delete it."}
{"_id":"q-en-rust-0e1daf20db5ddd1a8c1aa8a12381bc407ee8e15553d1c66df5c588b161c946c1","text":"if (InstrProfileOutput) { Options.InstrProfileOutput = InstrProfileOutput; } // cargo run tests in multhreading mode by default // so use atomics for coverage counters Options.Atomic = true; MPM.addPass(InstrProfiling(Options, false)); } );"}
{"_id":"q-en-rust-0e2bdf9c568619ebcb3a86f6c4045d0b8d2dae6e66ef092c18fcf513c16b534c","text":" Subproject commit 99faef833f890fe89f1a959d89b951954118828b Subproject commit e9da96eb452aa65e79e2342be700544afe509440 "}
{"_id":"q-en-rust-0e48566a2fa392bb252a8e69feeafeca0c9a0a472aa82ac40c7df95a8d723477","text":"ty::TypeScheme { ty: ty, generics: ty_generics } } hir::ItemTy(ref t, ref generics) => { let ty_generics = ty_generics_for_type_or_impl(ccx, generics); let ty_generics = ty_generics_for_type(ccx, generics); let ty = ccx.icx(generics).to_ty(&ExplicitRscope, &t); ty::TypeScheme { ty: ty, generics: ty_generics } } hir::ItemEnum(ref ei, ref generics) => { let ty_generics = ty_generics_for_type_or_impl(ccx, generics); let ty_generics = ty_generics_for_type(ccx, generics); let substs = mk_item_substs(ccx, &ty_generics); let def = convert_enum_def(tcx, it, ei); let t = tcx.mk_enum(def, tcx.mk_substs(substs)); ty::TypeScheme { ty: t, generics: ty_generics } } hir::ItemStruct(ref si, ref generics) => { let ty_generics = ty_generics_for_type_or_impl(ccx, generics); let ty_generics = ty_generics_for_type(ccx, generics); let substs = mk_item_substs(ccx, &ty_generics); let def = convert_struct_def(tcx, it, si); let t = tcx.mk_struct(def, tcx.mk_substs(substs));"}
{"_id":"q-en-rust-0e4bd91afd4a6feaead9d227b5c1e23565d2a531269b389d1df5760b5c406da8","text":" error: character literal may only contain one codepoint --> $DIR/issue-64732.rs:3:17 | LL | let _foo = b'hello0'; | ^^^^^^^^^ help: if you meant to write a byte string literal, use double quotes | LL | let _foo = b\"hello0\"; | ^^^^^^^^^ error: character literal may only contain one codepoint --> $DIR/issue-64732.rs:6:16 | LL | let _bar = 'hello'; | ^^^^^^^ help: if you meant to write a `str` literal, use double quotes | LL | let _bar = \"hello\"; | ^^^^^^^ error: aborting due to 2 previous errors "}
{"_id":"q-en-rust-0e7c6b875fc10908f9bf27ef496355624e3d5f4b0b97583f2294c5e7fe2d41a6","text":"// aux-build:sepcomp_lib.rs // compile-flags: -C lto // no-prefer-dynamic // ignore-android FIXME #18800 extern crate sepcomp_lib; use sepcomp_lib::a::one;"}
{"_id":"q-en-rust-0e887d838764a1972c15e9173615c3375730d6031076ad8963f24d7847ba97c4","text":"path.push(id); } let path = ast::Path { span: mk_sp(lo, self.span.hi), span: mk_sp(path_lo, self.span.hi), global: false, segments: path.move_iter().map(|identifier| { ast::PathSegment {"}
{"_id":"q-en-rust-0e8b07fa7b6c296f02159fe3a2fbc61462cf3148b27994f9e3d5f88f217063d0","text":"--lldb-python $$(CFG_LLDB_PYTHON) --gdb-version=\"$(CFG_GDB_VERSION)\" --lldb-version=\"$(CFG_LLDB_VERSION)\" --llvm-version=\"$$(LLVM_VERSION_$(3))\" --android-cross-path=$(CFG_ARM_LINUX_ANDROIDEABI_NDK) --adb-path=$(CFG_ADB) --adb-test-dir=$(CFG_ADB_TEST_DIR) "}
{"_id":"q-en-rust-0ed6abe0721448ed2dca502272afd31dd2418eed9c89abfe3ca51ea3f96e43d3","text":" // Regression test of #43913. // run-rustfix #![feature(trait_alias)] #![allow(bare_trait_objects, dead_code)] type Strings = Iterator; struct Struct(S); //~^ ERROR: expected trait, found type alias `Strings` fn main() {} "}
{"_id":"q-en-rust-0ed7d23ee46fa0e21547952b20d93dd9d21b16aeb052ef2ca248bcb7f46671ae","text":"buffer: String, } impl core::fmt::Write for Buffer { #[inline] fn write_str(&mut self, s: &str) -> fmt::Result { self.buffer.write_str(s) } #[inline] fn write_char(&mut self, c: char) -> fmt::Result { self.buffer.write_char(c) } #[inline] fn write_fmt(self: &mut Self, args: fmt::Arguments<'_>) -> fmt::Result { self.buffer.write_fmt(args) } } impl Buffer { crate fn empty_from(v: &Buffer) -> Buffer { Buffer { for_html: v.for_html, buffer: String::new() }"}
{"_id":"q-en-rust-0eef5edc5c916fe9203164412354a33b1f201b27df6a21274fd64a76e911ec8e","text":" // compile-pass // edition:2018 // // Tests that we properly handle StorageDead/StorageLives for temporaries // created in async loop bodies. #![feature(async_await)] async fn bar() -> Option<()> { Some(()) } async fn listen() { while let Some(_) = bar().await { String::new(); } } fn main() { listen(); } "}
{"_id":"q-en-rust-0ef8414ffc3284932838bf1044ad28f01855be326d1d6d22e53341117bf59bdd","text":"enum Enum1 { Variant1(isize), Variant2 //~ ERROR: variant is never used Variant2 //~ ERROR: variant is never constructed } enum Enum2 { Variant3(bool), #[allow(dead_code)] Variant4(isize), Variant5 { _x: isize }, //~ ERROR: variant is never used: `Variant5` Variant6(isize), //~ ERROR: variant is never used: `Variant6` Variant5 { _x: isize }, //~ ERROR: variant is never constructed: `Variant5` Variant6(isize), //~ ERROR: variant is never constructed: `Variant6` _Variant7, }"}
{"_id":"q-en-rust-0f1969ccea2bc6f79dacef9394c7cb524472df090530ce94f76790a27d768461","text":" // 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 or the MIT license // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. // Test that type IDs correctly account for higher-rank lifetimes // Also acts as a regression test for an ICE (issue #19791) #![feature(unboxed_closures)] use std::intrinsics::TypeId; fn main() { // Bare fns { let a = TypeId::of::(); let b = TypeId::of:: fn(&'static int, &'a int)>(); let c = TypeId::of:: fn(&'a int, &'b int)>(); let d = TypeId::of:: fn(&'b int, &'a int)>(); assert!(a != b); assert!(a != c); assert!(a != d); assert!(b != c); assert!(b != d); assert_eq!(c, d); // Make sure De Bruijn indices are handled correctly let e = TypeId::of:: fn(fn(&'a int) -> &'a int)>(); let f = TypeId::of:: fn(&'a int) -> &'a int)>(); assert!(e != f); } // Stack closures { let a = TypeId::of::<|&'static int, &'static int|>(); let b = TypeId::of:: |&'static int, &'a int|>(); let c = TypeId::of:: |&'a int, &'b int|>(); let d = TypeId::of:: |&'b int, &'a int|>(); assert!(a != b); assert!(a != c); assert!(a != d); assert!(b != c); assert!(b != d); assert_eq!(c, d); // Make sure De Bruijn indices are handled correctly let e = TypeId::of:: |(|&'a int| -> &'a int)|>(); let f = TypeId::of::<|for<'a> |&'a int| -> &'a int|>(); assert!(e != f); } // Boxed unboxed closures { let a = TypeId::of::>(); let b = TypeId::of:: Fn(&'static int, &'a int)>>(); let c = TypeId::of:: Fn(&'a int, &'b int)>>(); let d = TypeId::of:: Fn(&'b int, &'a int)>>(); assert!(a != b); assert!(a != c); assert!(a != d); assert!(b != c); assert!(b != d); assert_eq!(c, d); // Make sure De Bruijn indices are handled correctly let e = TypeId::of:: Fn(Box &'a int>)>>(); let f = TypeId::of:: Fn(&'a int) -> &'a int>)>>(); assert!(e != f); } // Raw unboxed closures // Note that every unboxed closure has its own anonymous type, // so no two IDs should equal each other, even when compatible { let a = id(|&: _: &int, _: &int| {}); let b = id(|&: _: &int, _: &int| {}); assert!(a != b); } fn id(_: T) -> TypeId { TypeId::of::() } } "}
{"_id":"q-en-rust-0f27be22c7aac66b89414555878e434ae5d9333abb5cd26af29cda6fcb3299e2","text":"if !non_trait.is_empty() { let render_mode = match what { AssocItemRender::All => { write!(w, \"
\", trait_, type_)?; RenderMode::ForDeref { mut_: deref_mut_ } } };"}
{"_id":"q-en-rust-0f27cf39a30889d5b3ba5a26739aa2078914e5fe187fb03943c45adeaca5442a","text":" Subproject commit 7799d03de85bcc1a7437f65d4f7adfbb267d2acb Subproject commit 79d659e5699fbf7db5b4819e9a442fb3f550472a "}
{"_id":"q-en-rust-0f27d73249838a969672d1064e2e10663cf117e600ad8880468f3c67f4aa6289","text":"_ => {} } } // Similar to operators, indexing is always assumed to be overloaded // Here, correct cases where an indexing expression can be simplified // to use builtin indexing because the index type is known to be // usize-ish fn fix_index_builtin_expr(&mut self, e: &hir::Expr) { if let hir::ExprIndex(ref base, ref index) = e.node { let mut tables = self.fcx.tables.borrow_mut(); match tables.expr_ty_adjusted(&base).sty { // All valid indexing looks like this ty::TyRef(_, ty::TypeAndMut { ty: ref base_ty, .. }) => { let index_ty = tables.expr_ty_adjusted(&index); let index_ty = self.fcx.resolve_type_vars_if_possible(&index_ty); if base_ty.builtin_index().is_some() && index_ty == self.fcx.tcx.types.usize { // Remove the method call record tables.type_dependent_defs_mut().remove(e.hir_id); tables.node_substs_mut().remove(e.hir_id); tables.adjustments_mut().get_mut(base.hir_id).map(|a| { // Discard the need for a mutable borrow match a.pop() { // Extra adjustment made when indexing causes a drop // of size information - we need to get rid of it // Since this is \"after\" the other adjustment to be // discarded, we do an extra `pop()` Some(Adjustment { kind: Adjust::Unsize, .. }) => { // So the borrow discard actually happens here a.pop(); }, _ => {} } }); } }, // Might encounter non-valid indexes at this point, so there // has to be a fall-through _ => {}, } } } } /////////////////////////////////////////////////////////////////////////// // Impl of Visitor for Resolver //"}
{"_id":"q-en-rust-0f7ef2f19c87a1e13193f68f8dda09f9b59027131fe892c8096285ff2d9f6578","text":"Err(err) } /// Try to recover from an unbraced const argument whose first token [could begin a type][ty]. /// /// [ty]: token::Token::can_begin_type pub(crate) fn recover_unbraced_const_arg_that_can_begin_ty( &mut self, mut snapshot: SnapshotParser<'a>, ) -> Option
> { match snapshot.parse_expr_res(Restrictions::CONST_EXPR, None) { // Since we don't know the exact reason why we failed to parse the type or the // expression, employ a simple heuristic to weed out some pathological cases. Ok(expr) if let token::Comma | token::Gt = snapshot.token.kind => { self.restore_snapshot(snapshot); Some(expr) } Ok(_) => None, Err(err) => { err.cancel(); None } } }
/// Creates a dummy const argument, and reports that the expression must be enclosed in braces pub fn dummy_const_arg_needs_braces( &self,"}
{"_id":"q-en-rust-0f89bea2e0ede6909132881d4cb2efcddef67ede39002fa633a75604972c32e4","text":"referent_ty: Ty<'tcx>) -> Rc> { // We can only make objects from sized types. let sized_obligation = traits::obligation_for_builtin_bound( fcx.tcx(), traits::ObligationCause::new(span, traits::ObjectSized), referent_ty, ty::BoundSized); match sized_obligation { Ok(sized_obligation) => { fcx.register_obligation(sized_obligation); } Err(ErrorReported) => { } } // This is just for better error reporting. Kinda goofy. The object type stuff // needs some refactoring so there is a more convenient type to pass around. let object_trait_ty ="}
{"_id":"q-en-rust-0f9fe503e1cf0dee4cdf1742fda38749a96419dc5649ab1ff2c5b87c7ff06e3f","text":"))), ) } ty::CoroutineClosure(did, _args) => { // FIXME(async_closures): Recover the proper error signature let inputs = tcx .closure_user_provided_sig(did.expect_local()) .value .skip_binder() .inputs(); let err = Ty::new_error(tcx, guar); (inputs.iter().map(|_| err).collect(), err, None) ty::CoroutineClosure(did, args) => { let args = args.as_coroutine_closure(); let sig = tcx.liberate_late_bound_regions( def_id.to_def_id(), args.coroutine_closure_sig(), ); let self_ty = match args.kind() { ty::ClosureKind::Fn => { Ty::new_imm_ref(tcx, tcx.lifetimes.re_erased, closure_ty) } ty::ClosureKind::FnMut => { Ty::new_mut_ref(tcx, tcx.lifetimes.re_erased, closure_ty) } ty::ClosureKind::FnOnce => closure_ty, }; ( [self_ty].into_iter().chain(sig.tupled_inputs_ty.tuple_fields()).collect(), sig.to_coroutine( tcx, args.parent_args(), args.kind_ty(), tcx.coroutine_for_closure(*did), Ty::new_error(tcx, guar), ), None, ) } ty::Error(_) => (vec![closure_ty, closure_ty], closure_ty, None), kind => {"}
{"_id":"q-en-rust-0fc234de1be245d65e370a388bc3268963e313a82160710b34c4928846428086","text":"pub is_cleanup: bool, } #[derive(Clone, Debug, RustcEncodable, RustcDecodable, HashStable)] pub struct Terminator<'tcx> { pub source_info: SourceInfo, pub kind: TerminatorKind<'tcx>, } #[derive(Clone, RustcEncodable, RustcDecodable, HashStable, PartialEq)] pub enum TerminatorKind<'tcx> { /// Block should have one successor in the graph; we jump there. Goto { target: BasicBlock }, /// Operand evaluates to an integer; jump depending on its value /// to one of the targets, and otherwise fallback to `otherwise`. SwitchInt { /// The discriminant value being tested. discr: Operand<'tcx>, /// The type of value being tested. /// This is always the same as the type of `discr`. /// FIXME: remove this redundant information. Currently, it is relied on by pretty-printing. switch_ty: Ty<'tcx>, /// Possible values. The locations to branch to in each case /// are found in the corresponding indices from the `targets` vector. values: Cow<'tcx, [u128]>, /// Possible branch sites. The last element of this vector is used /// for the otherwise branch, so targets.len() == values.len() + 1 /// should hold. // // This invariant is quite non-obvious and also could be improved. // One way to make this invariant is to have something like this instead: // // branches: Vec<(ConstInt, BasicBlock)>, // otherwise: Option // exhaustive if None // // However we’ve decided to keep this as-is until we figure a case // where some other approach seems to be strictly better than other. targets: Vec, }, /// Indicates that the landing pad is finished and unwinding should /// continue. Emitted by `build::scope::diverge_cleanup`. Resume, /// Indicates that the landing pad is finished and that the process /// should abort. Used to prevent unwinding for foreign items. Abort, /// Indicates a normal return. The return place should have /// been filled in before this executes. This can occur multiple times /// in different basic blocks. Return, /// Indicates a terminator that can never be reached. Unreachable, /// Drop the `Place`. Drop { place: Place<'tcx>, target: BasicBlock, unwind: Option }, /// Drop the `Place` and assign the new value over it. This ensures /// that the assignment to `P` occurs *even if* the destructor for /// place unwinds. Its semantics are best explained by the /// elaboration: /// /// ``` /// BB0 { /// DropAndReplace(P <- V, goto BB1, unwind BB2) /// } /// ``` /// /// becomes /// /// ``` /// BB0 { /// Drop(P, goto BB1, unwind BB2) /// } /// BB1 { /// // P is now uninitialized /// P <- V /// } /// BB2 { /// // P is now uninitialized -- its dtor panicked /// P <- V /// } /// ``` DropAndReplace { place: Place<'tcx>, value: Operand<'tcx>, target: BasicBlock, unwind: Option, }, /// Block ends with a call of a converging function. Call { /// The function that’s being called. func: Operand<'tcx>, /// Arguments the function is called with. /// These are owned by the callee, which is free to modify them. /// This allows the memory occupied by \"by-value\" arguments to be /// reused across function calls without duplicating the contents. args: Vec>, /// Destination for the return value. If some, the call is converging. destination: Option<(Place<'tcx>, BasicBlock)>, /// Cleanups to be done if the call unwinds. cleanup: Option, /// `true` if this is from a call in HIR rather than from an overloaded /// operator. True for overloaded function call. from_hir_call: bool, /// This `Span` is the span of the function, without the dot and receiver /// (e.g. `foo(a, b)` in `x.foo(a, b)` fn_span: Span, }, /// Jump to the target if the condition has the expected value, /// otherwise panic with a message and a cleanup target. Assert { cond: Operand<'tcx>, expected: bool, msg: AssertMessage<'tcx>, target: BasicBlock, cleanup: Option, }, /// A suspend point. Yield { /// The value to return. value: Operand<'tcx>, /// Where to resume to. resume: BasicBlock, /// The place to store the resume argument in. resume_arg: Place<'tcx>, /// Cleanup to be done if the generator is dropped at this suspend point. drop: Option, }, /// Indicates the end of the dropping of a generator. GeneratorDrop, /// A block where control flow only ever takes one real path, but borrowck /// needs to be more conservative. FalseEdge { /// The target normal control flow will take. real_target: BasicBlock, /// A block control flow could conceptually jump to, but won't in /// practice. imaginary_target: BasicBlock, }, /// A terminator for blocks that only take one path in reality, but where we /// reserve the right to unwind in borrowck, even if it won't happen in practice. /// This can arise in infinite loops with no function calls for example. FalseUnwind { /// The target normal control flow will take. real_target: BasicBlock, /// The imaginary cleanup block link. This particular path will never be taken /// in practice, but in order to avoid fragility we want to always /// consider it in borrowck. We don't want to accept programs which /// pass borrowck only when `panic=abort` or some assertions are disabled /// due to release vs. debug mode builds. This needs to be an `Option` because /// of the `remove_noop_landing_pads` and `no_landing_pads` passes. unwind: Option, }, /// Block ends with an inline assembly block. This is a terminator since /// inline assembly is allowed to diverge. InlineAsm { /// The template for the inline assembly, with placeholders. template: &'tcx [InlineAsmTemplatePiece], /// The operands for the inline assembly, as `Operand`s or `Place`s. operands: Vec>, /// Miscellaneous options for the inline assembly. options: InlineAsmOptions, /// Source spans for each line of the inline assembly code. These are /// used to map assembler errors back to the line in the source code. line_spans: &'tcx [Span], /// Destination block after the inline assembly returns, unless it is /// diverging (InlineAsmOptions::NORETURN). destination: Option, }, } /// Information about an assertion failure. #[derive(Clone, RustcEncodable, RustcDecodable, HashStable, PartialEq)] pub enum AssertKind {"}
{"_id":"q-en-rust-0fcb0a09168a90a7ca4f2103a2d4ddf39e47f105b6ee3f125bf512cff9649aab","text":"}; (respan(self.prev_span, Constness::NotConst), unsafety, abi) }; self.expect_keyword(keywords::Fn)?; if !self.eat_keyword(keywords::Fn) { // It is possible for `expect_one_of` to recover given the contents of // `self.expected_tokens`, therefore, do not use `self.unexpected()` which doesn't // account for this. if !self.expect_one_of(&[], &[])? { unreachable!() } } Ok((constness, unsafety, asyncness, abi)) }"}
{"_id":"q-en-rust-0fff251219050a5e87dad457ac585ea2a0d5b5357fdfea18880730a34256bdf7","text":" // build-pass pub trait Foo { type FooAssoc; } pub struct Bar { id: F::FooAssoc } pub struct Baz; impl Foo for Baz { type FooAssoc = usize; } static mut MY_FOO: Bar = Bar { id: 0 }; fn main() {} "}
{"_id":"q-en-rust-10025d3d8da87d3d0015a51ca7681e6fd4b40eb3fe3a35328793a380abfcacfa","text":" #![feature(fn_traits, unboxed_closures)] fn test FnOnce<(&'x str,)>>(_: F) {} struct Compose(F,G); impl FnOnce<(T,)> for Compose where F: FnOnce<(T,)>, G: FnOnce<(F::Output,)> { type Output = G::Output; extern \"rust-call\" fn call_once(self, (x,): (T,)) -> G::Output { (self.1)((self.0)(x)) } } struct Str<'a>(&'a str); fn mk_str<'a>(s: &'a str) -> Str<'a> { Str(s) } fn main() { let _: for<'a> fn(&'a str) -> Str<'a> = mk_str; // expected concrete lifetime, found bound lifetime parameter 'a let _: for<'a> fn(&'a str) -> Str<'a> = Str; //~^ ERROR: mismatched types test(|_: &str| {}); test(mk_str); // expected concrete lifetime, found bound lifetime parameter 'x test(Str); //~ ERROR: type mismatch in function arguments test(Compose(|_: &str| {}, |_| {})); test(Compose(mk_str, |_| {})); // internal compiler error: cannot relate bound region: // ReLateBound(DebruijnIndex { depth: 2 }, // BrNamed(DefId { krate: 0, node: DefIndex(6) => test::'x }, 'x(65))) //<= ReSkolemized(0, // BrNamed(DefId { krate: 0, node: DefIndex(6) => test::'x }, 'x(65))) test(Compose(Str, |_| {})); } "}
{"_id":"q-en-rust-100807ac89f6ee5b6869deb643870650a93c24a1e6707cc8d8fcdbd14659b494","text":"impl EntryKind { fn def_kind(&self) -> DefKind { match *self { EntryKind::AnonConst(..) => DefKind::AnonConst, EntryKind::Const(..) => DefKind::Const, EntryKind::AssocConst(..) => DefKind::AssocConst, EntryKind::ImmStatic"}
{"_id":"q-en-rust-1049c3aa82411c5176a6165571a9a17adb00bed2d66819c26269c16eee686c31","text":"// These cases don't actually need a destination ExprKind::Assign { .. } | ExprKind::AssignOp { .. } | ExprKind::Continue { .. } | ExprKind::Break { .. } | ExprKind::LlvmInlineAsm { .. } | ExprKind::Return { .. } => { | ExprKind::LlvmInlineAsm { .. } => { unpack!(block = this.stmt_expr(block, expr, None)); this.cfg.push_assign_unit(block, source_info, destination, this.hir.tcx()); block.unit() } ExprKind::Continue { .. } | ExprKind::Break { .. } | ExprKind::Return { .. } => { unpack!(block = this.stmt_expr(block, expr, None)); // No assign, as these have type `!`. block.unit() } // Avoid creating a temporary ExprKind::VarRef { .. } | ExprKind::SelfRef"}
{"_id":"q-en-rust-105073e15a0a25908cd437601f619994ed0bb0aee5efa52dbbb862f7da9485f9","text":"call_locations, no_emit_shared: false, html_no_source, force_unstable_if_unmarked, }; Some((options, render_options)) }"}
{"_id":"q-en-rust-105fee5e8cff6ca966c8e7276a2157c592068a11adf4dd26a5bbd829cba828a2","text":"COPY host-x86_64/dist-x86_64-linux/build-binutils.sh /tmp/ RUN ./build-binutils.sh # libssh2 (a dependency of Cargo) requires cmake 2.8.11 or higher but CentOS # only has 2.6.4, so build our own COPY host-x86_64/dist-x86_64-linux/build-cmake.sh /tmp/ RUN ./build-cmake.sh # Build a version of gcc capable of building LLVM 6 # Need at least GCC 5.1 to compile LLVM nowadays COPY host-x86_64/dist-x86_64-linux/build-gcc.sh /tmp/ RUN ./build-gcc.sh RUN ./build-gcc.sh && apt-get remove -y gcc g++ # CentOS 5.5 has Python 2.4 by default, but LLVM needs 2.7+ # Debian 6 has Python 2.6 by default, but LLVM needs 2.7+ COPY host-x86_64/dist-x86_64-linux/build-python.sh /tmp/ RUN ./build-python.sh # Now build LLVM+Clang 7, afterwards configuring further compilations to use the # LLVM needs cmake 3.4.3 or higher, and is planning to raise to 3.13.4. COPY host-x86_64/dist-x86_64-linux/build-cmake.sh /tmp/ RUN ./build-cmake.sh # Now build LLVM+Clang, afterwards configuring further compilations to use the # clang/clang++ compilers. COPY host-x86_64/dist-x86_64-linux/build-clang.sh host-x86_64/dist-x86_64-linux/llvm-project-centos.patch /tmp/ COPY host-x86_64/dist-x86_64-linux/build-clang.sh /tmp/ RUN ./build-clang.sh ENV CC=clang CXX=clang++ # Apparently CentOS 5.5 desn't have `git` in yum, but we're gonna need it for # cloning, so download and build it here. COPY host-x86_64/dist-x86_64-linux/build-git.sh /tmp/ RUN ./build-git.sh # for sanitizers, we need kernel headers files newer than the ones CentOS ships # with so we install newer ones here COPY host-x86_64/dist-x86_64-linux/build-headers.sh /tmp/ RUN ./build-headers.sh # OpenSSL requires a more recent version of perl # with so we install newer ones here COPY host-x86_64/dist-x86_64-linux/build-perl.sh /tmp/ RUN ./build-perl.sh COPY scripts/sccache.sh /scripts/ RUN sh /scripts/sccache.sh"}
{"_id":"q-en-rust-106177426ea9b8d2d6e29126acbd5818d4c82b572cb2284a15b0ef340ee9db3e","text":"return f.c; } struct quad_floats { float a; float b; float c; float d; }; float get_c_exhaust_sysv64_ints( void *a, void *b, void *c, void *d, void *e, void *f, // `f` used the last integer register, so `g` goes on the stack. // It also used to bring the \"count of available integer registers\" down to // `-1` which broke the next SSE-only aggregate argument (`h`) - see #62350. void *g, struct quad_floats h ) { return h.c; } // Calculates the average of `(x + y) / n` where x: i64, y: f64. There must be exactly n pairs // passed as variadic arguments. There are two versions of this function: the // variadic one, and the one that takes a `va_list`."}
{"_id":"q-en-rust-1084c75c59da6446ca30f5b408c1b6db79df7c0615b1690244d3dc2ce7f218da","text":"\"checksum quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)\" = \"7a6e920b65c65f10b2ae65c831a81a073a89edd28c7cce89475bff467ab4167a\" \"checksum quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)\" = \"faf4799c5d274f3868a4aae320a0a182cbd2baee377b378f080e16a23e9d80db\" \"checksum racer 2.1.23 (registry+https://github.com/rust-lang/crates.io-index)\" = \"94dbdea3d959d8f76a2e303b3eadf107fd76da886b231291e649168613d432fb\" \"checksum rand 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)\" = \"552840b97013b1a26992c11eac34bdd778e464601a4c2054b5f0bff7c6761293\" \"checksum rand 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)\" = \"ae9d223d52ae411a33cf7e54ec6034ec165df296ccd23533d671a28252b6f66a\" \"checksum rand_chacha 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)\" = \"771b009e3a508cb67e8823dda454aaa5368c7bc1c16829fb77d3e980440dd34a\" \"checksum rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)\" = \"0905b6b7079ec73b314d4c748701f6931eb79fd97c668caa3f1899b22b32c6db\""}
{"_id":"q-en-rust-10d10602b04a3ef145ccc2259ed47f38aa819e08630c3be92d7d8cd4fb17d92f","text":" error: `#[doc(hidden)]` is ignored on trait impl items --> $DIR/unused-attr-doc-hidden.rs:29:5 | LL | #[doc(hidden)] | ^^^^^^^^^^^^^^ help: remove this attribute | note: the lint level is defined here --> $DIR/unused-attr-doc-hidden.rs:4:9 | LL | #![deny(unused_attributes)] | ^^^^^^^^^^^^^^^^^ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: whether the impl item is `doc(hidden)` or not entirely depends on the corresponding trait item error: `#[doc(hidden)]` is ignored on trait impl items --> $DIR/unused-attr-doc-hidden.rs:34:5 | LL | #[doc(hidden)] | ^^^^^^^^^^^^^^ help: remove this attribute | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: whether the impl item is `doc(hidden)` or not entirely depends on the corresponding trait item error: `#[doc(hidden)]` is ignored on trait impl items --> $DIR/unused-attr-doc-hidden.rs:39:11 | LL | #[doc(hidden, alias = \"aka\")] | ^^^^^^-- | | | help: remove this attribute | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: whether the impl item is `doc(hidden)` or not entirely depends on the corresponding trait item error: `#[doc(hidden)]` is ignored on trait impl items --> $DIR/unused-attr-doc-hidden.rs:44:27 | LL | #[doc(alias = \"this\", hidden,)] | ^^^^^^- | | | help: remove this attribute | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: whether the impl item is `doc(hidden)` or not entirely depends on the corresponding trait item error: `#[doc(hidden)]` is ignored on trait impl items --> $DIR/unused-attr-doc-hidden.rs:49:11 | LL | #[doc(hidden, hidden)] | ^^^^^^-- | | | help: remove this attribute | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: whether the impl item is `doc(hidden)` or not entirely depends on the corresponding trait item error: `#[doc(hidden)]` is ignored on trait impl items --> $DIR/unused-attr-doc-hidden.rs:49:19 | LL | #[doc(hidden, hidden)] | ^^^^^^ help: remove this attribute | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: whether the impl item is `doc(hidden)` or not entirely depends on the corresponding trait item error: aborting due to 6 previous errors "}
{"_id":"q-en-rust-110741c6b5677bb67eda59812bd0aafcb890919d102f39238e5c95969a5b756b","text":"target_family: Some(\"windows\".to_string()), is_like_windows: true, is_like_msvc: true, // set VSLANG to 1033 can prevent link.exe from using // language packs, and avoid generating Non-UTF-8 error // messages if a link error occurred. link_env: vec![(\"VSLANG\".to_string(), \"1033\".to_string())], pre_link_args: args, crt_static_allows_dylibs: true, crt_static_respected: true,"}
{"_id":"q-en-rust-11243c62c9a4c30fe352906f58d969c203106793ba93bd6e3165739950d08453","text":"python2.7 \"$BUILD_SOURCESDIRECTORY/src/tools/publish_toolstate.py\" \"$(git rev-parse HEAD)\" \"$(git log --format=%s -n1 HEAD)\" \"\" \"\" cd .. rm -rf rust-toolstate condition: and(succeeded(), eq(variables['IMAGE'], 'mingw-check')) condition: and(succeeded(), not(variables.SKIP_JOB), eq(variables['IMAGE'], 'mingw-check')) displayName: Verify the publish_toolstate script works - bash: |"}
{"_id":"q-en-rust-113ac596f1a902840ef1a41ade27791428e565026fd1d1a4f85ce2cffa04f2a6","text":"#![crate_name = \"foo\"] // The goal of this test is to answer that it won't be generated as a list because // The goal of this test is to ensure that it won't be generated as a list because // block doc comments can have their lines starting with a star. // @has foo/fn.foo.html"}
{"_id":"q-en-rust-117ead81c5c5a12b2cc0a204e022a8c2aa81e16d804408a33d1ca50e958d83dc","text":" error[E0271]: type mismatch resolving ` as Stream>::Item == Repr` --> $DIR/issue-89008.rs:38:43 | LL | fn line_stream<'a, Repr>(&'a self) -> Self::LineStreamFut<'a, Repr> { | ---- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type mismatch resolving ` as Stream>::Item == Repr` | | | this type parameter | note: expected this to be `()` --> $DIR/issue-89008.rs:17:17 | LL | type Item = (); | ^^ = note: expected unit type `()` found type parameter `Repr` error: aborting due to previous error For more information about this error, try `rustc --explain E0271`. "}
{"_id":"q-en-rust-117eebd8751e91a66e57d85f498c7eb7e01a6acce7f7b33c0a0e8899276e292e","text":"}).is_some(); render_deref_methods(w, cx, impl_, containing_item, has_deref_mut)?; } write!(w, \"
\")?; for i in &traits { let did = i.trait_did().unwrap(); let assoc_link = AssocItemLink::GotoSource(did, &i.inner_impl().provided_trait_methods);"}
{"_id":"q-en-rust-11944b91a421c181de55055f1ac46ae3182ed97e575e6d5b0934cc99bcbc2a0b","text":"let externs = options.externs.clone(); let render_options = options.render_options.clone(); let scrape_examples_options = options.scrape_examples_options.clone(); let document_private = options.render_options.document_private; let config = core::create_config(options); interface::create_compiler_and_run(config, |compiler| {"}
{"_id":"q-en-rust-11b01c667be70424468853892b4ccc6adf321ab2d9b8085908d5c6c5fc8fbfbf","text":" PRINT-ATTR INPUT (DISPLAY): fn foo < T > () where T : Copy + { } PRINT-ATTR INPUT (DEBUG): TokenStream [ Ident { ident: \"fn\", span: $DIR/trailing-plus.rs:11:1: 11:3 (#0), }, Ident { ident: \"foo\", span: $DIR/trailing-plus.rs:11:4: 11:7 (#0), }, Punct { ch: '<', spacing: Alone, span: $DIR/trailing-plus.rs:11:7: 11:8 (#0), }, Ident { ident: \"T\", span: $DIR/trailing-plus.rs:11:8: 11:9 (#0), }, Punct { ch: '>', spacing: Alone, span: $DIR/trailing-plus.rs:11:9: 11:10 (#0), }, Group { delimiter: Parenthesis, stream: TokenStream [], span: $DIR/trailing-plus.rs:11:10: 11:12 (#0), }, Ident { ident: \"where\", span: $DIR/trailing-plus.rs:11:13: 11:18 (#0), }, Ident { ident: \"T\", span: $DIR/trailing-plus.rs:11:19: 11:20 (#0), }, Punct { ch: ':', spacing: Alone, span: $DIR/trailing-plus.rs:11:20: 11:21 (#0), }, Ident { ident: \"Copy\", span: $DIR/trailing-plus.rs:11:22: 11:26 (#0), }, Punct { ch: '+', spacing: Alone, span: $DIR/trailing-plus.rs:11:27: 11:28 (#0), }, Group { delimiter: Brace, stream: TokenStream [], span: $DIR/trailing-plus.rs:11:29: 12:2 (#0), }, ] "}
{"_id":"q-en-rust-11c5af70f5255ad93610927202ab6cbfa928c1815d89357cace1a535af551950","text":"} #[test] #[cfg_attr(any(target_os = \"vxworks\", target_os = \"android\"), ignore)] #[cfg_attr(any(target_os = \"vxworks\"), ignore)] fn exit_reported_right() { let p = if cfg!(target_os = \"windows\") { Command::new(\"cmd\").args(&[\"/C\", \"exit 1\"]).spawn() } else { Command::new(\"false\").spawn() shell_cmd().arg(\"-c\").arg(\"false\").spawn() }; assert!(p.is_ok()); let mut p = p.unwrap();"}
{"_id":"q-en-rust-11f674b93e650bd09eb718ee1935aa4cf0ddf92a907f6132a40ffb333eadfc6f","text":"is_valid = false; } sym::hidden if !self.check_doc_hidden(attr, meta_index, meta, hir_id, target, ) => { is_valid = false; } // no_default_passes: deprecated // passes: deprecated // plugins: removed, but rustdoc warns about it itself"}
{"_id":"q-en-rust-11fec1de0fe6ffa4ec36df220522ccce1d09b37c48b2d6d93810b65601eb9e03","text":"if let Ok(snippet) = self.infcx.tcx.sess.source_map().span_to_snippet(span) { let is_option = move_ty.starts_with(\"std::option::Option\"); let is_result = move_ty.starts_with(\"std::result::Result\"); if is_option || is_result { if (is_option || is_result) && use_spans.map_or(true, |v| !v.for_closure()) { err.span_suggestion( span, &format!(\"consider borrowing the `{}`'s content\", if is_option {"}
{"_id":"q-en-rust-124ae1d0d60ea6c4ed12e8cc4e8029ddb2e68c62bcbd6b226f0a095956db3c94","text":" // test for `doc(hidden)` with impl parameters in the same crate. #![crate_name = \"foo\"] #[doc(hidden)] pub enum HiddenType {} #[doc(hidden)] pub trait HiddenTrait {} pub enum MyLibType {} // @!has foo/enum.MyLibType.html '//*[@id=\"impl-From%3CHiddenType%3E\"]' 'impl From for MyLibType' impl From for MyLibType { fn from(it: HiddenType) -> MyLibType { match it {} } } pub struct T(T); // @!has foo/enum.MyLibType.html '//*[@id=\"impl-From%3CT%3CT%3CT%3CT%3CHiddenType%3E%3E%3E%3E%3E\"]' 'impl From>>>> for MyLibType' impl From>>>> for MyLibType { fn from(it: T>>>) -> MyLibType { todo!() } } // @!has foo/enum.MyLibType.html '//*[@id=\"impl-HiddenTrait\"]' 'impl HiddenTrait for MyLibType' impl HiddenTrait for MyLibType {} // @!has foo/struct.T.html '//*[@id=\"impl-From%3CMyLibType%3E\"]' 'impl From for T>>>' impl From for T>>> { fn from(it: MyLibType) -> T>>> { match it {} } } "}
{"_id":"q-en-rust-12523b24b38378b1aaa0011d5b2e3dbb2829fb3327421e8eab73aaa6d70926ea","text":"return; } if !ensure_stage1_toolchain_placeholder_exists(stage_path) { println!( \"Failed to create a template for stage 1 toolchain or confirm that it already exists\" ); return; } if try_link_toolchain(&stage_path[..]) { println!( \"Added `stage1` rustup toolchain; try `cargo +stage1 build` on a separate rust project to run a newly-built toolchain\""}
{"_id":"q-en-rust-1261c7af83a613c7255ffa495f65fea0f00a8c942e011345f8411fa1c81342e7","text":"legacy_imports: LegacyMacroImports, allow_shadowing: bool) { let import_macro = |this: &mut Self, name, ext: Rc<_>, span| { this.used_crates.insert(module.def_id().unwrap().krate); if let SyntaxExtension::NormalTT(..) = *ext { this.macro_names.insert(name); }"}
{"_id":"q-en-rust-129123802837bbca9194f2dcb6878411b1732e96a8fee60da4c0fa70e2d8e983","text":"use crate::mir::*; use crate::ty::subst::SubstsRef; use crate::ty::{CanonicalUserTypeAnnotation, Ty}; use crate::ty::{self, CanonicalUserTypeAnnotation, Ty}; use rustc_span::Span; macro_rules! make_mir_visitor {"}
{"_id":"q-en-rust-129e6bb2a16baf33d442f0791e8075bad593a4e3c6b9d62b12067b7eb0d35b82","text":"self.lookup_and_handle_method(expr.hir_id); } hir::ExprKind::Assign(ref left, ref right, ..) => { // Ignore write to field self.visit_expr(base_expr(left)); self.handle_assign(left); self.visit_expr(right); return; }"}
{"_id":"q-en-rust-12cb7f158005d219d5bd66fd18ea214f6610f184244e62839db92b6b9fc31370","text":"if let Some(ref dir) = build.lldb_python_dir { cmd.arg(\"--lldb-python-dir\").arg(dir); } let llvm_config = build.llvm_config(target); let llvm_version = output(Command::new(&llvm_config).arg(\"--version\")); cmd.arg(\"--llvm-version\").arg(llvm_version); cmd.args(&build.flags.args);"}
{"_id":"q-en-rust-137818e8154a6d83d16198c5048574dc886b09f01ebefcdaf33d5d5dd47d89b7","text":"} } fn collect_predicates_for_types(&mut self, obligation: &TraitObligation<'tcx>, trait_def_id: ast::DefId, types: Vec>) -> Vec> { let derived_cause = match self.tcx().lang_items.to_builtin_kind(trait_def_id) { Some(_) => { self.derived_cause(obligation, BuiltinDerivedObligation) }, None => { self.derived_cause(obligation, ImplDerivedObligation) } }; let normalized = project::normalize_with_depth(self, obligation.cause.clone(), obligation.recursion_depth + 1, &types); let obligations = normalized.value.iter().map(|&nested_ty| { // the obligation might be higher-ranked, e.g. for<'a> &'a // int : Copy. In that case, we will wind up with // late-bound regions in the `nested` vector. So for each // one we instantiate to a skolemized region, do our work // to produce something like `&'0 int : Copy`, and then // re-bind it. This is a bit of busy-work but preserves // the invariant that we only manipulate free regions, not // bound ones. self.infcx.try(|snapshot| { let (skol_ty, skol_map) = self.infcx().skolemize_late_bound_regions(&ty::Binder(nested_ty), snapshot); let skol_predicate = util::predicate_for_trait_def( self.tcx(), derived_cause.clone(), trait_def_id, obligation.recursion_depth + 1, skol_ty); match skol_predicate { Ok(skol_predicate) => Ok(self.infcx().plug_leaks(skol_map, snapshot, &skol_predicate)), Err(ErrorReported) => Err(ErrorReported) } }) }).collect::>, _>>(); match obligations { Ok(mut obls) => { obls.push_all(normalized.obligations.as_slice()); obls }, Err(ErrorReported) => Vec::new() } } /////////////////////////////////////////////////////////////////////////// // CONFIRMATION //"}
{"_id":"q-en-rust-1394bb016615f14e9711772c107035b40ab0b9af9f59792e471af641c7d69a08","text":"#[primary_span] pub span: Span, } #[derive(Diagnostic)] #[diag(hir_analysis::missing_parentheses_in_range, code = \"E0689\")] pub struct MissingParentheseInRange { #[primary_span] #[label(hir_analysis::missing_parentheses_in_range)] pub span: Span, pub ty_str: String, pub method_name: String, #[subdiagnostic] pub add_missing_parentheses: Option, } #[derive(Subdiagnostic)] #[multipart_suggestion_verbose( hir_analysis::add_missing_parentheses_in_range, applicability = \"maybe-incorrect\" )] pub struct AddMissingParenthesesInRange { pub func_name: String, #[suggestion_part(code = \"(\")] pub left: Span, #[suggestion_part(code = \")\")] pub right: Span, } "}
{"_id":"q-en-rust-13b5603afcb898f293a062a855402b885c3f9721fac1fbe82f16b8794ff81ca4","text":"(config.mode == common::Pretty && parse_name_directive(ln, \"ignore-pretty\")) || (config.target != config.host && parse_name_directive(ln, \"ignore-cross-compile\")) || ignore_gdb(config, ln) || ignore_lldb(config, ln); ignore_gdb(config, ln) || ignore_lldb(config, ln) || ignore_llvm(config, ln); props.should_fail = props.should_fail || parse_name_directive(ln, \"should-fail\"); });"}
{"_id":"q-en-rust-13c8449b72d935996ecdb93e0e36281099f72f9bcfdaaf9e20f8246f4e881e79","text":"| ^^^ type aliases cannot be used as traits | help: you might have meant to use `#![feature(trait_alias)]` instead of a `type` alias --> $DIR/issue-3907.rs:5:1 | LL | type Foo = dyn issue_3907::Foo; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ LL | trait Foo = dyn issue_3907::Foo; | help: consider importing this trait instead | LL | use issue_3907::Foo;"}
{"_id":"q-en-rust-13ccc30dca59000fe2f5b84f957e43d38761ed620e67902e89c50c95ffcd5a56","text":"// `public_items` map, so we can skip inserting into the // paths map if there was already an entry present and we're // not a public item. if !self.cache.paths.contains_key(&item.item_id.expect_def_id()) let item_def_id = item.item_id.expect_def_id(); if !self.cache.paths.contains_key(&item_def_id) || self .cache .effective_visibilities .is_directly_public(self.tcx, item.item_id.expect_def_id()) .is_directly_public(self.tcx, item_def_id) { self.cache.paths.insert( item.item_id.expect_def_id(), (self.cache.stack.clone(), item.type_()), ); self.cache .paths .insert(item_def_id, (self.cache.stack.clone(), item.type_())); } } }"}
{"_id":"q-en-rust-13d80c7d2b66c4a10eaf927088224400fe5942bc1a480eb9bec85ce896b2e96b","text":" // Copyright 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 or the MIT license // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. struct Foo; impl Foo { fn putc(&self, b: u8) { } fn puts(&self, s: &str) { for byte in s.bytes() { self.putc(byte) } } } fn main() {} "}
{"_id":"q-en-rust-13d9467847b1fabbd5159243dead28df3fa7d831945e992e280136d55bcfd8f2","text":" // check-pass // aux-build:test-macros.rs // compile-flags: -Z span-debug #![no_std] // Don't load unnecessary hygiene information from std extern crate std; #[macro_use] extern crate test_macros; macro_rules! empty_stmt { ($s:stmt) => { print_bang!($s); // Currently, all attributes are ignored // on an empty statement #[print_attr] #[rustc_dummy(first)] #[rustc_dummy(second)] $s } } fn main() { empty_stmt!(;); } "}
{"_id":"q-en-rust-13ddc92944b64a8c0ff9340c269286f2b556e94680bc56e27e4abd4b75c04f85","text":" #!/bin/sh CARGO_TARGET_DIR=$(pwd)/target/ export CARGO_TARGET_DIR echo 'Deprecated! `util/dev` usage is deprecated, please use `cargo dev` instead.' cd clippy_dev && cargo run -- \"$@\" "}
{"_id":"q-en-rust-13e4a92f6d2c0dd1625c678ce538da02f7fdc7024f2225f9b28680fdda3ffc9a","text":"id: AllocId, liveness: AllocCheck, ) -> InterpResult<'static, (Size, Align)> { // Regular allocations. if let Ok(alloc) = self.get(id) { return Ok((Size::from_bytes(alloc.bytes.len() as u64), alloc.align)); } // Function pointers. if let Ok(_) = self.get_fn_alloc(id) { return if let AllocCheck::Dereferencable = liveness { // The caller requested no function pointers. err!(DerefFunctionPointer) } else { Ok((Size::ZERO, Align::from_bytes(1).unwrap())) }; } // Foreign statics. // Can't do this in the match argument, we may get cycle errors since the lock would // be held throughout the match. let alloc = self.tcx.alloc_map.lock().get(id); match alloc { Some(GlobalAlloc::Static(did)) => { assert!(self.tcx.is_foreign_item(did)); // Use size and align of the type let ty = self.tcx.type_of(did); let layout = self.tcx.layout_of(ParamEnv::empty().and(ty)).unwrap(); return Ok((layout.size, layout.align.abi)); // Don't use `self.get` here as that will // a) cause cycles in case `id` refers to a static // b) duplicate a static's allocation in miri match self.alloc_map.get_or(id, || Err(())) { Ok((_, alloc)) => Ok((Size::from_bytes(alloc.bytes.len() as u64), alloc.align)), Err(()) => { // Not a local allocation, check the global `tcx.alloc_map`. // Can't do this in the match argument, we may get cycle errors since the lock would // be held throughout the match. let alloc = self.tcx.alloc_map.lock().get(id); match alloc { Some(GlobalAlloc::Static(did)) => { // Use size and align of the type. let ty = self.tcx.type_of(did); let layout = self.tcx.layout_of(ParamEnv::empty().and(ty)).unwrap(); Ok((layout.size, layout.align.abi)) }, Some(GlobalAlloc::Memory(alloc)) => // Need to duplicate the logic here, because the global allocations have // different associated types than the interpreter-local ones. Ok((Size::from_bytes(alloc.bytes.len() as u64), alloc.align)), Some(GlobalAlloc::Function(_)) => { if let AllocCheck::Dereferencable = liveness { // The caller requested no function pointers. err!(DerefFunctionPointer) } else { Ok((Size::ZERO, Align::from_bytes(1).unwrap())) } }, // The rest must be dead. None => if let AllocCheck::MaybeDead = liveness { // Deallocated pointers are allowed, we should be able to find // them in the map. Ok(*self.dead_alloc_map.get(&id) .expect(\"deallocated pointers should all be recorded in `dead_alloc_map`\")) } else { err!(DanglingPointerDeref) }, } } _ => {} } // The rest must be dead. if let AllocCheck::MaybeDead = liveness { // Deallocated pointers are allowed, we should be able to find // them in the map. Ok(*self.dead_alloc_map.get(&id) .expect(\"deallocated pointers should all be recorded in `dead_alloc_map`\")) } else { err!(DanglingPointerDeref) } }"}
{"_id":"q-en-rust-142f0cf17e4e9f9909838a614522c35e244acd08ebef51fc9a4e35bbc263aded","text":" // We used to not lower the extra `b @ ..` into `b @ _` which meant that no type // was registered for the binding `b` although it passed through resolve. // This resulted in an ICE (#69103). fn main() { let [a @ .., b @ ..] = &mut [1, 2]; //~^ ERROR `..` can only be used once per slice pattern b; let [.., c @ ..] = [1, 2]; //~^ ERROR `..` can only be used once per slice pattern c; // This never ICEd, but let's make sure it won't regress either. let (.., d @ ..) = (1, 2); //~^ ERROR `..` patterns are not allowed here d; } "}
{"_id":"q-en-rust-1476952c0e31f4d798aba2a64caf6b80cd9dc9449c5bbee1b353525a93565783","text":"replace_late_bound_regions(tcx, value, |_, _| ty::ReStatic).0 } /// Rewrite any late-bound regions so that they are anonymous. Region numbers are /// assigned starting at 1 and increasing monotonically in the order traversed /// by the fold operation. /// /// The chief purpose of this function is to canonicalize regions so that two /// `FnSig`s or `TraitRef`s which are equivalent up to region naming will become /// structurally identical. For example, `for<'a, 'b> fn(&'a int, &'b int)` and /// `for<'a, 'b> fn(&'b int, &'a int)` will become identical after anonymization. pub fn anonymize_late_bound_regions<'tcx, HR>(tcx: &ctxt<'tcx>, sig: &HR) -> HR where HR: HigherRankedFoldable<'tcx> { let mut counter = 0; replace_late_bound_regions(tcx, sig, |_, db| { counter += 1; ReLateBound(db, BrAnon(counter)) }).0 } /// Replaces the late-bound-regions in `value` that are bound by `value`. pub fn replace_late_bound_regions<'tcx, HR, F>( tcx: &ty::ctxt<'tcx>,"}
{"_id":"q-en-rust-147951eaa9bd7cfba78e9f8c8d45cd93951bc1476e28afc0795f5c7e403b33d4","text":"set -ex source shared.sh curl https://cmake.org/files/v3.6/cmake-3.6.3.tar.gz | tar xzf - CMAKE=3.13.4 curl -L https://github.com/Kitware/CMake/releases/download/v$CMAKE/cmake-$CMAKE.tar.gz | tar xzf - mkdir cmake-build cd cmake-build hide_output ../cmake-3.6.3/configure --prefix=/rustroot hide_output ../cmake-$CMAKE/configure --prefix=/rustroot hide_output make -j10 hide_output make install cd .. rm -rf cmake-build rm -rf cmake-3.6.3 rm -rf cmake-$CMAKE "}
{"_id":"q-en-rust-147dffc943fd49ae271f8afec684d54454d52cf25b0b8aca666df73ad7a875d7","text":"// preventing the latter from being formatted. ignore_fmt.add(&format!(\"!/{}\", untracked_path)).expect(&untracked_path); } if !check && paths.is_empty() { if let Some(files) = get_modified_files(build) { for file in files { println!(\"formatting modified file {file}\"); ignore_fmt.add(&format!(\"/{file}\")).expect(&file); } } } } else { println!(\"Not in git tree. Skipping git-aware format checks\"); }"}
{"_id":"q-en-rust-14c52b8e629e72772ca4dc2b044a38c2f15599465e9284f3147d3cdce9402c86","text":"LL | #[deprecated(since(b), note = \"a\")] //~ ERROR incorrect meta item | ^^^^^^^^ error[E0565]: literal in `deprecated` value must be a string --> $DIR/deprecation-sanity.rs:19:25 | LL | #[deprecated(note = b\"test\")] //~ ERROR literal in `deprecated` value must be a string | ^^^^^^^ help: consider removing the prefix: `\"test\"` error[E0565]: item in `deprecated` must be a key/value pair --> $DIR/deprecation-sanity.rs:22:18 | LL | #[deprecated(\"test\")] //~ ERROR item in `deprecated` must be a key/value pair | ^^^^^^ error[E0550]: multiple deprecated attributes --> $DIR/deprecation-sanity.rs:22:1 --> $DIR/deprecation-sanity.rs:28:1 | LL | fn multiple1() { } //~ ERROR multiple deprecated attributes | ^^^^^^^^^^^^^^^^^^ error[E0538]: multiple 'since' items --> $DIR/deprecation-sanity.rs:24:27 --> $DIR/deprecation-sanity.rs:30:27 | LL | #[deprecated(since = \"a\", since = \"b\", note = \"c\")] //~ ERROR multiple 'since' items | ^^^^^^^^^^^ error: aborting due to 7 previous errors error: aborting due to 9 previous errors Some errors occurred: E0538, E0541, E0550, E0551. Some errors occurred: E0538, E0541, E0550, E0551, E0565. For more information about an error, try `rustc --explain E0538`."}
{"_id":"q-en-rust-14cf61dbcc35a90cdf855f783fa77785d7ead83d62a6529ee884578029d5070d","text":"// ensure that we issue lints in a repeatable order def_ids.sort_by_cached_key(|&def_id| self.tcx.def_path_hash(def_id)); for def_id in def_ids { 'lifetimes: for def_id in def_ids { debug!(\"check_uses_for_lifetimes_defined_by_scope: def_id = {:?}\", def_id); let lifetimeuseset = self.lifetime_uses.remove(&def_id);"}
{"_id":"q-en-rust-15052fd3d471f2621a63ec2189436b98de1596d1d3cc34eb16ec9e211036424c","text":"_ => self.get(item.def_id), }; // Update levels of nested things. match item.kind { hir::ItemKind::Enum(ref def, _) => { for variant in def.variants { let variant_level = self.update_with_hir_id(variant.id, item_level); if let Some(ctor_hir_id) = variant.data.ctor_hir_id() { self.update_with_hir_id(ctor_hir_id, item_level); } for field in variant.data.fields() { self.update_with_hir_id(field.hir_id, variant_level); } } } hir::ItemKind::Impl(ref impl_) => { for impl_item_ref in impl_.items { if impl_.of_trait.is_some() || self.tcx.visibility(impl_item_ref.id.def_id) == ty::Visibility::Public { self.update(impl_item_ref.id.def_id, item_level); } } } hir::ItemKind::Trait(.., trait_item_refs) => { for trait_item_ref in trait_item_refs { self.update(trait_item_ref.id.def_id, item_level); } } hir::ItemKind::Struct(ref def, _) | hir::ItemKind::Union(ref def, _) => { if let Some(ctor_hir_id) = def.ctor_hir_id() { self.update_with_hir_id(ctor_hir_id, item_level); } for field in def.fields() { if field.vis.node.is_pub() { self.update_with_hir_id(field.hir_id, item_level); } } } hir::ItemKind::Macro(ref macro_def) => { self.update_reachability_from_macro(item.def_id, macro_def); } hir::ItemKind::ForeignMod { items, .. } => { for foreign_item in items { if self.tcx.visibility(foreign_item.id.def_id) == ty::Visibility::Public { self.update(foreign_item.id.def_id, item_level); } } } hir::ItemKind::OpaqueTy(..) | hir::ItemKind::Use(..) | hir::ItemKind::Static(..) | hir::ItemKind::Const(..) | hir::ItemKind::GlobalAsm(..) | hir::ItemKind::TyAlias(..) | hir::ItemKind::Mod(..) | hir::ItemKind::TraitAlias(..) | hir::ItemKind::Fn(..) | hir::ItemKind::ExternCrate(..) => {} } // Mark all items in interfaces of reachable items as reachable. match item.kind { // The interface is empty. hir::ItemKind::ExternCrate(..) => {} hir::ItemKind::Macro(..) | hir::ItemKind::ExternCrate(..) => {} // All nested items are checked by `visit_item`. hir::ItemKind::Mod(..) => {} // Handled in the access level of in rustc_resolve hir::ItemKind::Use(..) => {} // The interface is empty. hir::ItemKind::GlobalAsm(..) => {}"}
{"_id":"q-en-rust-15089504226b79a5c4300aa64f93c6ac382a52ff85c27bc06f8b6ade9fa45739","text":"\"rls-rustc\", \"rls-span\", \"rls-vfs\", \"rustc-serialize\", \"rustc-workspace-hack\", \"rustc_tools_util 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)\", \"rustfmt-nightly\","}
{"_id":"q-en-rust-150ea12ccafcc8157808cb267a308a756fbddc843199d19f0fffd9a80defae87","text":"ByteStr(_) | ByteStrRaw(..) => \"byte string\" } } // See comments in `interpolated_to_tokenstream` for why we care about // *probably* equal here rather than actual equality fn probably_equal_for_proc_macro(&self, other: &Lit) -> bool { mem::discriminant(self) == mem::discriminant(other) } } pub(crate) fn ident_can_begin_expr(ident: ast::Ident, is_raw: bool) -> bool {"}
{"_id":"q-en-rust-151ac6c88f7b9404df2e4be8d434aad6413bbc0409ce38e0fa63d69db71ba992","text":"impl Scalar { pub fn is_bool(&self) -> bool { if let Int(I8, _) = self.value { self.valid_range == (0..=1) } else { false } matches!(self.value, Int(I8, false)) && self.valid_range == (0..=1) } /// Returns the valid range as a `x..y` range."}
{"_id":"q-en-rust-151ff45c4b2d52ed12a15b8d93a7cc65ee3d42ef2cbb0d27eb79e2da6975d9fc","text":" // check-pass struct Sqlite {} trait HasArguments<'q> { type Arguments; } impl<'q> HasArguments<'q> for Sqlite { type Arguments = std::marker::PhantomData<&'q ()>; } fn foo() { let _ = ::Arguments::default(); } fn main() {} "}
{"_id":"q-en-rust-15277cc96da04b9002d17734570ab6610639f7b0e928fe7eda3bd3add7d5ba31","text":"// Get the `hir::Param` to verify whether it already has any bounds. // We do this to avoid suggesting code that ends up as `T: FooBar`, // instead we suggest `T: Foo + Bar` in that case. let mut has_bounds = None; let mut impl_trait = false; if let Node::GenericParam(ref param) = hir.get(id) { let kind = ¶m.kind; if let hir::GenericParamKind::Type { synthetic: Some(_), .. } = kind { // We've found `fn foo(x: impl Trait)` instead of // `fn foo(x: T)`. We want to suggest the correct // `fn foo(x: impl Trait + TraitBound)` instead of // `fn foo(x: T)`. (See #63706.) impl_trait = true; has_bounds = param.bounds.get(1); } else { has_bounds = param.bounds.get(0); match hir.get(id) { Node::GenericParam(ref param) => { let mut impl_trait = false; let has_bounds = if let hir::GenericParamKind::Type { synthetic: Some(_), .. } = ¶m.kind { // We've found `fn foo(x: impl Trait)` instead of // `fn foo(x: T)`. We want to suggest the correct // `fn foo(x: impl Trait + TraitBound)` instead of // `fn foo(x: T)`. (#63706) impl_trait = true; param.bounds.get(1) } else { param.bounds.get(0) }; let sp = hir.span(id); let sp = if let Some(first_bound) = has_bounds { // `sp` only covers `T`, change it so that it covers // `T:` when appropriate sp.until(first_bound.span()) } else { sp }; // FIXME: contrast `t.def_id` against `param.bounds` to not suggest // traits already there. That can happen when the cause is that // we're in a const scope or associated function used as a method. err.span_suggestions( sp, &message(format!( \"restrict type parameter `{}` with\", param.name.ident().as_str(), )), candidates.iter().map(|t| format!( \"{}{} {}{}\", param.name.ident().as_str(), if impl_trait { \" +\" } else { \":\" }, self.tcx.def_path_str(t.def_id), if has_bounds.is_some() { \" + \"} else { \"\" }, )), Applicability::MaybeIncorrect, ); suggested = true; } Node::Item(hir::Item { kind: hir::ItemKind::Trait(.., bounds, _), ident, .. }) => { let (sp, sep, article) = if bounds.is_empty() { (ident.span.shrink_to_hi(), \":\", \"a\") } else { (bounds.last().unwrap().span().shrink_to_hi(), \" +\", \"another\") }; err.span_suggestions( sp, &message(format!(\"add {} supertrait for\", article)), candidates.iter().map(|t| format!( \"{} {}\", sep, self.tcx.def_path_str(t.def_id), )), Applicability::MaybeIncorrect, ); suggested = true; } _ => {} } let sp = hir.span(id); // `sp` only covers `T`, change it so that it covers `T:` when appropriate. let sp = if let Some(first_bound) = has_bounds { sp.until(first_bound.span()) } else { sp }; // FIXME: contrast `t.def_id` against `param.bounds` to not suggest traits // already there. That can happen when the cause is that we're in a const // scope or associated function used as a method. err.span_suggestions( sp, &msg[..], candidates.iter().map(|t| format!( \"{}{} {}{}\", param, if impl_trait { \" +\" } else { \":\" }, self.tcx.def_path_str(t.def_id), if has_bounds.is_some() { \" + \" } else { \"\" }, )), Applicability::MaybeIncorrect, ); suggested = true; } }; } if !suggested { let mut msg = message(if let Some(param) = param_type { format!(\"restrict type parameter `{}` with\", param) } else { \"implement\".to_string() }); for (i, trait_info) in candidates.iter().enumerate() { msg.push_str(&format!( \"ncandidate #{}: `{}`\","}
{"_id":"q-en-rust-152ef0dcbdfa79e97039bc66e1cc534b38b8269d3609048baba769b6a75ed39b","text":"fn get_or_create_type_parameter_def<'a,'tcx>(ccx: &CrateCtxt<'a,'tcx>, ast_generics: &hir::Generics, space: ParamSpace, index: u32) index: u32, allow_defaults: bool) -> ty::TypeParameterDef<'tcx> { let param = &ast_generics.ty_params[index as usize];"}
{"_id":"q-en-rust-15613aaa604b2e22e3f5063e5932b8f32f55441ac433ba0e9459635296c5057b","text":" Subproject commit f5532b22b5d741f3ea207b5b07e3e1ca63476f9b Subproject commit 02b3734a5ba6de984eb5a02c50860cc014e58d56 "}
{"_id":"q-en-rust-15a3e0493b22d74b467ea924aa2b604cfb8cc83de7db00d663dd49fada6fb35c","text":"/// # Examples /// /// ``` /// # #![feature(duration_as_u128)] /// use std::time::Duration; /// /// let duration = Duration::new(5, 730023852); /// assert_eq!(duration.as_nanos(), 5730023852); /// ``` #[unstable(feature = \"duration_as_u128\", issue = \"50202\")] #[stable(feature = \"duration_as_u128\", since = \"1.33.0\")] #[inline] pub const fn as_nanos(&self) -> u128 { self.secs as u128 * NANOS_PER_SEC as u128 + self.nanos as u128"}
{"_id":"q-en-rust-15b3ec5ff926166b8a62fd2080f512600ea2bfb7ec0569c25d793d4eb9c01846","text":"// appears to be the most interesting point to report to the // user via an even more ad-hoc guess. categorized_path.sort_by(|p0, p1| p0.category.cmp(&p1.category)); debug!(\"`: sorted_path={:#?}\", categorized_path); debug!(\"best_blame_constraint: sorted_path={:#?}\", categorized_path); categorized_path.remove(0) }"}
{"_id":"q-en-rust-15c96de8dbc9c5bc132db48d90227a00a55932ad8be34db4328577150f956a45","text":" // test for trait methods with `doc(hidden)`. #![crate_name = \"foo\"] // @has foo/trait.Trait.html // @!has - '//*[@id=\"associatedtype.Foo\"]' 'type Foo' // @has - '//*[@id=\"associatedtype.Bar\"]' 'type Bar' // @!has - '//*[@id=\"tymethod.f\"]' 'fn f()' // @has - '//*[@id=\"tymethod.g\"]' 'fn g()' pub trait Trait { #[doc(hidden)] type Foo; type Bar; #[doc(hidden)] fn f(); fn g(); } // @has foo/struct.S.html // @!has - '//*[@id=\"associatedtype.Foo\"]' 'type Foo' // @has - '//*[@id=\"associatedtype.Bar\"]' 'type Bar' // @!has - '//*[@id=\"method.f\"]' 'fn f()' // @has - '//*[@id=\"method.g\"]' 'fn g()' pub struct S; impl Trait for S { type Foo = (); type Bar = (); fn f() {} fn g() {} } "}
{"_id":"q-en-rust-15d527b7f4321c8e8fc999a87b297ed9b24425594e910c879326e853d3736f57","text":" //@ revisions: enable-backchain disable-backchain //@ assembly-output: emit-asm //@ compile-flags: -O --crate-type=lib --target=s390x-unknown-linux-gnu //@ needs-llvm-components: systemz //@[enable-backchain] compile-flags: -Ctarget-feature=+backchain //@[disable-backchain] compile-flags: -Ctarget-feature=-backchain #![feature(no_core, lang_items)] #![no_std] #![no_core] #[lang = \"sized\"] trait Sized {} extern \"C\" { fn extern_func(); } // CHECK-LABEL: test_backchain #[no_mangle] extern \"C\" fn test_backchain() -> i32 { // Here we try to match if backchain register is saved to the parameter area (stored in r15/sp) // And also if a new parameter area (160 bytes) is allocated for the upcoming function call // enable-backchain: lgr [[REG1:.*]], %r15 // enable-backchain-NEXT: aghi %r15, -160 // enable-backchain: stg [[REG1]], 0(%r15) // disable-backchain: aghi %r15, -160 // disable-backchain-NOT: stg %r{{.*}}, 0(%r15) unsafe { extern_func(); } // enable-backchain-NEXT: brasl %r{{.*}}, extern_func@PLT // disable-backchain: brasl %r{{.*}}, extern_func@PLT // Make sure that the expected return value is written into %r2 (return register): // enable-backchain-NEXT: lghi %r2, 1 // disable-backchain: lghi %r2, 0 #[cfg(target_feature = \"backchain\")] { 1 } #[cfg(not(target_feature = \"backchain\"))] { 0 } // CHECK: br %r{{.*}} } "}
{"_id":"q-en-rust-15d5a57c183b64aa9ccf88c9a530a20d6dff2d534343621378492cdb89380f5f","text":"use syntax::ast; use syntax::source_map::Spanned; use syntax::ptr::P; use syntax::util::lev_distance::find_best_match_for_name; use syntax_pos::Span; impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {"}
{"_id":"q-en-rust-15deeb8ee15aac73134bd0925d5880113562dce69872a43b72c071ff7e786ef5","text":" error[E0384]: cannot assign twice to immutable variable `a` --> $DIR/tainted-promoteds.rs:7:5 | LL | let a = 0; | - | | | first assignment to `a` | help: consider making this binding mutable: `mut a` LL | a = &0 * &1 * &2 * &3; | ^^^^^^^^^^^^^^^^^^^^^ cannot assign twice to immutable variable error: aborting due to previous error For more information about this error, try `rustc --explain E0384`. "}
{"_id":"q-en-rust-15f0d6d5fc2a59f13c73d92e9baf5e30f7a7941331bf977cf3132e9ff65dc9bd","text":"for attr in &data.attrs { match attr.style { crate::AttrStyle::Outer => { assert!( inner_attrs.len() == 0, \"Found outer attribute {:?} after inner attrs {:?}\", attr, inner_attrs ); outer_attrs.push(attr); } crate::AttrStyle::Inner => {"}
{"_id":"q-en-rust-1649de114e0184f26680540e5a7b84646d406e873497c922a37c0208153e26de","text":"// option. This file may not be copied, modified, or distributed // except according to those terms. // compile-flags:--no-defaults --passes \"collapse-docs\" --passes \"unindent-comments\" // compile-flags:--no-defaults --passes collapse-docs --passes unindent-comments // @has issue_15347/fn.foo.html #[doc(hidden)]"}
{"_id":"q-en-rust-16655e1b66b04d4ea8eab2e01e78493177e16bbabf6080fec191548dc7724e81","text":"E0495, // cannot infer an appropriate lifetime due to conflicting requirements E0496, // .. name `..` shadows a .. name that is already in scope E0498, // malformed plugin attribute E0514, // metadata version mismatch }"}
{"_id":"q-en-rust-16908103d656a7e8caafc360c3a03e40f2e2802b8e6cb8b19fdd64574447602a","text":"} fn build_free<'tcx>(tcx: &ty::ctxt<'tcx>, cfg: &mut CFG<'tcx>, unit_temp: Lvalue<'tcx>, data: &FreeData<'tcx>, target: BasicBlock) -> BasicBlock { target: BasicBlock) -> Terminator<'tcx> { let free_func = tcx.lang_items.box_free_fn() .expect(\"box_free language item is missing\"); let substs = tcx.mk_substs(Substs::new( VecPerParamSpace::new(vec![], vec![], vec![data.item_ty]), VecPerParamSpace::new(vec![], vec![], vec![]) )); let block = cfg.start_new_cleanup_block(); cfg.terminate(block, Terminator::Call { Terminator::Call { func: Operand::Constant(Constant { span: data.span, ty: tcx.lookup_item_type(free_func).ty.subst(tcx, substs),"}
{"_id":"q-en-rust-16bb75bbb26b749ad23ffb8ea05165527fd9ab9b1f2a9885ed2e34ea094e4b71","text":"LL | type Bar<'a>: Deref::Bar<'a, Target = Self>>; | +++ error: aborting due to previous error error[E0229]: associated type bindings are not allowed here --> $DIR/issue-85347.rs:3:46 | LL | type Bar<'a>: Deref::Bar>; | ^^^^^^^^^^^^^ associated type not allowed here error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0107`. Some errors have detailed explanations: E0107, E0229. For more information about an error, try `rustc --explain E0107`. "}
{"_id":"q-en-rust-16d68052fd2cb310025b7a41095218d4545ffda9d7c0f567a1460ed6733fdbb7","text":"fn in_call( cx: &ConstCx<'_, 'tcx>, callee: &Operand<'tcx>, _args: &[Operand<'tcx>], args: &[Operand<'tcx>], _return_ty: Ty<'tcx>, ) -> bool { if cx.mode == Mode::Fn {"}
{"_id":"q-en-rust-1706519923258630ab29825dfc58c657f904a5fc8074f5c50a62d046d97db7fe","text":"} fn is_try_block(&self) -> bool { self.token.is_keyword(kw::Try) && self.look_ahead(1, |t| *t == token::OpenDelim(token::Brace)) && self.token.uninterpolated_span().rust_2018() && // Prevent `while try {} {}`, `if try {} {} else {}`, etc. !self.restrictions.contains(Restrictions::NO_STRUCT_LITERAL) self.token.is_keyword(kw::Try) && self.look_ahead(1, |t| *t == token::OpenDelim(token::Brace)) && self.token.uninterpolated_span().rust_2018() } /// Parses an `async move? {...}` expression."}
{"_id":"q-en-rust-1739ad79d5d5978d156c5e0a786c4d82c814831d4e0e7b97c395af95e72f9739","text":"[submodule \"src/llvm-project\"] path = src/llvm-project url = https://github.com/rust-lang/llvm-project.git branch = rustc/16.0-2023-03-06 branch = rustc/16.0-2023-04-05 [submodule \"src/doc/embedded-book\"] path = src/doc/embedded-book url = https://github.com/rust-embedded/book.git"}
{"_id":"q-en-rust-1756ab34c2b79b6b0c758d9918ed5c37801e4ce9be3908823ec059127275d5dc","text":"/// # Examples /// /// ``` /// # #![feature(duration_as_u128)] /// use std::time::Duration; /// /// let duration = Duration::new(5, 730023852); /// assert_eq!(duration.as_millis(), 5730); /// ``` #[unstable(feature = \"duration_as_u128\", issue = \"50202\")] #[stable(feature = \"duration_as_u128\", since = \"1.33.0\")] #[inline] pub const fn as_millis(&self) -> u128 { self.secs as u128 * MILLIS_PER_SEC as u128 + (self.nanos / NANOS_PER_MILLI) as u128"}
{"_id":"q-en-rust-176315d5a0122161d9680572e4e585423c07b3dc98ca1407ded8e6bfa369b2e8","text":" // Copyright 2017 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 or the MIT license // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. // Issue 46112: An extern crate pub reexporting libcore was causing // paths rooted from `std` to be misrendered in the diagnostic output. // ignore-windows // aux-build:xcrate_issue_46112_rexport_core.rs extern crate xcrate_issue_46112_rexport_core; fn test(r: Result"}
{"_id":"q-en-rust-176ea369b80c081c7a7aef44a2f65211c6f9f61b4ebbcf66458acde2791897ed","text":"#[license = \"MIT/ASL2\"]; #[crate_type = \"dylib\"]; #[crate_type = \"rlib\"]; #[doc(html_logo_url = \"http://www.rust-lang.org/logos/rust-logo-128x128-blk.png\", #[doc(html_logo_url = \"http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png\", html_favicon_url = \"http://www.rust-lang.org/favicon.ico\", html_root_url = \"http://static.rust-lang.org/doc/master\")];"}
{"_id":"q-en-rust-1774f0e8eb76e0ef4d3d05a580363baeba5227e1f7acc557015ad64d8a1cf378","text":"verbose_help); } fn print_wall_help() { println!(\" The flag `-Wall` does not exist in `rustc`. Most useful lints are enabled by default. Use `rustc -W help` to see all available lints. It's more common to put warning settings in the crate root using `#![warn(LINT_NAME)]` instead of using the command line flag directly. \"); } fn describe_lints(sess: &Session, lint_store: &lint::LintStore, loaded_plugins: bool) { println!(\" Available lint options:"}
{"_id":"q-en-rust-17aeeb92dc3ce347f2a985e84acbd978e2e9e71098e23984634d54617886b14c","text":"Command::new(\"mkdir\").arg(\"./\").output().unwrap() }; assert!(status.code() == Some(1)); assert!(status.code().is_some()); assert!(status.code() != Some(0)); assert_eq!(stdout, Vec::new()); assert!(!stderr.is_empty()); } #[test] #[cfg_attr(any(target_os = \"vxworks\", target_os = \"android\"), ignore)] #[cfg_attr(any(target_os = \"vxworks\"), ignore)] fn test_finish_once() { let mut prog = if cfg!(target_os = \"windows\") { Command::new(\"cmd\").args(&[\"/C\", \"exit 1\"]).spawn().unwrap() } else { Command::new(\"false\").spawn().unwrap() shell_cmd().arg(\"-c\").arg(\"false\").spawn().unwrap() }; assert!(prog.wait().unwrap().code() == Some(1)); } #[test] #[cfg_attr(any(target_os = \"vxworks\", target_os = \"android\"), ignore)] #[cfg_attr(any(target_os = \"vxworks\"), ignore)] fn test_finish_twice() { let mut prog = if cfg!(target_os = \"windows\") { Command::new(\"cmd\").args(&[\"/C\", \"exit 1\"]).spawn().unwrap() } else { Command::new(\"false\").spawn().unwrap() shell_cmd().arg(\"-c\").arg(\"false\").spawn().unwrap() }; assert!(prog.wait().unwrap().code() == Some(1)); assert!(prog.wait().unwrap().code() == Some(1)); } #[test] #[cfg_attr(any(target_os = \"vxworks\", target_os = \"android\"), ignore)] #[cfg_attr(any(target_os = \"vxworks\"), ignore)] fn test_wait_with_output_once() { let prog = if cfg!(target_os = \"windows\") { Command::new(\"cmd\").args(&[\"/C\", \"echo hello\"]).stdout(Stdio::piped()).spawn().unwrap() } else { Command::new(\"echo\").arg(\"hello\").stdout(Stdio::piped()).spawn().unwrap() shell_cmd().arg(\"-c\").arg(\"echo hello\").stdout(Stdio::piped()).spawn().unwrap() }; let Output { status, stdout, stderr } = prog.wait_with_output().unwrap();"}
{"_id":"q-en-rust-17bc4b8f3ab8a001fd1556625ffd51ad22a96a5ca5393992630f5079e00aa84a","text":"expanded_cache: FxHashMap::default(), primary_def_id: Some(def_id), found_recursion: false, found_any_recursion: false, check_recursion: true, tcx: self, };"}
{"_id":"q-en-rust-17c781cacd66802b6112c5021f0409d0d7ff700eee6d076b1be18bfe870f8f80","text":"Box::new(MaybeUninit::uninit()) } // FIXME: add a test for a bigger box. Currently broken, see // https://github.com/rust-lang/rust/issues/58201. // https://github.com/rust-lang/rust/issues/58201 #[no_mangle] pub fn box_uninitialized2() -> Box> { // CHECK-LABEL: @box_uninitialized2 // CHECK-NOT: store // CHECK-NOT: alloca // CHECK-NOT: memcpy // CHECK-NOT: memset Box::new(MaybeUninit::uninit()) } // Hide the `allocalign` attribute in the declaration of __rust_alloc // from the CHECK-NOT above, and also verify the attributes got set reasonably."}
{"_id":"q-en-rust-17cba66c086a608ea782497353ac4c704963876abe047a2af2af4ebb3be2ed69","text":"use rustc_hir as hir; use rustc_hir::def::{DefKind, Res}; use rustc_hir::def_id::{DefId, DefIdMap, LocalDefId, LocalDefIdSet}; use rustc_hir::intravisit::{walk_item, Visitor}; use rustc_hir::intravisit::{walk_body, walk_item, Visitor}; use rustc_hir::{Node, CRATE_HIR_ID}; use rustc_middle::hir::nested_filter; use rustc_middle::ty::TyCtxt;"}
{"_id":"q-en-rust-18575ed8a646e637032032dd22fa1b343e35bca79efc8013ae4c1e2c392e4709","text":" error[E0308]: mismatched types --> $DIR/bad-type-in-vec-push.rs:11:17 | LL | vector.sort(); | ------ here the type of `vector` is inferred to be `Vec<_>` LL | result.push(vector); | ---- ^^^^^^ expected integer, found struct `Vec` | | | arguments to this method are incorrect | = note: expected type `{integer}` found struct `Vec<_>` note: associated function defined here --> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL error[E0308]: mismatched types --> $DIR/bad-type-in-vec-push.rs:18:12 | LL | x.push(\"\"); | ---- ^^ expected integer, found `&str` | | | arguments to this method are incorrect | note: associated function defined here --> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0308`. "}
{"_id":"q-en-rust-186ca344dba3bfacc4908c2dd054957e62834d1a84b64e4e3cb1f871fde4cd6d","text":"} fn run(self, builder: &Builder<'_>) { // This gets called by `promote-release` // (https://github.com/rust-lang/rust-central-station/tree/master/promote-release). let mut cmd = builder.tool_cmd(Tool::BuildManifest); if builder.config.dry_run { return;"}
{"_id":"q-en-rust-187831d0df53994235b5dda27398760a1c1b64a1bb1e8d6bd450fc1986b5ab69","text":"impl ErrorIndex { pub fn command(builder: &Builder<'_>) -> Command { // This uses stage-1 to match the behavior of building rustdoc. // Error-index-generator links with the rustdoc library, so we want to // use the same librustdoc to avoid building rustdoc twice (and to // avoid building the compiler an extra time). This uses // saturating_sub to deal with building with stage 0. (Using stage 0 // isn't recommended, since it will fail if any new error index tests // use new syntax, but it should work otherwise.) let compiler = builder.compiler(builder.top_stage.saturating_sub(1), builder.config.build); // Error-index-generator links with the rustdoc library, so we need to add `rustc_lib_paths` // for rustc_private and libLLVM.so, and `sysroot_lib` for libstd, etc. let host = builder.config.build; let compiler = builder.compiler_for(builder.top_stage, host, host); let mut cmd = Command::new(builder.ensure(ErrorIndex { compiler })); add_dylib_path( vec![ PathBuf::from(&builder.sysroot_libdir(compiler, compiler.host)), builder.rustc_libdir(compiler), ], &mut cmd, ); let mut dylib_paths = builder.rustc_lib_paths(compiler); dylib_paths.push(PathBuf::from(&builder.sysroot_libdir(compiler, compiler.host))); add_dylib_path(dylib_paths, &mut cmd); cmd } }"}
{"_id":"q-en-rust-1879d9353e28d89365ff22524b348e7686623c83dfa09b40943d1dc074622cb2","text":" #![feature(doc_alias)] #![feature(trait_alias)] pub struct Foo; pub trait Bar { const BAZ: u8; } impl Bar for Foo { #[doc(alias = \"CONST_BAZ\")] //~ ERROR const BAZ: u8 = 0; } impl Foo { #[doc(alias = \"CONST_FOO\")] // ok! pub const FOO: u8 = 0; pub fn bar() -> u8 { Self::FOO } } "}
{"_id":"q-en-rust-1899d88e199059e4dfc1c5a74ecc48ec62edff95212be03291def0c29a041a26","text":"fn test1() { let a: i32 = \"foo\"; //~^ ERROR: mismatched types let b: i32 = \"f'oo\"; //~^ ERROR: mismatched types } fn test2() {"}
{"_id":"q-en-rust-18cb5ae81a91e786478b316ef08cf11f396ccc8cd86051a698f861c24e622132","text":"fn after_krate(&mut self) -> Result<(), Error> { debug!(\"Done with crate\"); debug!(\"Adding Primitive impls\"); for primitive in Rc::clone(&self.cache).primitive_locations.values() { self.get_impls(*primitive); } let e = ExternalCrate { crate_num: LOCAL_CRATE }; let index = (*self.index).clone().into_inner(); debug!(\"Constructing Output\");"}
{"_id":"q-en-rust-18cdf94a4b4635600ae292d0b6e413874ee5be12bde942e92fec9fcf2050c6c6","text":" // Copyright 2014-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 or the MIT license // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. //! Scoped thread-local storage //! //! This module provides the ability to generate *scoped* thread-local //! variables. In this sense, scoped indicates that thread local storage //! actually stores a reference to a value, and this reference is only placed //! in storage for a scoped amount of time. //! //! There are no restrictions on what types can be placed into a scoped //! variable, but all scoped variables are initialized to the equivalent of //! null. Scoped thread local storage is useful when a value is present for a known //! period of time and it is not required to relinquish ownership of the //! contents. //! //! # Examples //! //! ``` //! # #![feature(scoped_tls)] //! scoped_thread_local!(static FOO: u32); //! //! // Initially each scoped slot is empty. //! assert!(!FOO.is_set()); //! //! // When inserting a value, the value is only in place for the duration //! // of the closure specified. //! FOO.set(&1, || { //! FOO.with(|slot| { //! assert_eq!(*slot, 1); //! }); //! }); //! ``` #![unstable(feature = \"thread_local_internals\")] use prelude::v1::*; // macro hygiene sure would be nice, wouldn't it? #[doc(hidden)] pub mod __impl { pub use super::imp::KeyInner; pub use sys_common::thread_local::INIT as OS_INIT; } /// Type representing a thread local storage key corresponding to a reference /// to the type parameter `T`. /// /// Keys are statically allocated and can contain a reference to an instance of /// type `T` scoped to a particular lifetime. Keys provides two methods, `set` /// and `with`, both of which currently use closures to control the scope of /// their contents. #[unstable(feature = \"scoped_tls\", reason = \"scoped TLS has yet to have wide enough use to fully consider stabilizing its interface\")] pub struct ScopedKey { #[doc(hidden)] pub inner: __impl::KeyInner } /// Declare a new scoped thread local storage key. /// /// This macro declares a `static` item on which methods are used to get and /// set the value stored within. #[macro_export] #[allow_internal_unstable] macro_rules! scoped_thread_local { (static $name:ident: $t:ty) => ( __scoped_thread_local_inner!(static $name: $t); ); (pub static $name:ident: $t:ty) => ( __scoped_thread_local_inner!(pub static $name: $t); ); } #[macro_export] #[doc(hidden)] #[allow_internal_unstable] macro_rules! __scoped_thread_local_inner { (static $name:ident: $t:ty) => ( #[cfg_attr(not(any(windows, target_os = \"android\", target_os = \"ios\", target_os = \"openbsd\", target_arch = \"aarch64\")), thread_local)] static $name: ::std::thread::ScopedKey<$t> = __scoped_thread_local_inner!($t); ); (pub static $name:ident: $t:ty) => ( #[cfg_attr(not(any(windows, target_os = \"android\", target_os = \"ios\", target_os = \"openbsd\", target_arch = \"aarch64\")), thread_local)] pub static $name: ::std::thread::ScopedKey<$t> = __scoped_thread_local_inner!($t); ); ($t:ty) => ({ use std::thread::ScopedKey as __Key; #[cfg(not(any(windows, target_os = \"android\", target_os = \"ios\", target_os = \"openbsd\", target_arch = \"aarch64\")))] const _INIT: __Key<$t> = __Key { inner: ::std::thread::__scoped::KeyInner { inner: ::std::cell::UnsafeCell { value: 0 as *mut _ }, } }; #[cfg(any(windows, target_os = \"android\", target_os = \"ios\", target_os = \"openbsd\", target_arch = \"aarch64\"))] const _INIT: __Key<$t> = __Key { inner: ::std::thread::__scoped::KeyInner { inner: ::std::thread::__scoped::OS_INIT, marker: ::std::marker::PhantomData::<::std::cell::Cell<$t>>, } }; _INIT }) } #[unstable(feature = \"scoped_tls\", reason = \"scoped TLS has yet to have wide enough use to fully consider stabilizing its interface\")] impl ScopedKey { /// Insert a value into this scoped thread local storage slot for a /// duration of a closure. /// /// While `cb` is running, the value `t` will be returned by `get` unless /// this function is called recursively inside of `cb`. /// /// Upon return, this function will restore the previous value, if any /// was available. /// /// # Examples /// /// ``` /// # #![feature(scoped_tls)] /// scoped_thread_local!(static FOO: u32); /// /// FOO.set(&100, || { /// let val = FOO.with(|v| *v); /// assert_eq!(val, 100); /// /// // set can be called recursively /// FOO.set(&101, || { /// // ... /// }); /// /// // Recursive calls restore the previous value. /// let val = FOO.with(|v| *v); /// assert_eq!(val, 100); /// }); /// ``` pub fn set(&'static self, t: &T, cb: F) -> R where F: FnOnce() -> R, { struct Reset<'a, T: 'a> { key: &'a __impl::KeyInner, val: *mut T, } #[unsafe_destructor] impl<'a, T> Drop for Reset<'a, T> { fn drop(&mut self) { unsafe { self.key.set(self.val) } } } let prev = unsafe { let prev = self.inner.get(); self.inner.set(t as *const T as *mut T); prev }; let _reset = Reset { key: &self.inner, val: prev }; cb() } /// Get a value out of this scoped variable. /// /// This function takes a closure which receives the value of this /// variable. /// /// # Panics /// /// This function will panic if `set` has not previously been called. /// /// # Examples /// /// ```no_run /// # #![feature(scoped_tls)] /// scoped_thread_local!(static FOO: u32); /// /// FOO.with(|slot| { /// // work with `slot` /// }); /// ``` pub fn with(&'static self, cb: F) -> R where F: FnOnce(&T) -> R { unsafe { let ptr = self.inner.get(); assert!(!ptr.is_null(), \"cannot access a scoped thread local variable without calling `set` first\"); cb(&*ptr) } } /// Test whether this TLS key has been `set` for the current thread. pub fn is_set(&'static self) -> bool { unsafe { !self.inner.get().is_null() } } } #[cfg(not(any(windows, target_os = \"android\", target_os = \"ios\", target_os = \"openbsd\", target_arch = \"aarch64\")))] mod imp { use std::cell::UnsafeCell; #[doc(hidden)] pub struct KeyInner { pub inner: UnsafeCell<*mut T> } unsafe impl ::marker::Sync for KeyInner { } #[doc(hidden)] impl KeyInner { #[doc(hidden)] pub unsafe fn set(&self, ptr: *mut T) { *self.inner.get() = ptr; } #[doc(hidden)] pub unsafe fn get(&self) -> *mut T { *self.inner.get() } } } #[cfg(any(windows, target_os = \"android\", target_os = \"ios\", target_os = \"openbsd\", target_arch = \"aarch64\"))] mod imp { use marker; use std::cell::Cell; use sys_common::thread_local::StaticKey as OsStaticKey; #[doc(hidden)] pub struct KeyInner { pub inner: OsStaticKey, pub marker: marker::PhantomData>, } unsafe impl ::marker::Sync for KeyInner { } #[doc(hidden)] impl KeyInner { #[doc(hidden)] pub unsafe fn set(&self, ptr: *mut T) { self.inner.set(ptr as *mut _) } #[doc(hidden)] pub unsafe fn get(&self) -> *mut T { self.inner.get() as *mut _ } } } #[cfg(test)] mod tests { use cell::Cell; use prelude::v1::*; scoped_thread_local!(static FOO: u32); #[test] fn smoke() { scoped_thread_local!(static BAR: u32); assert!(!BAR.is_set()); BAR.set(&1, || { assert!(BAR.is_set()); BAR.with(|slot| { assert_eq!(*slot, 1); }); }); assert!(!BAR.is_set()); } #[test] fn cell_allowed() { scoped_thread_local!(static BAR: Cell); BAR.set(&Cell::new(1), || { BAR.with(|slot| { assert_eq!(slot.get(), 1); }); }); } #[test] fn scope_item_allowed() { assert!(!FOO.is_set()); FOO.set(&1, || { assert!(FOO.is_set()); FOO.with(|slot| { assert_eq!(*slot, 1); }); }); assert!(!FOO.is_set()); } } "}
{"_id":"q-en-rust-19132f39ad0b17482a29a93b782085ce185ed2f81ffd344a3c0e0b52d7c4638a","text":" use core::fmt; use core::iter::FusedIterator; use core::marker::PhantomData; use core::mem::{self, MaybeUninit}; use core::ptr::{self, NonNull}; use core::{fmt, mem}; use crate::alloc::{Allocator, Global}; use super::{count, Iter, VecDeque}; use super::{count, wrap_index, VecDeque}; /// A draining iterator over the elements of a `VecDeque`. ///"}
{"_id":"q-en-rust-1933ff121029b9db30d32892fee907b3a0eba6c1919037afb0fff0e6ff0825f9","text":"use std::collections::BTreeMap; use std::env; use std::fs; use std::fs::{self, File}; use std::io::{self, Read, Write}; use std::path::{PathBuf, Path}; use std::process::{Command, Stdio}; use std::collections::HashMap; static HOSTS: &[&str] = &[ \"aarch64-unknown-linux-gnu\","}
{"_id":"q-en-rust-1948251ca4c842fbf2a15dc6203a506bc70505a3abc15fa8fe1703788d19d12d","text":"pub mod fun_treemap; pub mod list; pub mod priority_queue; pub mod rope; pub mod smallintmap; pub mod sort;"}
{"_id":"q-en-rust-194a6d9038fa05289cce313e2bccb2a420f8b7309d84bbe0f03923c76ec186c2","text":"[`std::env`]: https://doc.rust-lang.org/stable/std/env/index.html#functions [strikethrough]: https://github.github.com/gfm/#strikethrough-extension- [tables]: https://github.github.com/gfm/#tables-extension- [task list extension]: https://github.github.com/gfm/#task-list-items-extension- "}
{"_id":"q-en-rust-196447890a229aadfe80a9584eab4477a66f1c91c8bab06251280c25f5155d92","text":"} else { // `sret` parameter thus one less integer register available arg.make_indirect(); // NOTE(eddyb) return is handled first, so no registers // should've been used yet. assert_eq!(int_regs, MAX_INT_REGS); int_regs -= 1; } } Ok(ref cls) => { // split into sized chunks passed individually int_regs -= needed_int; sse_regs -= needed_sse; if arg.layout.is_aggregate() { let size = arg.layout.size; arg.cast_to(cast_target(cls, size))"}
{"_id":"q-en-rust-19858e05d9e0b80dffff5a1bc5c3404fe5cb0b102de5ebbbb5cc6f723d2fc526","text":"Err(CharTryFromError(())) } else { // SAFETY: checked that it's a legal unicode value Ok(unsafe { from_u32_unchecked(i) }) Ok(unsafe { transmute(i) }) } } }"}
{"_id":"q-en-rust-19a25cb7546a38869ea883763103fd382bf503f8d4c9a86fe7097c9bd7dd7155","text":"} fn run_ui_cargo(config: &mut compiletest::Config) { if cargo::is_rustc_test_suite() { return; } fn run_tests( config: &compiletest::Config, filter: &Option,"}
{"_id":"q-en-rust-1a00d8c4bfea1de316291798da6e1ce51de72fba4dd35aa4e55fd015dff2dad5","text":"#[rustc_doc_primitive = \"f64\"] #[doc(alias = \"double\")] /// A 64-bit floating point type (specifically, the \"binary64\" type defined in IEEE 754-2008). /// A 64-bit floating-point type (specifically, the \"binary64\" type defined in IEEE 754-2008). /// /// This type is very similar to [`prim@f32`], but has increased precision by using twice as many /// bits. Please see [the documentation for `f32`](prim@f32) or [Wikipedia on double-precision"}
{"_id":"q-en-rust-1a1161b7ce6350c3983e6d83cf960c55f8d1e54eb1af8ee22e6cecbf3c1bade3","text":"/// the hashmap because certain items (traits and types) need to have their mappings for trait /// implementations filled out before they're inserted. fn item(&mut self, item: clean::Item) -> Result<(), Error> { let local_blanket_impl = match item.def_id { clean::ItemId::Blanket { impl_id, .. } => impl_id.is_local(), clean::ItemId::Auto { .. } | clean::ItemId::DefId(_) | clean::ItemId::Primitive(_, _) => false, }; // Flatten items that recursively store other items // FIXME(CraftSpider): We skip children of local blanket implementations, as we'll have // already seen the actual generic impl, and the generated ones don't need documenting. // This is necessary due to the visibility, return type, and self arg of the generated // impls not quite matching, and will no longer be necessary when the mismatch is fixed. if !local_blanket_impl { item.kind.inner_items().for_each(|i| self.item(i.clone()).unwrap()); } item.kind.inner_items().for_each(|i| self.item(i.clone()).unwrap()); let id = item.def_id; if let Some(mut new_item) = self.convert_item(item) {"}
{"_id":"q-en-rust-1a1a2dec9a3b57696477d66b133fcbfce224980370c37681df41fef5b65fedb6","text":"// '👎 Deprecated since 1.0.0: deprecated' // @has issue_32374/struct.U.html '//*[@class=\"stab unstable\"]' // '🔬 This is a nightly-only experimental API. (test #32374)' // @has issue_32374/struct.U.html '//details' // '🔬 This is a nightly-only experimental API. (test #32374)' // @has issue_32374/struct.U.html '//summary' // '🔬 This is a nightly-only experimental API. (test #32374)' // @has issue_32374/struct.U.html '//details/p' // 'unstable' #[rustc_deprecated(since = \"1.0.0\", reason = \"deprecated\")] #[unstable(feature = \"test\", issue = \"32374\", reason = \"unstable\")] pub struct U;"}
{"_id":"q-en-rust-1a4ffcb7cf29dcff2ccc2935a45e9c3400da8c5a4eaf93487be6f396b014f1d5","text":"let external_paths = ctxt.external_paths.borrow_mut().take(); *analysis.external_paths.borrow_mut() = external_paths; let map = ctxt.external_typarams.borrow_mut().take(); *analysis.external_typarams.borrow_mut() = map; let map = ctxt.inlined.borrow_mut().take(); *analysis.inlined.borrow_mut() = map; analysis.deref_trait_did = ctxt.deref_trait_did.get(); (krate, analysis) }), &sess) Some((krate, analysis)) }), &sess); krate_and_analysis.unwrap() }"}
{"_id":"q-en-rust-1a71604bfd57d1faa92388168017a0cc276e044e362016071949636b49a601c1","text":" // 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 or the MIT license // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. use std::io; use std::vec; pub struct Container<'a> { reader: &'a mut Reader //~ ERROR explicit lifetime bound required } impl<'a> Container<'a> { pub fn wrap<'s>(reader: &'s mut Reader) -> Container<'s> { Container { reader: reader } } pub fn read_to(&mut self, vec: &mut [u8]) { self.reader.read(vec); } } pub fn for_stdin<'a>() -> Container<'a> { let mut r = io::stdin(); Container::wrap(&mut r as &mut Reader) } fn main() { let mut c = for_stdin(); let mut v = vec::Vec::from_elem(10, 0u8); c.read_to(v.as_mut_slice()); } "}
{"_id":"q-en-rust-1aa636be8b244eaed326c98686e4bfff7ed8e08a462ba18f4faf82138e9a264b","text":"fn main() { let _x = \"test\" as &::std::any::Any; //~^ ERROR the trait `core::kinds::Sized` is not implemented for the type `str` //~^^ NOTE the trait `core::kinds::Sized` must be implemented for the cast to the object type //~^^ ERROR the trait `core::kinds::Sized` is not implemented for the type `str` }"}
{"_id":"q-en-rust-1abc7a62e989d3c01508beee233a66931ed17bac072aff90414e317899f9df73","text":" Subproject commit 8485d40a3264b15b92d391e99cb3d1abf8f25025 Subproject commit 23549a8c362a403026432f65a6cb398cb10d44b7 "}
{"_id":"q-en-rust-1abf5a9a099038738be52ce6afb877cdfb4970daa2d44396595391a95456ad4e","text":"use foo::self; //~ ERROR unresolved import `foo::self` //~^ ERROR `self` imports are only allowed within a { } list use std::mem::self; //~^ ERROR `self` imports are only allowed within a { } list fn main() {}"}
{"_id":"q-en-rust-1ac50255539b3d8913d6292f2c4a7c1f9632950764f450655d5f1d9f32d44a96","text":"/// println!(\"{:?}\", Foo(vec![10, 11])); /// ``` #[stable(feature = \"debug_builders\", since = \"1.2.0\")] #[inline] pub fn debug_list<'b>(&'b mut self) -> DebugList<'b, 'a> { builders::debug_list_new(self) }"}
{"_id":"q-en-rust-1acbb513c2262d09ca6e1af60e1acef6f533be019f4d3309a946e853db4aab42","text":" error[E0119]: conflicting implementations of trait `Bar` for type `()` --> $DIR/dont-drop-upcast-candidate.rs:10:1 | LL | impl Bar for T where dyn Foo: Unsize {} | ------------------------------------------------ first implementation here LL | impl Bar for () {} | ^^^^^^^^^^^^^^^ conflicting implementation for `()` error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0119`. "}
{"_id":"q-en-rust-1b0193d5328c8ac74a597c20c564211a88f63b7efdf27abf3ca61c59d93c99fb","text":"fn check_trait_fn_not_async(&self, span: Span, asyncness: IsAsync) { if asyncness.is_async() { struct_span_err!(self.session, span, E0706, \"trait fns cannot be declared `async`\").emit() struct_span_err!(self.session, span, E0706, \"trait fns cannot be declared `async`\") .note(\"`async` trait functions are not currently supported\") .note(\"consider using the `async-trait` crate: https://crates.io/crates/async-trait\") .emit(); } }"}
{"_id":"q-en-rust-1b08d68d378918586f925cc40298666aeacf00241b84f38c5afda79f4cdbaf7f","text":"// Note that currently the `wasm-import-module` doesn't do anything, but // eventually LLVM 7 should read this and ferry the appropriate import // module to the output file. if cx.tcx.sess.target.target.arch == \"wasm32\" { if let Some(module) = wasm_import_module(cx.tcx, id) { llvm::AddFunctionAttrStringValue( llfn, llvm::AttributePlace::Function, const_cstr!(\"wasm-import-module\"), &module, ); if let Some(id) = id { if cx.tcx.sess.target.target.arch == \"wasm32\" { if let Some(module) = wasm_import_module(cx.tcx, id) { llvm::AddFunctionAttrStringValue( llfn, llvm::AttributePlace::Function, const_cstr!(\"wasm-import-module\"), &module, ); } } } }"}
{"_id":"q-en-rust-1b22ef3a47795ade4957a2f858457eab959e80682fdb5896ed9b44666fbd8ff0","text":" // Copyright 2018 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 or the MIT license // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. #![feature(nll)] fn main() { let foo = &16; //~^ HELP consider changing this to be a mutable reference //~| SUGGESTION &mut 16 *foo = 32; //~^ ERROR cannot assign to `*foo` which is behind a `&` reference let bar = foo; //~^ HELP consider changing this to be a mutable reference //~| SUGGESTION &mut i32 *bar = 64; //~^ ERROR cannot assign to `*bar` which is behind a `&` reference } "}
{"_id":"q-en-rust-1b2334a5b6a03cf8a7d155e3753307f32b2e04c63c3c6f4b4f1ceb2a88c56851","text":"| help: replace `_` with the correct type: `i32` error[E0121]: the type placeholder `_` is not allowed within types on item signatures --> $DIR/typeck_type_placeholder_item.rs:197:26 | LL | type F: std::ops::Fn(_); | ^ not allowed in type signatures error[E0121]: the type placeholder `_` is not allowed within types on item signatures --> $DIR/typeck_type_placeholder_item.rs:40:24 | LL | fn test9(&self) -> _ { () }"}
{"_id":"q-en-rust-1b692043bf57b8b75df39c7ea704bb4fcac55fbed2e668cfb50f94cc68e3014f","text":" // aux-build:impl-const.rs // run-pass #![feature(const_generics)] #![allow(incomplete_features)] extern crate impl_const; use impl_const::*; pub fn main() { let n = Num::<5>; n.five(); } "}
{"_id":"q-en-rust-1b9de160c954b28d122a0d937c3ecb1c21f6afb14b0cb9ba4bc99a60e58d8931","text":"/// } /// ``` #[stable(feature = \"io_error_inner\", since = \"1.3.0\")] #[inline] pub fn into_inner(self) -> Option> { match self.repr { Repr::Os(..) => None,"}
{"_id":"q-en-rust-1bc6d485bcab4deadb19de23dd6f11a5c83c4318e84ec74712df47e324969d38","text":" // 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 or the MIT license // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. fn main() { if true { proc(_) {} } else { proc(_: &mut ()) {} }; } "}
{"_id":"q-en-rust-1c02cfa45a99df2ede8c126f14f38d21a27eac2420d63367f5ccf09e1196fb83","text":"let bin_root = self.out.join(host.triple).join(\"rustfmt\"); let rustfmt_path = bin_root.join(\"bin\").join(exe(\"rustfmt\", host)); let rustfmt_stamp = bin_root.join(\".rustfmt-stamp\"); let legacy_rustfmt = self.initial_rustc.with_file_name(exe(\"rustfmt\", host)); if !legacy_rustfmt.exists() { t!(self.symlink_file(&rustfmt_path, &legacy_rustfmt)); } if rustfmt_path.exists() && !program_out_of_date(&rustfmt_stamp, &channel) { return Some(rustfmt_path); }"}
{"_id":"q-en-rust-1c2abc276333d5fb11821999c6c2e4f56d556f2421270d9acf9f93aaead1d3dd","text":"// except according to those terms. // aux-build:attr-on-trait.rs // ignore-stage1 #![feature(proc_macro)]"}
{"_id":"q-en-rust-1c3c86032b6d4b0b3010040adbddb11e9a6342a38fabd6635a02d317a36a9b44","text":"let host_libs = builder .stage_out(compiler, Mode::ToolRustc) .join(builder.cargo_dir()); let target_libs = builder .stage_out(compiler, Mode::ToolRustc) .join(&self.host) .join(builder.cargo_dir()); cargo.env(\"HOST_LIBS\", host_libs); cargo.env(\"TARGET_LIBS\", target_libs); // clippy tests need to find the driver cargo.env(\"CLIPPY_DRIVER_PATH\", clippy);"}
{"_id":"q-en-rust-1c3f42a92a75b84ae62a565ac834798d447d9652a2c996cd7e40daf3b5c1539f","text":"pub fn get_linker(sess: &Session) -> (String, Command, Vec<(OsString, OsString)>) { let envs = vec![(\"PATH\".into(), command_path(sess))]; // If our linker looks like a batch script on Windows then to execute this // we'll need to spawn `cmd` explicitly. This is primarily done to handle // emscripten where the linker is `emcc.bat` and needs to be spawned as // `cmd /c emcc.bat ...`. // // This worked historically but is needed manually since #42436 (regression // was tagged as #42791) and some more info can be found on #44443 for // emscripten itself. let cmd = |linker: &str| { if cfg!(windows) && linker.ends_with(\".bat\") { let mut cmd = Command::new(\"cmd\"); cmd.arg(\"/c\").arg(linker); cmd } else { Command::new(linker) } }; if let Some(ref linker) = sess.opts.cg.linker { (linker.clone(), Command::new(linker), envs) (linker.clone(), cmd(linker), envs) } else if sess.target.target.options.is_like_msvc { let (cmd, envs) = msvc_link_exe_cmd(sess); (\"link.exe\".to_string(), cmd, envs) } else { let linker = &sess.target.target.options.linker; (linker.clone(), Command::new(&linker), envs) (linker.clone(), cmd(linker), envs) } }"}
{"_id":"q-en-rust-1c9182b3020da5b9e9c95397b9dc371921adfe7d68fc690f51e2e4a3a7b6b0a5","text":" // revisions: cfail #![feature(const_generics, const_evaluatable_checked)] #![allow(incomplete_features)] // regression test for #77650 struct C([T; N.get()]) where [T; N.get()]: Sized; impl<'a, const N: core::num::NonZeroUsize, A, B: PartialEq> PartialEq<&'a [A]> for C where [B; N.get()]: Sized, { fn eq(&self, other: &&'a [A]) -> bool { self.0 == other //~^ error: can't compare } } fn main() {} "}
{"_id":"q-en-rust-1ce10baa949a26c58b1cd8af26cbf806499cae26fe1e59fb786b58b9d6b9e8da","text":"retry pip3 install awscli --upgrade --user echo \"##vso[task.prependpath]$HOME/.local/bin\" displayName: Install awscli (Linux) condition: and(succeeded(), eq(variables['Agent.OS'], 'Linux')) condition: and(succeeded(), not(variables.SKIP_JOB), eq(variables['Agent.OS'], 'Linux')) - script: pip install awscli displayName: Install awscli (non-Linux) condition: and(succeeded(), ne(variables['Agent.OS'], 'Linux')) condition: and(succeeded(), not(variables.SKIP_JOB), ne(variables['Agent.OS'], 'Linux')) # Configure our CI_JOB_NAME variable which log analyzers can use for the main # step to see what's going on."}
{"_id":"q-en-rust-1d1e5a17691a0410b33ff7bd6b7ff8c9ee8c8b0a9af9a51b7c312d4fcf3c04d8","text":" Subproject commit 941968db2fd9c85788a4f971c8e425d46b4cb734 Subproject commit 75a5f9236c689a547fe207a10854f0775bce7937 "}
{"_id":"q-en-rust-1d2d5fafeaa6e20b598aac1d87be98776ec174e3df6e52ec5f5b3fdfffdc1676","text":"|| self.suggest_into(err, expr, expr_ty, expected) || self.suggest_floating_point_literal(err, expr, expected) || self.suggest_null_ptr_for_literal_zero_given_to_ptr_arg(err, expr, expected) || self.suggest_coercing_result_via_try_operator(err, expr, expected, expr_ty) || self.suggest_missing_unwrap_expect(err, expr, expected, expr_ty); || self.suggest_coercing_result_via_try_operator(err, expr, expected, expr_ty); if !suggested { self.note_source_of_type_mismatch_constraint("}
{"_id":"q-en-rust-1d2f25a34c4d865b1d9eed7d4ff667a8324effc948f10bdb491886539247a2e9","text":"/// context it's calculated within. This is used by the `type_id` intrinsic. pub fn hash_crate_independent(tcx: &ctxt, ty: Ty, svh: &Svh) -> u64 { let mut state = sip::SipState::new(); macro_rules! byte( ($b:expr) => { ($b as u8).hash(&mut state) } ); macro_rules! hash( ($e:expr) => { $e.hash(&mut state) } ); let region = |_state: &mut sip::SipState, r: Region| { match r { ReStatic => {} ReEmpty | ReEarlyBound(..) | ReLateBound(..) | ReFree(..) | ReScope(..) | ReInfer(..) => { tcx.sess.bug(\"non-static region found when hashing a type\") helper(tcx, ty, svh, &mut state); return state.result(); fn helper(tcx: &ctxt, ty: Ty, svh: &Svh, state: &mut sip::SipState) { macro_rules! byte( ($b:expr) => { ($b as u8).hash(state) } ); macro_rules! hash( ($e:expr) => { $e.hash(state) } ); let region = |state: &mut sip::SipState, r: Region| { match r { ReStatic => {} ReLateBound(db, BrAnon(i)) => { db.hash(state); i.hash(state); } ReEmpty | ReEarlyBound(..) | ReLateBound(..) | ReFree(..) | ReScope(..) | ReInfer(..) => { tcx.sess.bug(\"unexpected region found when hashing a type\") } } } }; let did = |state: &mut sip::SipState, did: DefId| { let h = if ast_util::is_local(did) { svh.clone() } else { tcx.sess.cstore.get_crate_hash(did.krate) }; h.as_str().hash(state); did.node.hash(state); }; let mt = |state: &mut sip::SipState, mt: mt| { mt.mutbl.hash(state); }; ty::walk_ty(ty, |ty| { match ty.sty { ty_bool => byte!(2), ty_char => byte!(3), ty_int(i) => { byte!(4); hash!(i); } ty_uint(u) => { byte!(5); hash!(u); } ty_float(f) => { byte!(6); hash!(f); } ty_str => { byte!(7); } ty_enum(d, _) => { byte!(8); did(&mut state, d); } ty_uniq(_) => { byte!(9); } ty_vec(_, Some(n)) => { byte!(10); n.hash(&mut state); } ty_vec(_, None) => { byte!(11); } ty_ptr(m) => { byte!(12); mt(&mut state, m); } ty_rptr(r, m) => { byte!(13); region(&mut state, r); mt(&mut state, m); } ty_bare_fn(ref b) => { byte!(14); hash!(b.unsafety); hash!(b.abi); let did = |state: &mut sip::SipState, did: DefId| { let h = if ast_util::is_local(did) { svh.clone() } else { tcx.sess.cstore.get_crate_hash(did.krate) }; h.as_str().hash(state); did.node.hash(state); }; let mt = |state: &mut sip::SipState, mt: mt| { mt.mutbl.hash(state); }; let fn_sig = |state: &mut sip::SipState, sig: &FnSig| { let sig = anonymize_late_bound_regions(tcx, sig); for a in sig.inputs.iter() { helper(tcx, *a, svh, state); } if let ty::FnConverging(output) = sig.output { helper(tcx, output, svh, state); } ty_closure(ref c) => { byte!(15); hash!(c.unsafety); hash!(c.onceness); hash!(c.bounds); match c.store { UniqTraitStore => byte!(0), RegionTraitStore(r, m) => { byte!(1) region(&mut state, r); assert_eq!(m, ast::MutMutable); }; maybe_walk_ty(ty, |ty| { match ty.sty { ty_bool => byte!(2), ty_char => byte!(3), ty_int(i) => { byte!(4); hash!(i); } ty_uint(u) => { byte!(5); hash!(u); } ty_float(f) => { byte!(6); hash!(f); } ty_str => { byte!(7); } ty_enum(d, _) => { byte!(8); did(state, d); } ty_uniq(_) => { byte!(9); } ty_vec(_, Some(n)) => { byte!(10); n.hash(state); } ty_vec(_, None) => { byte!(11); } ty_ptr(m) => { byte!(12); mt(state, m); } ty_rptr(r, m) => { byte!(13); region(state, r); mt(state, m); } ty_bare_fn(ref b) => { byte!(14); hash!(b.unsafety); hash!(b.abi); fn_sig(state, &b.sig); return false; } ty_closure(ref c) => { byte!(15); hash!(c.unsafety); hash!(c.onceness); hash!(c.bounds); match c.store { UniqTraitStore => byte!(0), RegionTraitStore(r, m) => { byte!(1); region(state, r); assert_eq!(m, ast::MutMutable); } } fn_sig(state, &c.sig); return false; } } ty_trait(box TyTrait { ref principal, bounds }) => { byte!(17); did(&mut state, principal.def_id); hash!(bounds); } ty_struct(d, _) => { byte!(18); did(&mut state, d); } ty_tup(ref inner) => { byte!(19); hash!(inner.len()); } ty_param(p) => { byte!(20); hash!(p.idx); did(&mut state, p.def_id); } ty_open(_) => byte!(22), ty_infer(_) => unreachable!(), ty_err => byte!(23), ty_unboxed_closure(d, r, _) => { byte!(24); did(&mut state, d); region(&mut state, r); } } }); ty_trait(box TyTrait { ref principal, bounds }) => { byte!(17); did(state, principal.def_id); hash!(bounds); let principal = anonymize_late_bound_regions(tcx, principal); for subty in principal.substs.types.iter() { helper(tcx, *subty, svh, state); } state.result() return false; } ty_struct(d, _) => { byte!(18); did(state, d); } ty_tup(ref inner) => { byte!(19); hash!(inner.len()); } ty_param(p) => { byte!(20); hash!(p.idx); did(state, p.def_id); } ty_open(_) => byte!(22), ty_infer(_) => unreachable!(), ty_err => byte!(23), ty_unboxed_closure(d, r, _) => { byte!(24); did(state, d); region(state, r); } } true }); } } impl Variance {"}
{"_id":"q-en-rust-1d3450039f0d14b6e1c079ac1cec417dde081838d47d8cc98fe087b5cb4b423b","text":" error[E0425]: cannot find function `printf` in this scope --> $DIR/seggest_print_over_printf.rs:6:5 | LL | printf(\"%d\", x); | ^^^^^^ not found in this scope | help: you may have meant to use the `print` macro | LL | print!(\"%d\", x); | ~~~~~~ error: aborting due to previous error For more information about this error, try `rustc --explain E0425`. "}
{"_id":"q-en-rust-1d6d423b53dbe5cef576e2541957c540176808e71d43c181ab62710d2c95aad2","text":" #[deny(single_use_lifetimes)] // edition:2018 // check-pass // Prior to the fix, the compiler complained that the 'a lifetime was only used // once. This was obviously wrong since the lifetime is used twice: For the s3 // parameter and the return type. The issue was caused by the compiler // desugaring the async function into a generator that uses only a single // lifetime, which then the validator complained about becauase of the // single_use_lifetimes constraints. async fn bar<'a>(s1: String, s2: &'_ str, s3: &'a str) -> &'a str { s3 } fn foo<'a>(s1: String, s2: &'_ str, s3: &'a str) -> &'a str { s3 } fn main() {} "}
{"_id":"q-en-rust-1d89a26cc507119d46e22ddec86a6ce890906ead166c03a8d6776beb0ac1b7de","text":" error[E0277]: `&mut ()` is not a tuple --> $DIR/issue-57404.rs:6:41 | LL | handlers.unwrap().as_mut().call_mut(&mut ()); | -------- -^^^^^^ | | | | | the trait `Tuple` is not implemented for `&mut ()` | | help: consider removing the leading `&`-reference | required by a bound introduced by this call | note: required by a bound in `call_mut` --> $SRC_DIR/core/src/ops/function.rs:LL:COL error: aborting due to previous error For more information about this error, try `rustc --explain E0277`. "}
{"_id":"q-en-rust-1d998adc3448d96d2171fc5eed79a03c6ed0210d492e3607800844217278bcf4","text":"impl Step for RustcDocs { type Output = Option; const DEFAULT: bool = true; const ONLY_HOSTS: bool = true; fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { let builder = run.builder;"}
{"_id":"q-en-rust-1d99fb1300f77ef10a84d2f924b6c92597e0852b22f045430b5e9b63a87bb795","text":" error: mismatched closing delimiter: `]` --> $DIR/issue-67377-invalid-syntax-in-enum-discriminant.rs:5:42 | LL | V = [PhantomData; { [ () ].len() ].len() as isize, | - - ^ mismatched closing delimiter | | | | | unclosed delimiter | closing delimiter possibly meant for this error: mismatched closing delimiter: `]` --> $DIR/issue-67377-invalid-syntax-in-enum-discriminant.rs:15:36 | LL | V = [Vec::new; { [].len() ].len() as isize, | - - ^ mismatched closing delimiter | | | | | unclosed delimiter | closing delimiter possibly meant for this error: mismatched closing delimiter: `]` --> $DIR/issue-67377-invalid-syntax-in-enum-discriminant.rs:26:36 | LL | V = [Vec::new; { [0].len() ].len() as isize, | - - ^ mismatched closing delimiter | | | | | unclosed delimiter | closing delimiter possibly meant for this error: mismatched closing delimiter: `]` --> $DIR/issue-67377-invalid-syntax-in-enum-discriminant.rs:5:42 | LL | V = [PhantomData; { [ () ].len() ].len() as isize, | - - ^ mismatched closing delimiter | | | | | unclosed delimiter | closing delimiter possibly meant for this error: mismatched closing delimiter: `]` --> $DIR/issue-67377-invalid-syntax-in-enum-discriminant.rs:15:36 | LL | V = [Vec::new; { [].len() ].len() as isize, | - - ^ mismatched closing delimiter | | | | | unclosed delimiter | closing delimiter possibly meant for this error: mismatched closing delimiter: `]` --> $DIR/issue-67377-invalid-syntax-in-enum-discriminant.rs:26:36 | LL | V = [Vec::new; { [0].len() ].len() as isize, | - - ^ mismatched closing delimiter | | | | | unclosed delimiter | closing delimiter possibly meant for this error: mismatched closing delimiter: `]` --> $DIR/issue-67377-invalid-syntax-in-enum-discriminant.rs:5:42 | LL | V = [PhantomData; { [ () ].len() ].len() as isize, | - - ^ mismatched closing delimiter | | | | | unclosed delimiter | closing delimiter possibly meant for this error: mismatched closing delimiter: `]` --> $DIR/issue-67377-invalid-syntax-in-enum-discriminant.rs:15:36 | LL | V = [Vec::new; { [].len() ].len() as isize, | - - ^ mismatched closing delimiter | | | | | unclosed delimiter | closing delimiter possibly meant for this error: mismatched closing delimiter: `]` --> $DIR/issue-67377-invalid-syntax-in-enum-discriminant.rs:26:36 | LL | V = [Vec::new; { [0].len() ].len() as isize, | - - ^ mismatched closing delimiter | | | | | unclosed delimiter | closing delimiter possibly meant for this error: mismatched closing delimiter: `]` --> $DIR/issue-67377-invalid-syntax-in-enum-discriminant.rs:5:42 | LL | V = [PhantomData; { [ () ].len() ].len() as isize, | - - ^ mismatched closing delimiter | | | | | unclosed delimiter | closing delimiter possibly meant for this error: mismatched closing delimiter: `]` --> $DIR/issue-67377-invalid-syntax-in-enum-discriminant.rs:15:36 | LL | V = [Vec::new; { [].len() ].len() as isize, | - - ^ mismatched closing delimiter | | | | | unclosed delimiter | closing delimiter possibly meant for this error: mismatched closing delimiter: `]` --> $DIR/issue-67377-invalid-syntax-in-enum-discriminant.rs:26:36 | LL | V = [Vec::new; { [0].len() ].len() as isize, | - - ^ mismatched closing delimiter | | | | | unclosed delimiter | closing delimiter possibly meant for this error[E0282]: type annotations needed --> $DIR/issue-67377-invalid-syntax-in-enum-discriminant.rs:15:29 | LL | V = [Vec::new; { [].len() ].len() as isize, | ^^^ cannot infer type for type parameter `T` error[E0282]: type annotations needed --> $DIR/issue-67377-invalid-syntax-in-enum-discriminant.rs:26:14 | LL | V = [Vec::new; { [0].len() ].len() as isize, | ^^^^^^^^ cannot infer type for type parameter `T` error: aborting due to 14 previous errors For more information about this error, try `rustc --explain E0282`. "}
{"_id":"q-en-rust-1d9ed2d556f6f3723a9c495ddfb4083726dde618afa0c3fa68ac6ec3b2ee1e82","text":"euv::AutoRef(..) | euv::ClosureInvocation(..) | euv::ForLoop(..) | euv::RefBinding(..) => { euv::RefBinding(..) | euv::MatchDiscriminant(..) => { format!(\"previous borrow of `{}` occurs here\", self.bccx.loan_path_to_string(&*old_loan.loan_path)) }"}
{"_id":"q-en-rust-1db5248d1b2c0eddd506850c57ab4cf866769951e402eb7abe526cc8afc2c11c","text":" error[E0499]: cannot borrow `chars` as mutable more than once at a time --> $DIR/issue-102972.rs:4:9 | LL | for _c in chars.by_ref() { | -------------- | | | first mutable borrow occurs here | first borrow later used here LL | chars.next(); | ^^^^^^^^^^^^ second mutable borrow occurs here | = note: a for loop advances the iterator for you, the result is stored in `_c`. = help: if you want to call `next` on a iterator within the loop, consider using `while let`. error[E0382]: borrow of moved value: `iter` --> $DIR/issue-102972.rs:12:9 | LL | let mut iter = v.iter(); | -------- move occurs because `iter` has type `std::slice::Iter<'_, i32>`, which does not implement the `Copy` trait LL | for _i in iter { | ---- `iter` moved due to this implicit call to `.into_iter()` LL | iter.next(); | ^^^^^^^^^^^ value borrowed here after move | = note: a for loop advances the iterator for you, the result is stored in `_i`. = help: if you want to call `next` on a iterator within the loop, consider using `while let`. note: `into_iter` takes ownership of the receiver `self`, which moves `iter` --> $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL error: aborting due to 2 previous errors Some errors have detailed explanations: E0382, E0499. For more information about an error, try `rustc --explain E0382`. "}
{"_id":"q-en-rust-1e19b26604193a5af0c9d04320e06294b061e4f7d3e4a55dd919cd2fd0ae4f46","text":"fn fmt(&self, f: &mut Formatter) -> Result { try!(write!(f, \"\"\")); for c in self.chars().flat_map(|c| c.escape_default()) { try!(write!(f, \"{}\", c)); try!(f.write_char(c)) } write!(f, \"\"\") }"}
{"_id":"q-en-rust-1e1c8ffde5f297e643b3b2820bbf4758d443e6cbeda978b216926b73a488e148","text":" //@ check-pass #![feature(inherent_associated_types)] //~^ WARN the feature `inherent_associated_types` is incomplete struct D { a: T } impl D { type Item = T; fn next() -> Self::Item { Self::Item::default() } } fn main() { } "}
{"_id":"q-en-rust-1e1d93fced3d9fbeda6dcb30bc66fc7460f9a8f7eec94281c1a68ecef942346f","text":"/// println!(\"{:?}\", Foo(vec![(\"A\".to_string(), 10), (\"B\".to_string(), 11)])); /// ``` #[stable(feature = \"debug_builders\", since = \"1.2.0\")] #[inline] pub fn debug_map<'b>(&'b mut self) -> DebugMap<'b, 'a> { builders::debug_map_new(self) }"}
{"_id":"q-en-rust-1e1dfbad1ab9acf8abb0446035681f29f8b6d050640f182b063c4836daa91a62","text":" use std::convert::TryInto; struct S; fn main() { let _: u32 = 5i32.try_into::<32>().unwrap(); //~ ERROR wrong number of const arguments S.f::<0>(); //~ ERROR no method named `f` S::<0>; //~ ERROR wrong number of const arguments } "}
{"_id":"q-en-rust-1e304a191f883320a578ead565526b4ddae3dbfabfcea8ccdd43e4488366a897","text":"); } let is_fn_trait = [ self.tcx.lang_items().fn_trait(), self.tcx.lang_items().fn_mut_trait(), self.tcx.lang_items().fn_once_trait(), ] .contains(&Some(trait_ref.def_id())); let is_target_feature_fn = if let ty::FnDef(def_id, _) = trait_ref.skip_binder().self_ty().kind { !self.tcx.codegen_fn_attrs(def_id).target_features.is_empty() } else { false }; if is_fn_trait && is_target_feature_fn { err.note( \"`#[target_feature]` functions do not implement the `Fn` traits\", ); } // Try to report a help message if !trait_ref.has_infer_types_or_consts() && self.predicate_can_apply(obligation.param_env, trait_ref)"}
{"_id":"q-en-rust-1e60024065413774d177c03d8686b6e52bfa887f244b9b144df6ce58edfd99b4","text":"ty ); // Fast path: if this is a primitive simple `==` will work let saw_impl = impl_type == ty; // NOTE: the `match` is necessary; see #92662. // this allows us to ignore generics because the user input // may not include the generic placeholders // e.g. this allows us to match Foo (user comment) with Foo (actual type) let saw_impl = impl_type == ty || match (impl_type.kind(), ty.kind()) { (ty::Adt(impl_def, _), ty::Adt(ty_def, _)) => { debug!(\"impl def_id: {:?}, ty def_id: {:?}\", impl_def.did, ty_def.did); impl_def.did == ty_def.did } _ => false, }; if saw_impl { Some(trait_) } else { None } })"}
{"_id":"q-en-rust-1e7339c9126e45f6605253a1a31533cd24bf614c5f258eab8775f754a3d3ca1a","text":"#[derive(Clone)] enum Enum { Variant1, //~ ERROR: variant is never used Variant1, //~ ERROR: variant is never constructed Variant2, }"}
{"_id":"q-en-rust-1ea7516811c0ff542fdb5bfc172b0a063c4edfe9284fe598374f817d01542562","text":"/// of the type. fn in_any_value_of_ty(_cx: &ConstCx<'_, 'tcx>, _ty: Ty<'tcx>) -> bool; fn in_static(cx: &ConstCx<'_, 'tcx>, def_id: DefId) -> bool { // `mir_const_qualif` does return the qualifs in the final value of a `static`, so we could // use value-based qualification here, but we shouldn't do this without a good reason. Self::in_any_value_of_ty(cx, cx.tcx.type_of(def_id)) } fn in_projection_structurally( cx: &ConstCx<'_, 'tcx>, per_local: &impl Fn(Local) -> bool,"}
{"_id":"q-en-rust-1f2e610c11917a6ac13e3e454a908e6135e22a65e7c57b844a08053e6bc6ce35","text":"/// with this error. /// /// [`from_utf8_unchecked`]: struct.String.html#method.from_utf8_unchecked /// [`&str`]: ../../std/primitive.str.html /// [`String`]: struct.String.html /// [`u8`]: ../../std/primitive.u8.html /// [`Vec`]: ../../std/vec/struct.Vec.html /// [`str::from_utf8`]: ../../std/str/fn.from_utf8.html /// [`as_bytes`]: struct.String.html#method.as_bytes /// [`into_bytes`]: struct.String.html#method.into_bytes /// [`FromUtf8Error`]: struct.FromUtf8Error.html /// [`Err`]: ../../std/result/enum.Result.html#variant.Err #[inline]"}
{"_id":"q-en-rust-1f50f54a4c7eb90226c91b194d0ee08ee91a375235a768154cfb384c984b6a30","text":"self.lldb_git_commit_hash = self.git_commit_hash(\"lldb\", \"x86_64-unknown-linux-gnu\"); self.miri_git_commit_hash = self.git_commit_hash(\"miri\", \"x86_64-unknown-linux-gnu\"); self.check_toolstate(); self.digest_and_sign(); let manifest = self.build_manifest(); self.write_channel_files(&self.rust_release, &manifest);"}
{"_id":"q-en-rust-1f7ebf3e662e6a4bff0390b7828a999c027163c69979321b56fe80f93ea4c41d","text":"} TokenTree::Token(t) => { // Doc comments cannot appear in a matcher. debug_assert!(!matches!(t, Token { kind: DocComment(..), .. })); // If the token matches, we can just advance the parser. Otherwise, this // match hash failed, there is nothing to do, and hopefully another item in // `cur_items` will match. if token_name_eq(&t, token) { // If it's a doc comment, we just ignore it and move on to the next tt in // the matcher. If the token matches, we can just advance the parser. // Otherwise, this match has failed, there is nothing to do, and hopefully // another item in `cur_items` will match. if matches!(t, Token { kind: DocComment(..), .. }) { item.idx += 1; self.cur_items.push(item); } else if token_name_eq(&t, token) { item.idx += 1; self.next_items.push(item); }"}
{"_id":"q-en-rust-1ff59c8648948705813d425bcf6e310212b37cdaef37d3cc18609e1417725269","text":"}; use rustc_hir::def_id::DefId; use rustc_macros::{LintDiagnostic, Subdiagnostic}; use rustc_middle::ty::{Predicate, Ty, TyCtxt}; use rustc_middle::ty::{PolyExistentialTraitRef, Predicate, Ty, TyCtxt}; use rustc_session::parse::ParseSess; use rustc_span::{edition::Edition, sym, symbol::Ident, Span, Symbol};"}
{"_id":"q-en-rust-201518e7a471880d5de4cd30ff7430e898742a384e17de9f515cb3581c89cd67","text":" // The error message here still is pretty confusing. fn main() { let mut result = vec![1]; // The type of `result` is constrained to be `Vec<{integer}>` here. // But the logic we use to find what expression constrains a type // is not sophisticated enough to know this. let mut vector = Vec::new(); vector.sort(); result.push(vector); //~^ ERROR mismatched types // So it thinks that the type of `result` is constrained here. } fn example2() { let mut x = vec![1]; x.push(\"\"); //~^ ERROR mismatched types } "}
{"_id":"q-en-rust-202dbb5a3b56371ffcf484bed5c5ada3f5cd99e346b369e1995a890d93aaa5b3","text":"/// /// assert_eq!(actual, expected); /// ``` #[unstable(feature = \"ptr_hash\", reason = \"newly added\", issue = \"56286\")] #[stable(feature = \"ptr_hash\", since = \"1.35.0\")] pub fn hash(hashee: *const T, into: &mut S) { use hash::Hash; hashee.hash(into);"}
{"_id":"q-en-rust-202e9ea6234d49e9486be204a086864d103beab5082f8d88e01a67303e59d194","text":"ENV TARGETS=$TARGETS,aarch64-fuchsia ENV TARGETS=$TARGETS,wasm32-unknown-unknown ENV TARGETS=$TARGETS,wasm32-wasi # FIXME(#61022) - reenable solaris # ENV TARGETS=$TARGETS,sparcv9-sun-solaris # ENV TARGETS=$TARGETS,x86_64-sun-solaris ENV TARGETS=$TARGETS,sparcv9-sun-solaris ENV TARGETS=$TARGETS,x86_64-sun-solaris ENV TARGETS=$TARGETS,x86_64-unknown-linux-gnux32 ENV TARGETS=$TARGETS,x86_64-unknown-cloudabi ENV TARGETS=$TARGETS,x86_64-fortanix-unknown-sgx"}
{"_id":"q-en-rust-2030b41956f1ac39fb2b551ebc6c5c90f2952cc30e33b3eb995a31630c9caf97","text":" // 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 or the MIT license // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. fn main() { let v = &[]; //~ ERROR cannot determine a type for this local variable: unconstrained type let it = v.iter(); } "}
{"_id":"q-en-rust-2037244389db9b9a3b19065e9f0fc3977f53a954ba992e7461e6900e46fbd0c8","text":"if w > 2 { val = utf8_acc_cont_byte!(val, s[i + 2]); } if w > 3 { val = utf8_acc_cont_byte!(val, s[i + 3]); } return CharRange {ch: unsafe { transmute(val as u32) }, next: i}; return CharRange {ch: unsafe { transmute(val) }, next: i}; } return multibyte_char_range_at_reverse(*self, prev);"}
{"_id":"q-en-rust-2038c89d7fc3b100fb60ca8b395199478d023a7c8ee89db8d0e63148e8d87f37","text":" // Copyright 2018 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 or the MIT license // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. #![feature(fn_traits)] fn main() { ::call; //~^ ERROR associated type bindings are not allowed here [E0229] } "}
{"_id":"q-en-rust-206fb8d110eaa902a892754da50270ec46650f4096261fec039e6f165747aec6","text":"| sym::default_lib_allocator | sym::start | sym::custom_mir, .. ] => {} [name, ..] => { match BUILTIN_ATTRIBUTE_MAP.get(name) { // checked below Some(BuiltinAttribute { type_: AttributeType::CrateLevel, .. }) => {} Some(_) => { // FIXME: differentiate between unstable and internal attributes just like we do with features instead // of just accepting `rustc_` attributes by name. That should allow trimming the above list, too. // FIXME: differentiate between unstable and internal attributes just // like we do with features instead of just accepting `rustc_` // attributes by name. That should allow trimming the above list, too. if !name.as_str().starts_with(\"rustc_\") { span_bug!( attr.span,"}
{"_id":"q-en-rust-2090e57d0624a1568785c284618483d213821ec3385063743ba70736df9c22f8","text":"repr_packed, repr_simd, repr_transparent, require, residual, result, rhs,"}
{"_id":"q-en-rust-21165f414a854d15c1935be77df9d1388f0a8704d2e2322f28a550a1ce11e680","text":" goto: file://|DOC_PATH|/lib2/struct.Foo.html // This test checks that the font weight is correctly applied. assert: (\"//*[@class='docblock type-decl']//a[text()='Alias']\", {\"font-weight\": \"400\"}) assert: (\"//*[@class='structfield small-section-header']//a[text()='Alias']\", {\"font-weight\": \"400\"}) assert: (\"#method.a_method > code\", {\"font-weight\": \"600\"}) assert: (\"#associatedtype.X > code\", {\"font-weight\": \"600\"}) assert: (\"#associatedconstant.Y > code\", {\"font-weight\": \"600\"}) "}
{"_id":"q-en-rust-212cc0932fb4e8631e7cf4471985e746c4d784b37055ad54a03265f444bf96ac","text":"} if let Some(ref dox) = i.impl_item.opt_doc_value() { if trait_.is_none() && i.inner_impl().items.is_empty() { if trait_.is_none() && impl_.items.is_empty() { w.write_str( \"
This impl block contains no items.
"}
{"_id":"q-en-rust-2139544592d01b88cf097e70c80b38daf4c57bc6f663f52aec2228bb898f8a95","text":" // Regression test for #121534 // Tests that no ICE occurs in KnownPanicsLint when it // evaluates an operation whose operands have different // layout types even though they have the same type. // This situation can be contrived through the use of // unions as in this test //@ build-pass union Union { u32_field: u32, i32_field: i32, } pub fn main() { let u32_variant = Union { u32_field: 2 }; let i32_variant = Union { i32_field: 3 }; let a = unsafe { u32_variant.u32_field }; let b = unsafe { i32_variant.u32_field }; let _diff = a - b; } "}
{"_id":"q-en-rust-214e132c49b265cedd29b99033be89db0bddf44e3ba013806046b6f06b09995d","text":" error: invalid `?` in type --> $DIR/issue-103748-ICE-wrong-braces.rs:3:36 | LL | struct Apple((Apple, Option(Banana ? Citron))); | ^ `?` is only allowed on expressions, not types | help: if you meant to express that the type might not contain a value, use the `Option` wrapper type | LL | struct Apple((Apple, Option(Option Citron))); | +++++++ ~ error: expected one of `)` or `,`, found `Citron` --> $DIR/issue-103748-ICE-wrong-braces.rs:3:38 | LL | struct Apple((Apple, Option(Banana ? Citron))); | -^^^^^^ expected one of `)` or `,` | | | help: missing `,` error[E0412]: cannot find type `Citron` in this scope --> $DIR/issue-103748-ICE-wrong-braces.rs:3:38 | LL | struct Apple((Apple, Option(Banana ? Citron))); | ^^^^^^ not found in this scope error[E0214]: parenthesized type parameters may only be used with a `Fn` trait --> $DIR/issue-103748-ICE-wrong-braces.rs:3:22 | LL | struct Apple((Apple, Option(Banana ? Citron))); | ^^^^^^^^^^^^^^^^^^^^^^^ only `Fn` traits may use parentheses | help: use angle brackets instead | LL | struct Apple((Apple, Option)); | ~ ~ error[E0072]: recursive type `Apple` has infinite size --> $DIR/issue-103748-ICE-wrong-braces.rs:3:1 | LL | struct Apple((Apple, Option(Banana ? Citron))); | ^^^^^^^^^^^^ ----- recursive without indirection | help: insert some indirection (e.g., a `Box`, `Rc`, or `&`) to break the cycle | LL | struct Apple((Box, Option(Banana ? Citron))); | ++++ + error: aborting due to 5 previous errors Some errors have detailed explanations: E0072, E0214, E0412. For more information about an error, try `rustc --explain E0072`. "}
{"_id":"q-en-rust-217f3555e35d74e60ea6b9a32d25835584f1964c109f36bba74e805304f965a0","text":"// Multibyte case is a fn to allow char_range_at to inline cleanly fn multibyte_char_range_at(s: &str, i: uint) -> CharRange { let mut val = s[i] as uint; let mut val = s[i] as u32; let w = UTF8_CHAR_WIDTH[val] as uint; assert!((w != 0));"}
{"_id":"q-en-rust-2185c11d719580ae6a96bf23adb79035c9d3125dbd763d73071a729c1a03be63","text":"let crate_types = if options.proc_macro_crate { vec![config::CrateType::ProcMacro] } else { vec![config::CrateType::Dylib] vec![config::CrateType::Rlib] }; let sessopts = config::Options {"}
{"_id":"q-en-rust-21c1a25f20443dc0f5f80d4b56059c6b2af3768650669a2eedf50375d0cb78a8","text":"#![feature(ptr_offset_from)] #![feature(rustc_attrs)] #![feature(receiver_trait)] #![feature(slice_from_raw_parts)] #![feature(specialization)] #![feature(staged_api)] #![feature(std_internals)]"}
{"_id":"q-en-rust-21e613c3b1faf714a8b18ba641183acce7f8376d10a99067558b8cb537b55083","text":"#[doc(keyword = \"struct\")] // /// The `struct` keyword. /// The keyword used to define structs. /// /// The `struct` keyword is used to define a struct type. /// Structs in Rust come in three flavours: Regular structs, tuple structs, /// and empty structs. /// /// Example: /// ```rust /// struct Regular { /// field1: f32, /// field2: String, /// pub field3: bool /// } /// /// struct Tuple(u32, String); /// /// struct Empty; /// ``` /// struct Foo { /// field1: u32, /// field2: String, /// /// Regular structs are the most commonly used. Each field defined within them has a name and a /// type, and once defined can be accessed using `example_struct.field` syntax. The fields of a /// struct share its mutability, so `foo.bar = 2;` would only be valid if `foo` was mutable. Adding /// `pub` to a field makes it visible to code in other modules, as well as allowing it to be /// directly accessed and modified. /// /// Tuple structs are similar to regular structs, but its fields have no names. They are used like /// tuples, with deconstruction possible via `let TupleStruct(x, y) = foo;` syntax. For accessing /// individual variables, the same syntax is used as with regular tuples, namely `foo.0`, `foo.1`, /// etc, starting at zero. /// /// Empty structs, or unit-like structs, are most commonly used as markers, for example /// [`PhantomData`]. Empty structs have a size of zero bytes, but unlike empty enums they can be /// instantiated, making them similar to the unit type `()`. Unit-like structs are useful when you /// need to implement a trait on something, but don't need to store any data inside it. /// /// # Instantiation /// /// Structs can be instantiated in a manner of different ways, each of which can be mixed and /// matched as needed. The most common way to make a new struct is via a constructor method such as /// `new()`, but when that isn't available (or you're writing the constructor itself), struct /// literal syntax is used: /// /// ```rust /// # struct Foo { field1: f32, field2: String, etc: bool } /// let example = Foo { /// field1: 42.0, /// field2: \"blah\".to_string(), /// etc: true, /// }; /// ``` /// /// It's only possible to directly instantiate a struct using struct literal syntax when all of its /// fields are visible to you. /// /// There are a handful of shortcuts provided to make writing constructors more convenient, most /// common of which is the Field Init shorthand. When there is a variable and a field of the same /// name, the assignment can be simplified from `field: field` into simply `field`. The following /// example of a hypothetical constructor demonstrates this: /// /// ```rust /// struct User { /// name: String, /// admin: bool, /// } /// /// impl User { /// pub fn new(name: String) -> Self { /// Self { /// name, /// admin: false, /// } /// } /// } /// ``` /// /// Another shortcut for struct instantiation is available, used when you need to make a new /// struct that has the same values as most of a previous struct of the same type, called struct /// update syntax: /// /// ```rust /// # struct Foo { field1: String, field2: () } /// # let thing = Foo { field1: \"\".to_string(), field2: () }; /// let updated_thing = Foo { /// field1: \"a new value\".to_string(), /// ..thing /// }; /// ``` /// /// There are different kinds of structs. For more information, take a look at the /// [Rust Book][book]. /// Tuple structs are instantiated in the same way as tuples themselves, except with the struct's /// name as a prefix: `Foo(123, false, 0.1)`. /// /// Empty structs are instantiated with just their name, and don't need anything else. `let thing = /// EmptyStruct;` /// /// # Style conventions /// /// Structs are always written in CamelCase, with few exceptions. While the trailing comma on a /// struct's list of fields can be omitted, it's usually kept for convenience in adding and /// removing fields down the line. /// /// For more information on structs, take a look at the [Rust Book][book] or the /// [Reference][reference]. /// /// [`PhantomData`]: marker/struct.PhantomData.html /// [book]: https://doc.rust-lang.org/book/second-edition/ch05-01-defining-structs.html /// [reference]: https://doc.rust-lang.org/reference/items/structs.html mod struct_keyword { }"}
{"_id":"q-en-rust-22b172c85ea0f880cac595f835737979c74284275326a223ff9b0da0810e1885","text":"let mut _0: *const &u8; let mut _2: *const &u8; let mut _3: *const &u8; let mut _4: *const &u8; scope 1 (inlined generic_cast::<&u8, &u8>) { debug x => _3; let mut _4: *const &u8; debug x => _4; let mut _5: *const &u8; } bb0: { StorageLive(_2); StorageLive(_3); _3 = _1; StorageLive(_4); _4 = _3; - _2 = move _4 as *const &u8 (PtrToPtr); + _2 = move _4; _4 = _1; StorageLive(_5); _5 = _4; - _3 = move _5 as *const &u8 (PtrToPtr); + _3 = move _5; StorageDead(_5); StorageDead(_4); StorageDead(_3); - _2 = move _3 as *const &u8 (PtrToPtr); + _2 = move _3; _0 = _2; StorageDead(_3); StorageDead(_2); return; }"}
{"_id":"q-en-rust-22c8b826dc1759574aed457e25d6a569168c4ac05932b876fbb1262d6dba6511","text":"// extern-return-TwoU64s // foreign-fn-with-byval // issue-28676 // issue-62350-sysv-neg-reg-counts // struct-return // ignore-android"}
{"_id":"q-en-rust-232115002819804541bca4b9ca369167bda6a4ecfb4dfb35cc6435b6aa9bf328","text":"} // Determine if a node with the given attributes should be included in this configuation. fn in_cfg(&mut self, attrs: &[ast::Attribute]) -> bool { pub fn in_cfg(&mut self, attrs: &[ast::Attribute]) -> bool { attrs.iter().all(|attr| { // When not compiling with --test we should not compile the #[test] functions if !self.should_test && is_test_or_bench(attr) {"}
{"_id":"q-en-rust-235f3ce6fd3365a857a117f30c0a12690726a1aef3783508005c55dbc99fc383","text":" // 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 or the MIT license // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. // error-pattern:explicit failure pub fn main() { fail!(); println!(\"{}\", 1i); } "}
{"_id":"q-en-rust-23b8a63dbb5cf1492a3b8721f7b56b6e42e4b3e6cad48284093b46d4ca1128b9","text":"There’s just one line of this first example left: ```rust,ignore println!(\"You guessed: {}\", input); println!(\"You guessed: {}\", guess); } ``` This prints out the string we saved our input in. The `{}`s are a placeholder, and so we pass it `input` as an argument. If we had multiple `{}`s, we would and so we pass it `guess` as an argument. If we had multiple `{}`s, we would pass multiple arguments: ```rust"}
{"_id":"q-en-rust-23d90071ecaa24e475f6121790b95a7e6097e22eb7e26e4b7ff65b9222ad5743","text":" // compile-flags: -Zsave-analysis // only-x86_64 // Also test for #72960 #![feature(asm)]"}
{"_id":"q-en-rust-24273e92ffa86722e033fad957ab7e07b321364454cdda7964847f949bd6fefd","text":"}; ``` At the moment, `if` and `match`, as well as the looping constructs `for`, `while`, and `loop`, are forbidden inside a `const`, `static`, or `const fn`. At the moment, `for` loops, `.await`, and the `Try` operator (`?`) are forbidden inside a `const`, `static`, or `const fn`. This will be allowed at some point in the future, but the implementation is not yet complete. See the tracking issue for [conditionals] or [loops] in a const context for the current status. This may be allowed at some point in the future, but the implementation is not yet complete. See the tracking issues for [`async`] and [`?`] in `const fn`, and (to support `for` loops in `const fn`) the tracking issues for [`impl const Trait for Ty`] and [`&mut T`] in `const fn`. [conditionals]: https://github.com/rust-lang/rust/issues/49146 [loops]: https://github.com/rust-lang/rust/issues/52000 [`async`]: https://github.com/rust-lang/rust/issues/69431 [`?`]: https://github.com/rust-lang/rust/issues/74935 [`impl const Trait for Ty`]: https://github.com/rust-lang/rust/issues/67792 [`&mut T`]: https://github.com/rust-lang/rust/issues/57349 "}
{"_id":"q-en-rust-243b21ac619c9029c3bc517719f0e59b6d0acd468feac2459e0479267652a915","text":" error[E0597]: borrowed value does not live long enough --> $DIR/issue-52049.rs:16:10 | LL | foo(&unpromotable(5u32)); | ^^^^^^^^^^^^^^^^^^ - temporary value only lives until here | | | temporary value does not live long enough | = note: borrowed value must be valid for the static lifetime... error: aborting due to previous error For more information about this error, try `rustc --explain E0597`. "}
{"_id":"q-en-rust-2451b88c0cc752a6725a450675fa35cb2eef911c05c4b3a722e5d7a29d0e6ec9","text":"id, expr_ty.repr(self.tcx()), def); match def { def::DefStruct(..) | def::DefVariant(..) => { def::DefStruct(..) | def::DefVariant(..) | def::DefFn(..) | def::DefStaticMethod(..) => { Ok(self.cat_rvalue_node(id, span, expr_ty)) } def::DefFn(..) | def::DefStaticMethod(..) | def::DefMod(_) | def::DefForeignMod(_) | def::DefStatic(_, false) | def::DefMod(_) | def::DefForeignMod(_) | def::DefStatic(_, false) | def::DefUse(_) | def::DefTrait(_) | def::DefTy(_) | def::DefPrimTy(_) | def::DefTyParam(..) | def::DefTyParamBinder(..) | def::DefRegion(_) | def::DefLabel(_) | def::DefSelfTy(..) | def::DefMethod(..) => {"}
{"_id":"q-en-rust-2473453dbc575b939318490d6f89d2b5eb5746cd74658826cc1b9404039f5e44","text":" // Copyright 2017 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 or the MIT license // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. struct Foo; fn main() { || if let Foo::NotEvenReal() = Foo {}; //~ ERROR E0599 } "}
{"_id":"q-en-rust-2483d863943b6aa71d4fa027394680bd88fb2d6e978e117ae611e32d2f7eb360","text":"#[diag(parse_use_eq_instead)] pub(crate) struct UseEqInstead { #[primary_span] #[suggestion(style = \"verbose\", applicability = \"machine-applicable\", code = \"=\")] pub span: Span, #[suggestion(style = \"verbose\", applicability = \"machine-applicable\", code = \"\")] pub suggestion: Span, } #[derive(Diagnostic)]"}
{"_id":"q-en-rust-24a20abf51cce5104541d084ba7b16884f5909a3eb5dc88fc1df74841398e6be","text":" // Copyright 2017 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 or the MIT license // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. trait Foo { const AMT: usize; } enum Bar { First(A), Second(B), } impl Foo for Bar { const AMT: usize = [A::AMT][(A::AMT > B::AMT) as usize]; //~ ERROR constant evaluation } impl Foo for u8 { const AMT: usize = 1; } impl Foo for u16 { const AMT: usize = 2; } fn main() { println!(\"{}\", as Foo>::AMT); } "}
{"_id":"q-en-rust-24bef5309ff4893abd597dd15b6d1f941a011815e7ab0fd7ee836726cb11fc3d","text":"use crate::build::{BlockAnd, BlockAndExtension, Builder}; use crate::build::{GuardFrame, GuardFrameLocal, LocalsForNode}; use crate::hair::{self, *}; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_data_structures::{fx::{FxHashMap, FxHashSet}, stack::ensure_sufficient_stack}; use rustc_hir::HirId; use rustc_index::bit_set::BitSet; use rustc_middle::middle::region;"}
{"_id":"q-en-rust-24cf365c5a570063ffc44044fcfc4dd13486fd9136ec93191eb1746b996dba13","text":" //@ check-pass //@ edition: 2021 #![feature(async_closure)] // Make sure that we don't hit a query cycle when validating // the by-move coroutine body for an async closure. use std::future::Future; async fn test(operation: impl Fn() -> Fut) { operation().await; } pub async fn orchestrate_simple_crud() { test(async || async {}.await).await; } fn main() {} "}
{"_id":"q-en-rust-24e05572bc32be741f57a94cd225572b6bb9c6933f06334c60cc34d6718e6031","text":" //@ aux-build:implied-predicates.rs //@ check-pass extern crate implied_predicates; use implied_predicates::Bar; fn bar() {} fn main() {} "}
{"_id":"q-en-rust-24fd671a6e92215aa5f15fc7c36c00d6cd02bc668c2f9d59b6d69b6955e32a3e","text":"} code, pre, h1.fqn { font-family: Menlo, Monaco, Consolas, \"Inconsolata\", \"Courier New\", monospace; font-family: \"Inconsolata\", Menlo, Monaco, Consolas, \"DejaVu Sans Mono\", monospace; } code, pre { color: #333;"}
{"_id":"q-en-rust-24ff8d628c6040a1839cb428d533408539c0e0affbece0ef561915d222934519","text":" // 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 or the MIT license // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. // aux-build:issue-30535.rs extern crate issue_30535 as foo; fn bar( _: foo::Foo::FooV //~ ERROR value `foo::Foo::FooV` used as a type ) {} fn main() {} "}
{"_id":"q-en-rust-25216c979b5d60ec2c09044aae0c023aa2587c352cccba461cb948a43e24a918","text":"message.push_str(&format!(\" ({})\", feature)); if let Some(unstable_reason) = reason { let mut ids = cx.id_map.borrow_mut(); message = format!( \"{}{}\", message, MarkdownHtml( &unstable_reason.as_str(), &mut ids, error_codes, cx.shared.edition(), &cx.shared.playground, ) .into_string() ); } extra_info.push(format!(\"
{}
\", message)); }"}
{"_id":"q-en-rust-2537b17f4d84b6f7b33527d39d7b4238f0db2b2044a98accf3ef4f10325bd8cd","text":"let file = annotated_file.file.clone(); let line = &annotated_file.lines[line_idx]; if let Some(source_string) = file.get_line(line.line_index - 1) { let leading_whitespace = source_string.chars().take_while(|c| c.is_whitespace()).count(); let leading_whitespace = source_string .chars() .take_while(|c| c.is_whitespace()) .map(|c| { match c { // Tabs are displayed as 4 spaces 't' => 4, _ => 1, } }) .sum(); if source_string.chars().any(|c| !c.is_whitespace()) { whitespace_margin = min(whitespace_margin, leading_whitespace); }"}
{"_id":"q-en-rust-258e3fdc479ae2342449d856fec0518e14fad0fdd23f2f49f98f8a4c0462813d","text":"candidates.ambiguous = true; // Could wind up being a fn() type. } // Provide an impl, but only for suitable `fn` pointers. ty::FnDef(..) | ty::FnPtr(_) => { ty::FnPtr(_) => { if let ty::FnSig { unsafety: hir::Unsafety::Normal, abi: Abi::Rust,"}
{"_id":"q-en-rust-259772f739ec95d2a3c94131978ec55e853585730317b553df06a55d7ecd2dd3","text":"traits_in_scope: Default::default(), all_traits: Default::default(), all_trait_impls: Default::default(), document_private_items, }; // Because of the `crate::` prefix, any doc comment can reference"}
{"_id":"q-en-rust-25dd76d98bad1d92511143fb7a70649fdbb8c99815f50b87f46234dd59cffd4b","text":" // compile-pass // note this was only reproducible with lib crates // compile-flags: --crate-type=lib pub struct Hz; impl Hz { pub const fn num(&self) -> u32 { 42 } pub const fn normalized(&self) -> Hz { Hz } pub const fn as_u32(&self) -> u32 { self.normalized().num() // this used to promote the `self.normalized()` } } "}
{"_id":"q-en-rust-25f4e6ade0b3c8083df4e12f9d4919cd7c6d70b389e7632a3cba0acef8e7b680","text":"/// does not have any \"extra\" NaN payloads, then the output NaN is guaranteed to be preferred. /// /// The non-deterministic choice happens when the operation is executed; i.e., the result of a /// NaN-producing floating point operation is a stable bit pattern (looking at these bits multiple /// NaN-producing floating-point operation is a stable bit pattern (looking at these bits multiple /// times will yield consistent results), but running the same operation twice with the same inputs /// can produce different results. ///"}
{"_id":"q-en-rust-2600f6d77fd8753946b597076f2240036951454145902538f47e1f1a32bc6e6f","text":"#[stable(feature = \"unicode_version\", since = \"1.45.0\")] pub use crate::unicode::UNICODE_VERSION; // perma-unstable re-exports #[unstable(feature = \"char_internals\", reason = \"exposed only for libstd\", issue = \"none\")] pub use self::methods::encode_utf16_raw; #[unstable(feature = \"char_internals\", reason = \"exposed only for libstd\", issue = \"none\")] pub use self::methods::encode_utf8_raw; use crate::fmt::{self, Write}; use crate::iter::FusedIterator;"}
{"_id":"q-en-rust-2607f660ffef6b242674cd4e237e47506c4500b0796b82171075a4f8d9bf5730","text":"))] mod imp { use super::Handler; use crate::io; use crate::mem; use crate::ptr;"}
{"_id":"q-en-rust-2625c7e16728c8a0ca323c0f2bb626eaf8f0939beb232921619cb3dc9273a09b","text":"} else { val + n }; // zero the upper bits let val = val as u128; let val = (val << amt) >> amt; (Self { val: val as u128, ty: self.ty, }, oflo) } else { let (min, max) = match int { Integer::I8 => (u8::min_value() as u128, u8::max_value() as u128), Integer::I16 => (u16::min_value() as u128, u16::max_value() as u128), Integer::I32 => (u32::min_value() as u128, u32::max_value() as u128), Integer::I64 => (u64::min_value() as u128, u64::max_value() as u128), Integer::I128 => (u128::min_value(), u128::max_value()), }; let max = u128::max_value() >> amt; let val = self.val; let oflo = val > max - n; let val = if oflo { min + (n - (max - val) - 1) n - (max - val) - 1 } else { val + n };"}
{"_id":"q-en-rust-26505605ebe0721308d904e640ffd219627b5fd419c46969ebb48fe9ed503d4f","text":"pub fn fully_expand_fragment(&mut self, input_fragment: AstFragment) -> AstFragment { let orig_expansion_data = self.cx.current_expansion.clone(); let orig_force_mode = self.cx.force_mode; self.cx.current_expansion.depth = 0; // Collect all macro invocations and replace them with placeholders. let (mut fragment_with_placeholders, mut invocations) ="}
{"_id":"q-en-rust-265e0178b3d6b8da030e87c22d167887e1f629d864ee738d0099263256c4eca5","text":".RE .TP fB-lfR [fIKINDfR=]fINAMEfR Link the generated crate(s) to the specified native library fINAMEfR. Link the generated crate(s) to the specified library fINAMEfR. The optional fIKINDfR can be one of fIstaticfR, fIdylibfR, or fIframeworkfR. If omitted, fIdylibfR is assumed."}
{"_id":"q-en-rust-267178c1ee6b5f3eb90de3c4f96bc6a79991c1fcf235d89566ddb330f7a8a9d9","text":"/// let localhost = Ipv4Addr::new(127, 0, 0, 1); /// assert_eq!(\"127.0.0.1\".parse(), Ok(localhost)); /// assert_eq!(localhost.is_loopback(), true); /// assert!(\"012.004.002.000\".parse::().is_err()); // all octets are in octal /// assert!(\"0000000.0.0.0\".parse::().is_err()); // first octet is a zero in octal /// assert!(\"0xcb.0x0.0x71.0x00\".parse::().is_err()); // all octets are in hex /// ``` #[derive(Copy)] #[stable(feature = \"rust1\", since = \"1.0.0\")]"}
{"_id":"q-en-rust-268303e4ae6a3b5270d7511a8e956ef6fcd1ffc1f3b19ab30bd3f444d0f91ba8","text":".collect(), _ => Vec::new(), }; candidates.retain(|candidate| *candidate != self.tcx.parent(result.callee.def_id)); return Err(IllegalSizedBound(candidates, needs_mut, span)); }"}
{"_id":"q-en-rust-2685211d7a9cac923a0c603cae472ee4269a41d6ed3b4d0f3d220ad8090303d8","text":"/// /// Note that this call does not perform any actual network communication, /// because UDP is a datagram protocol. #[deprecated = \"`UdpStream` has been deprecated\"] #[allow(deprecated)] pub fn connect(self, other: SocketAddr) -> UdpStream { UdpStream { socket: self,"}
{"_id":"q-en-rust-269b5b3df4dc1dea80271fd6694b747e495f54a389f9a892987fbdc08036afec","text":" // compile-flags: --document-private-items // This ensures that no ICE is triggered when rustdoc is run on this code. mod stdlib { pub (crate) use std::i8; } "}
{"_id":"q-en-rust-26a527f2ce582dd1ea35b248df0ce5c64dc026f8fdc052b516954be85338f400","text":"fn has_errors(&self) -> bool { self.err_count() > 0 } fn has_errors_or_delayed_span_bugs(&self) -> bool { self.has_errors() || !self.delayed_span_bugs.is_empty() } fn abort_if_errors_and_should_abort(&mut self) { self.emit_stashed_diagnostics();"}
{"_id":"q-en-rust-26d4c51732e08f7bf7c5e7cd4d27b558ab7d4598d5371447f4d73e8cec6c0c57","text":"/// This unifies the logic used for resolving `include_X!`, and `#[doc(include)]` file paths. /// /// Returns an absolute path to the file that `path` refers to. pub fn resolve_path(&self, path: impl Into, span: Span) -> PathBuf { pub fn resolve_path( &self, path: impl Into, span: Span, ) -> Result> { let path = path.into(); // Relative paths are resolved relative to the file in which they are found"}
{"_id":"q-en-rust-274829340f6bf4d0830a6e54879840480bc4141308a2b8e5367245bbfec991ca","text":"// The root node must be created with create_root_def() assert!(data != DefPathData::CrateRoot); // Find a unique DefKey. This basically means incrementing the disambiguator // until we get no match. let mut key = DefKey { // Find the next free disambiguator for this key. let disambiguator = { let next_disamb = self.next_disambiguator.entry((parent, data.clone())).or_insert(0); let disambiguator = *next_disamb; *next_disamb = next_disamb.checked_add(1).expect(\"disambiguator overflow\"); disambiguator }; let key = DefKey { parent: Some(parent), disambiguated_data: DisambiguatedDefPathData { data, disambiguator: 0 data, disambiguator } }; while self.keys_created.contains(&key) { key.disambiguated_data.disambiguator += 1; } self.keys_created.insert(key.clone()); let parent_hash = self.table.def_path_hash(parent); let def_path_hash = key.compute_stable_hash(parent_hash);"}
{"_id":"q-en-rust-2760faaeabc1bfffa90d5aec6f09820666e7f80e1e3364f1c9b3620bd7a34a5d","text":" // Regression test for the ICE described in #87496. // check-pass #[repr(transparent)] struct TransparentCustomZst(()); extern \"C\" { fn good17(p: TransparentCustomZst); //~^ WARNING: `extern` block uses type `TransparentCustomZst`, which is not FFI-safe } fn main() {} "}
{"_id":"q-en-rust-276a51299151cf06ac77a38694f4309c68ef6bd0ee9fd477132d9bd62cb8d0df","text":"let lib_llvm = out_dir.join(\"build\").join(\"lib\").join(lib_name); if !lib_llvm.exists() { t!(builder.symlink_file(\"libLLVM.dylib\", &lib_llvm)); t!(builder.build.config.symlink_file(\"libLLVM.dylib\", &lib_llvm)); } }"}
{"_id":"q-en-rust-2782c47b5ac722cf97c57720a810c0619139cd0080f7faff1698f5898b45fc9c","text":"if let DefKind::Trait = def_kind { record!(self.tables.trait_def[def_id] <- self.tcx.trait_def(def_id)); record!(self.tables.super_predicates_of[def_id] <- self.tcx.super_predicates_of(def_id)); record!(self.tables.implied_predicates_of[def_id] <- self.tcx.implied_predicates_of(def_id)); let module_children = self.tcx.module_children_local(local_id); record_array!(self.tables.module_children_non_reexports[def_id] <-"}
{"_id":"q-en-rust-2817b2d2b5341e92b51bb73fe73a8a56273c3448ca7a9a1373cecd6aceea77c5","text":"// Only pass correct values for these flags for the `run-make` suite as it // requires that a C++ compiler was configured which isn't always the case. if suite == \"run-make\" { let llvm_config = build.llvm_config(target); let llvm_components = output(Command::new(&llvm_config).arg(\"--components\")); let llvm_cxxflags = output(Command::new(&llvm_config).arg(\"--cxxflags\")); cmd.arg(\"--cc\").arg(build.cc(target))"}
{"_id":"q-en-rust-28858d2d686b7e5d46c9366ab157d89d824493d0ffdcca159eb83e28f7528684","text":"| help: replace with the correct return type: `main::FnTest9` error[E0121]: the type placeholder `_` is not allowed within types on item signatures --> $DIR/typeck_type_placeholder_item.rs:199:14 --> $DIR/typeck_type_placeholder_item.rs:201:14 | LL | type A = _; | ^ not allowed in type signatures error[E0121]: the type placeholder `_` is not allowed within types on item signatures --> $DIR/typeck_type_placeholder_item.rs:201:14 --> $DIR/typeck_type_placeholder_item.rs:203:14 | LL | type B = _; | ^ not allowed in type signatures error[E0121]: the type placeholder `_` is not allowed within types on item signatures --> $DIR/typeck_type_placeholder_item.rs:203:14 --> $DIR/typeck_type_placeholder_item.rs:205:14 | LL | const C: _; | ^ not allowed in type signatures error[E0121]: the type placeholder `_` is not allowed within types on item signatures --> $DIR/typeck_type_placeholder_item.rs:206:14 --> $DIR/typeck_type_placeholder_item.rs:208:14 | LL | const D: _ = 42; | ^"}
{"_id":"q-en-rust-288de0beb712496a5ce473b849eb6e23b69a65e5183ee4df2ad17773e1743d87","text":"pub fn is_file(&self) -> bool { self.0.is_file() } /// Test whether this file type represents a symbolic link. /// The result is mutually exclusive to the results of /// [`is_dir`] and [`is_file`]; only zero or one of these /// tests may pass. /// /// The underlying [`Metadata`] struct needs to be retrieved /// with the [`fs::symlink_metadata`] function and not the"}
{"_id":"q-en-rust-28ceae6a505a799cb0cdfda0ad0c5386fd09df6ae4ecf8fd1edc31793959f86b","text":"f.write_str(\" \")?; if let Some(ref ty) = self.trait_ { match self.polarity { ty::ImplPolarity::Positive | ty::ImplPolarity::Reservation => {} ty::ImplPolarity::Negative => write!(f, \"!\")?, if self.is_negative_trait_impl() { write!(f, \"!\")?; } ty.print(cx).fmt(f)?; write!(f, \" for \")?;"}
{"_id":"q-en-rust-28d97051604a7bd90121d939192bc67378cc12375251b65afb33ab3cacfe6f38","text":"use rustc_hir::Node; use rustc_middle::dep_graph::DepContext; use rustc_middle::ty::print::with_no_trimmed_paths; use rustc_middle::ty::relate::{self, RelateResult, TypeRelation}; use rustc_middle::ty::{ self, error::TypeError, Binder, List, Region, Subst, Ty, TyCtxt, TypeFoldable, TypeSuperVisitable, TypeVisitable,"}
{"_id":"q-en-rust-290adaaea08ce867f35f0515b1b800b7733551e1a92e00a68652683bb0b70fa2","text":"return; } // FIXME(#99978) hide #[no_mangle] symbols for proc-macros let is_windows = self.sess.target.is_like_windows; let path = tmpdir.join(if is_windows { \"list.def\" } else { \"list\" });"}
{"_id":"q-en-rust-295eba40831de44f4ff108ee8ec97d6820997a51b20fb40448d512de324dfe88","text":"self.as_mut_vec().truncate(0); // verbatim paths need . and .. removed } else if comps.prefix_verbatim() { } else if comps.prefix_verbatim() && !path.inner.is_empty() { let mut buf: Vec<_> = comps.collect(); for c in path.components() { match c {"}
{"_id":"q-en-rust-29800fedf683c26d33171651277bef4d925f428e8d59a37d4774e44aa4cbd857","text":"split_or_candidate |= self.simplify_candidate(candidate); } if split_or_candidate { // At least one of the candidates has been split into subcandidates. // We need to change the candidate list to include those. let mut new_candidates = Vec::new(); ensure_sufficient_stack(|| { if split_or_candidate { // At least one of the candidates has been split into subcandidates. // We need to change the candidate list to include those. let mut new_candidates = Vec::new(); for candidate in candidates { candidate.visit_leaves(|leaf_candidate| new_candidates.push(leaf_candidate)); for candidate in candidates { candidate.visit_leaves(|leaf_candidate| new_candidates.push(leaf_candidate)); } self.match_simplified_candidates( span, start_block, otherwise_block, &mut *new_candidates, fake_borrows, ); } else { self.match_simplified_candidates( span, start_block, otherwise_block, candidates, fake_borrows, ); } self.match_simplified_candidates( span, start_block, otherwise_block, &mut *new_candidates, fake_borrows, ); } else { self.match_simplified_candidates( span, start_block, otherwise_block, candidates, fake_borrows, ); }; }); } fn match_simplified_candidates("}
{"_id":"q-en-rust-29b1d091d91bc890b93a551c41ccfedcc3854aefa1b44caf192bf617149ecb59","text":"} } #[stable(feature = \"rust1\", since = \"1.0.0\")] impl Seek for File { impl Seek for &File { fn seek(&mut self, pos: SeekFrom) -> io::Result { self.inner.seek(pos) } } #[stable(feature = \"rust1\", since = \"1.0.0\")] impl Read for &File { impl Read for File { fn read(&mut self, buf: &mut [u8]) -> io::Result { self.inner.read(buf) (&*self).read(buf) } fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> io::Result { (&*self).read_vectored(bufs) } fn read_buf(&mut self, cursor: BorrowedCursor<'_>) -> io::Result<()> { self.inner.read_buf(cursor) (&*self).read_buf(cursor) } #[inline] fn is_read_vectored(&self) -> bool { (&&*self).is_read_vectored() } fn read_to_end(&mut self, buf: &mut Vec) -> io::Result { (&*self).read_to_end(buf) } fn read_to_string(&mut self, buf: &mut String) -> io::Result { (&*self).read_to_string(buf) } } #[stable(feature = \"rust1\", since = \"1.0.0\")] impl Write for File { fn write(&mut self, buf: &[u8]) -> io::Result { (&*self).write(buf) } fn write_vectored(&mut self, bufs: &[IoSlice<'_>]) -> io::Result { (&*self).write_vectored(bufs) } #[inline] fn is_write_vectored(&self) -> bool { (&&*self).is_write_vectored() } fn flush(&mut self) -> io::Result<()> { (&*self).flush() } } #[stable(feature = \"rust1\", since = \"1.0.0\")] impl Seek for File { fn seek(&mut self, pos: SeekFrom) -> io::Result { (&*self).seek(pos) } } #[stable(feature = \"io_traits_arc\", since = \"CURRENT_RUSTC_VERSION\")] impl Read for Arc { fn read(&mut self, buf: &mut [u8]) -> io::Result { (&**self).read(buf) } fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> io::Result { self.inner.read_vectored(bufs) (&**self).read_vectored(bufs) } fn read_buf(&mut self, cursor: BorrowedCursor<'_>) -> io::Result<()> { (&**self).read_buf(cursor) } #[inline] fn is_read_vectored(&self) -> bool { self.inner.is_read_vectored() (&**self).is_read_vectored() } // Reserves space in the buffer based on the file size when available. fn read_to_end(&mut self, buf: &mut Vec) -> io::Result { let size = buffer_capacity_required(self); buf.reserve(size.unwrap_or(0)); io::default_read_to_end(self, buf, size) (&**self).read_to_end(buf) } // Reserves space in the buffer based on the file size when available. fn read_to_string(&mut self, buf: &mut String) -> io::Result { let size = buffer_capacity_required(self); buf.reserve(size.unwrap_or(0)); io::default_read_to_string(self, buf, size) (&**self).read_to_string(buf) } } #[stable(feature = \"rust1\", since = \"1.0.0\")] impl Write for &File { #[stable(feature = \"io_traits_arc\", since = \"CURRENT_RUSTC_VERSION\")] impl Write for Arc { fn write(&mut self, buf: &[u8]) -> io::Result { self.inner.write(buf) (&**self).write(buf) } fn write_vectored(&mut self, bufs: &[IoSlice<'_>]) -> io::Result { self.inner.write_vectored(bufs) (&**self).write_vectored(bufs) } #[inline] fn is_write_vectored(&self) -> bool { self.inner.is_write_vectored() (&**self).is_write_vectored() } fn flush(&mut self) -> io::Result<()> { self.inner.flush() (&**self).flush() } } #[stable(feature = \"rust1\", since = \"1.0.0\")] impl Seek for &File { #[stable(feature = \"io_traits_arc\", since = \"CURRENT_RUSTC_VERSION\")] impl Seek for Arc { fn seek(&mut self, pos: SeekFrom) -> io::Result { self.inner.seek(pos) (&**self).seek(pos) } }"}
{"_id":"q-en-rust-29b210d7b129725099942add3f5c16ab63c953068e59754410e2cf13d573c49c","text":"const D: _ = 42; //~^ ERROR the type placeholder `_` is not allowed within types on item signatures // type E: _; // FIXME: make the parser propagate the existence of `B` type F: std::ops::Fn(_); //~^ ERROR the type placeholder `_` is not allowed within types on item signatures } impl Qux for Struct { type A = _;"}
{"_id":"q-en-rust-29b54cc1c5ab7694902a71ce647ec20de1c13371d067f270af4f31eeb4d9d94b","text":"target } const MAX_INT_REGS: usize = 6; // RDI, RSI, RDX, RCX, R8, R9 const MAX_SSE_REGS: usize = 8; // XMM0-7 pub fn compute_abi_info<'a, Ty, C>(cx: &C, fty: &mut FnType<'a, Ty>) where Ty: TyLayoutMethods<'a, C> + Copy, C: LayoutOf> + HasDataLayout { let mut int_regs = 6; // RDI, RSI, RDX, RCX, R8, R9 let mut sse_regs = 8; // XMM0-7 let mut int_regs = MAX_INT_REGS; let mut sse_regs = MAX_SSE_REGS; let mut x86_64_ty = |arg: &mut ArgType<'a, Ty>, is_arg: bool| { let mut cls_or_mem = classify_arg(cx, arg); let mut needed_int = 0; let mut needed_sse = 0; if is_arg { if let Ok(cls) = cls_or_mem { let mut needed_int = 0; let mut needed_sse = 0; for &c in &cls { match c { Some(Class::Int) => needed_int += 1,"}
{"_id":"q-en-rust-29ed1a55cccf3c47678204bfa5e64c5ec66d8eac5259f55f47545780ad95fa75","text":"err.help(\"the semantics of slice patterns changed recently; see issue #62254\"); } else if self.autoderef(span, expected_ty) .any(|(ty, _)| matches!(ty.kind(), ty::Slice(..) | ty::Array(..))) && let (Some(span), true) = (ti.span, ti.origin_expr) && let Some(span) = ti.span && let Some(_) = ti.origin_expr && let Ok(snippet) = self.tcx.sess.source_map().span_to_snippet(span) { let ty = self.resolve_vars_if_possible(ti.expected);"}
{"_id":"q-en-rust-2a1860437e89293804a134231695bc016a781a1749ab3feea0be321f64f63f0c","text":"use rustc_hir::intravisit::{self, Visitor}; use rustc_hir::Node; use rustc_middle::bug; use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags; use rustc_middle::middle::codegen_fn_attrs::{CodegenFnAttrFlags, CodegenFnAttrs}; use rustc_middle::middle::privacy::{self, Level}; use rustc_middle::mir::interpret::{ConstAllocation, ErrorHandled, GlobalAlloc}; use rustc_middle::query::Providers;"}
{"_id":"q-en-rust-2a374c56b9000ab72b4a260baeba6e57a8674fc18712967e4f5e37e039a7bbd4","text":"} } #[cfg(any(target_arch = \"x86_64\", target_arch = \"arm\"))] #[cfg(not(target_arch = \"x86\"))] #[macro_use] mod imp { pub type ptr_t = u32;"}
{"_id":"q-en-rust-2a53bb0d741d7d7ddc1aa99861ff9c72c387c89196286c85177160427bc2162a","text":"/// } /// ``` #[stable(feature = \"rust1\", since = \"1.0.0\")] #[inline] pub fn raw_os_error(&self) -> Option { match self.repr { Repr::Os(i) => Some(i),"}
{"_id":"q-en-rust-2a53f47872b5faf3f06de960a432c6713fcc2cf96aeb3fc59731d5da4dad45b1","text":" // revisions: current next //[next] compile-flags: -Znext-solver // check-pass #![feature(non_lifetime_binders)] //~^ WARN the feature `non_lifetime_binders` is incomplete pub trait Foo { type Bar: ?Sized; } impl Foo for () { type Bar = K; } pub fn f(a: T1, b: T2) where T1: for Foo = T>, T2: for Foo = >::Bar>, { } fn it_works() { f((), ()); } fn main() {} "}
{"_id":"q-en-rust-2a6d4ebccddc1ed6485ffea932a91eb7a0e9d78b7b391e258872ebf00f9adaed","text":" // 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 or the MIT license // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. // aux-build:plugin.rs #![feature(proc_macro)] #[macro_use] extern crate plugin; #[derive(Foo, Bar)] struct Baz { a: i32, b: i32, } fn main() {} "}
{"_id":"q-en-rust-2abc916f9ed8d3ffb3fd11dff8c146d2cf3351ff1b78341f9f3a7b121f0fb1f3","text":"/// \"successfully written\" (by returning nonzero success values from /// `write`), any 0-length writes from `inner` must be reported as i/o /// errors from this method. pub(super) fn flush_buf(&mut self) -> io::Result<()> { pub(in crate::io) fn flush_buf(&mut self) -> io::Result<()> { /// Helper struct to ensure the buffer is updated after all the writes /// are complete. It tracks the number of written bytes and drains them /// all from the front of the buffer when dropped."}
{"_id":"q-en-rust-2b1169fabaf0cb25b15e841df0299c5f04c8c6c3cc575bab1a9d458970a79587","text":"} let size = ret.layout.size; let bits = size.bits(); if bits <= 128 { if bits <= 256 { let unit = if bits <= 8 { Reg::i8() } else if bits <= 16 {"}
{"_id":"q-en-rust-2b7e710d393a0d89ee0e30ff1721928c67a861677c5ca505c332dbc0c9060fbd","text":" error: missing `in` in `for` loop --> $DIR/issue-40782.rs:12:10 | 12 | for i 0..2 { | ^ help: try adding `in` here error: aborting due to previous error "}
{"_id":"q-en-rust-2bb42eaaec1ddbf8e02820917a8769cd5e44f6e54a632fef193fc2bfd8ce0f79","text":"if !types.is_empty() { write!(w, \"
\")?; for t in &types {"}
{"_id":"q-en-rust-2bddce07701efe9faa35189b8bbed92ef2a7d209e8147aafd0a51d046a237502","text":"|| found_assoc(tcx.types.u64) || found_assoc(tcx.types.u128) || found_assoc(tcx.types.f32) || found_assoc(tcx.types.f32); || found_assoc(tcx.types.f64); if found_candidate && actual.is_numeric() && !actual.has_concrete_skeleton()"}
{"_id":"q-en-rust-2bfc2196185800a6fe60bedf67ce0a45d377e423b332419977293acd065e45af","text":"if v.is_ascii() { bytes.push(cx.expr_u8(expr.span, v as u8)); } else { cx.span_err(expr.span, \"non-ascii char literal in bytes!\") cx.span_err(expr.span, \"non-ascii char literal in bytes!\"); err = true; } } _ => cx.span_err(expr.span, \"unsupported literal in bytes!\") _ => { cx.span_err(expr.span, \"unsupported literal in bytes!\"); err = true; } }, _ => cx.span_err(expr.span, \"non-literal in bytes!\") _ => { cx.span_err(expr.span, \"non-literal in bytes!\"); err = true; } } } // For some reason using quote_expr!() here aborts if we threw an error. // I'm assuming that the end of the recursive parse tricks the compiler // into thinking this is a good time to stop. But we'd rather keep going. if err { // Since the compiler will stop after the macro expansion phase anyway, we // don't need type info, so we can just return a DummyResult return DummyResult::expr(sp); } let e = cx.expr_vec_slice(sp, bytes); let e = quote_expr!(cx, { static BYTES: &'static [u8] = $e; BYTES}); MacExpr::new(e) }"}
{"_id":"q-en-rust-2c3514289967299a9cafdd1a66fcbde0f5bd1db6627654cd464ffb8d57ce2982","text":"let fs = fields.move_map(|f| { Spanned { span: folder.new_span(f.span), node: ast::FieldPat { ident: f.node.ident, ident: folder.fold_ident(f.node.ident), pat: folder.fold_pat(f.node.pat), is_shorthand: f.node.is_shorthand, }}"}
{"_id":"q-en-rust-2c49ea1c7fb65e05ed29cad5d520ca74a73c24e6da01fdbde5737c384b543e77","text":" // 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 or the MIT license // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. // aux-build:import_crate_var.rs // error-pattern: `$crate` may not be imported // error-pattern: `use $crate;` was erroneously allowed and will become a hard error #![feature(rustc_attrs)] #[macro_use] extern crate import_crate_var; m!(); #[rustc_error] fn main() {} "}
{"_id":"q-en-rust-2c6b3ff7c8e0a6ab1f7711826f1636eca0fb2e350bfae336d0350448efc26408","text":"self.points.contains(row, index) } /// Returns an iterator of all the elements contained by the region `r` crate fn get_elements(&self, row: N) -> impl Iterator + '_ { self.points .row(row) .into_iter() .flat_map(|set| set.iter()) .take_while(move |&p| self.elements.point_in_range(p)) .map(move |p| self.elements.to_location(p)) } /// Returns a \"pretty\" string value of the region. Meant for debugging. crate fn region_value_str(&self, r: N) -> String { region_value_str( self.points .row(r) .into_iter() .flat_map(|set| set.iter()) .take_while(|&p| self.elements.point_in_range(p)) .map(|p| self.elements.to_location(p)) .map(RegionElement::Location), ) region_value_str(self.get_elements(r).map(RegionElement::Location)) } }"}
{"_id":"q-en-rust-2c72eb6938f2b052372e1be6482eee0ba64d9f302bc538ad6397381d9efbc63a","text":"/// (e.g. `min`, `minimum`, `max`, `maximum`); other aspects of their semantics and which IEEE 754 /// operation they correspond to are documented with the respective functions. /// /// When a floating-point operation is executed in `const` context, the same rules apply: no /// guarantee is made about which of the NaN bit patterns described above will be returned. The /// result does not have to match what happens when executing the same code at runtime, and the /// result can vary depending on factors such as compiler version and flags. /// When an arithmetic floating-point operation is executed in `const` context, the same rules /// apply: no guarantee is made about which of the NaN bit patterns described above will be /// returned. The result does not have to match what happens when executing the same code at /// runtime, and the result can vary depending on factors such as compiler version and flags. /// /// ### Target-specific \"extra\" NaN values // FIXME: Is there a better place to put this?"}
{"_id":"q-en-rust-2c827f087847c5da4c28c9440db65fe3d3f2bf93ac65d657ca9cf4f264a9ff75","text":"use clean::Variant::*; match variant { CLike(disr) => Variant::Plain(disr.map(|disr| disr.into_tcx(tcx))), Tuple(fields) => Variant::Tuple( fields .into_iter() .filter_map(|f| match *f.kind { clean::StructFieldItem(ty) => Some(ty.into_tcx(tcx)), clean::StrippedItem(_) => None, _ => unreachable!(), }) .collect(), ), Struct(s) => Variant::Struct(ids(s.fields, tcx)), Tuple(fields) => Variant::Tuple(ids_keeping_stripped(fields, tcx)), Struct(s) => Variant::Struct { fields_stripped: s.has_stripped_entries(), fields: ids(s.fields, tcx), }, } } }"}
{"_id":"q-en-rust-2c9b7e731b7fd070882cc9cee8f6a4f8ca96a89f479edcdb5a4e7f1ffe6229b6","text":"self.check_export_name(hir_id, &attr, span, target) } else if self.tcx.sess.check_name(attr, sym::rustc_args_required_const) { self.check_rustc_args_required_const(&attr, span, target, item) } else if self.tcx.sess.check_name(attr, sym::rustc_layout_scalar_valid_range_start) { self.check_rustc_layout_scalar_valid_range(&attr, span, target) } else if self.tcx.sess.check_name(attr, sym::rustc_layout_scalar_valid_range_end) { self.check_rustc_layout_scalar_valid_range(&attr, span, target) } else if self.tcx.sess.check_name(attr, sym::allow_internal_unstable) { self.check_allow_internal_unstable(hir_id, &attr, span, target, &attrs) } else if self.tcx.sess.check_name(attr, sym::rustc_allow_const_fn_unstable) {"}
{"_id":"q-en-rust-2ca30154175281794f8a22e6e31cbaf4b123372aee89d2414562144e01178200","text":"/// Returns a map from a sufficiently visible external item (i.e. an external item that is /// visible from at least one local module) to a sufficiently visible parent (considering /// modules that re-export the external item to be parents). fn visible_parent_map<'a>(&'a self) -> ::std::cell::RefMut<'a, DefIdMap> { let mut visible_parent_map = self.visible_parent_map.borrow_mut(); if !visible_parent_map.is_empty() { return visible_parent_map; } fn visible_parent_map<'a>(&'a self) -> ::std::cell::Ref<'a, DefIdMap> { { let visible_parent_map = self.visible_parent_map.borrow(); if !visible_parent_map.is_empty() { return visible_parent_map; } } use std::collections::vec_deque::VecDeque; use std::collections::hash_map::Entry; let mut visible_parent_map = self.visible_parent_map.borrow_mut(); for cnum in (1 .. self.next_crate_num().as_usize()).map(CrateNum::new) { let cdata = self.get_crate_data(cnum);"}
{"_id":"q-en-rust-2cac947f723ba2fc469c53a700a882a5249281538a4e49be48cdb46ba884de2a","text":"without modifying the original\"] #[stable(feature = \"unicode_case_mapping\", since = \"1.2.0\")] pub fn to_lowercase(&self) -> String { let out = convert_while_ascii(self.as_bytes(), u8::to_ascii_lowercase); let (mut s, rest) = convert_while_ascii(self, u8::to_ascii_lowercase); // Safety: we know this is a valid char boundary since // out.len() is only progressed if ascii bytes are found let rest = unsafe { self.get_unchecked(out.len()..) }; // Safety: We have written only valid ASCII to our vec let mut s = unsafe { String::from_utf8_unchecked(out) }; let prefix_len = s.len(); for (i, c) in rest.char_indices() { if c == 'Σ' {"}
{"_id":"q-en-rust-2cb32c5306f300fd5daf8bfefe142274e624f37cbf226254fbd0b5306eecefd2","text":"#[rustc_doc_primitive = \"f16\"] #[doc(alias = \"half\")] /// A 16-bit floating point type (specifically, the \"binary16\" type defined in IEEE 754-2008). /// A 16-bit floating-point type (specifically, the \"binary16\" type defined in IEEE 754-2008). /// /// This type is very similar to [`prim@f32`] but has decreased precision because it uses half as many /// bits. Please see [the documentation for `f32`](prim@f32) or [Wikipedia on half-precision"}
{"_id":"q-en-rust-2cb36f77df2b1b8c96c390a1becae160fef1ce3dffb9c97a6da2891d4ba4b8cb","text":" // Copyright 2017 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 or the MIT license // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. fn f(x: &mut u32) {} fn main() { let x = Box::new(3); f(&mut *x); } "}
{"_id":"q-en-rust-2cb8a81acb2ccf2f0cb46bb8883a0f121a97afc52ff48bc3519300d52962aac8","text":"node_to_hir_id: self.node_to_hir_id.clone(), macro_def_scopes: self.macro_def_scopes.clone(), expansions: self.expansions.clone(), keys_created: self.keys_created.clone(), next_disambiguator: self.next_disambiguator.clone(), } } }"}
{"_id":"q-en-rust-2cc08db4569cda8563bfae0123e3188452cc62dd2d54b4ab30ced48bc50242db","text":"} if self.index < self.len { self.len -= 1; self.a_len -= 1; let i = self.len; // SAFETY: `i` is smaller than the previous value of `self.len`, // which is also smaller than or equal to `self.a.len()` and `self.b.len()`"}
{"_id":"q-en-rust-2ce9e68d77702a3977bff9ae6ca25474cc3db469e476b8218b390656a6f7e168","text":" error: this file contains an un-closed delimiter --> $DIR/issue-63135.rs:3:16 | LL | fn i(n{...,f # | - - ^ | | | | | un-closed delimiter | un-closed delimiter error: expected field pattern, found `...` --> $DIR/issue-63135.rs:3:8 | LL | fn i(n{...,f # | ^^^ help: to omit remaining fields, use one fewer `.`: `..` error: expected `}`, found `,` --> $DIR/issue-63135.rs:3:11 | LL | fn i(n{...,f # | ---^ | | | | | expected `}` | `..` must be at the end and cannot have a trailing comma error: expected `[`, found `}` --> $DIR/issue-63135.rs:3:15 | LL | fn i(n{...,f # | ^ expected `[` error: expected `:`, found `)` --> $DIR/issue-63135.rs:3:15 | LL | fn i(n{...,f # | ^ expected `:` error: expected one of `->`, `where`, or `{`, found `` --> $DIR/issue-63135.rs:3:15 | LL | fn i(n{...,f # | ^ expected one of `->`, `where`, or `{` here error: aborting due to 6 previous errors "}
{"_id":"q-en-rust-2d04913175a532dae957de23db16c9bd7f12191fe26dda34a337a4d5fec64623","text":" PRINT-BANG INPUT (DISPLAY): ; PRINT-BANG INPUT (DEBUG): TokenStream [ Group { delimiter: None, stream: TokenStream [ Punct { ch: ';', spacing: Alone, span: $DIR/issue-80760-empty-stmt.rs:25:17: 25:18 (#0), }, ], span: $DIR/issue-80760-empty-stmt.rs:13:21: 13:23 (#4), }, ] "}
{"_id":"q-en-rust-2d0aac5e0c890bbeb51bcc0a7b007b54b2971632292fe79d509705da1723be7e","text":" #![crate_type=\"lib\"] #[repr(i8)] pub enum Type { Type1 = 0, Type2 = 1 } // CHECK: define signext i8 @test() #[no_mangle] pub extern \"C\" fn test() -> Type { Type::Type1 } "}
{"_id":"q-en-rust-2d160c63e6053f1422eb434106ecea94f5004727466568380059d3de309db222","text":"rc::Rc, }; require std::time::Duration; //~^ ERROR expected item, found `require` include std::time::Instant; //~^ ERROR expected item, found `include` pub using std::io; //~^ ERROR expected item, found `using` fn main() { let x = Rc::new(1); let _ = write!(io::stdout(), \"{:?}\", x); let _ = Duration::new(5, 0); let _ = Instant::now(); }"}
{"_id":"q-en-rust-2d615bedb567f74fb48c5840d95fc571c7c7c9ed9df80341307e82a15ad54986","text":" error[E0594]: cannot assign to `self.foo`, which is behind a `&` reference --> $DIR/issue-93093.rs:8:9 | LL | async fn bar(&self) { | ----- help: consider changing this to be a mutable reference: `&mut self` LL | LL | self.foo += 1; | ^^^^^^^^^^^^^ `self` is a `&` reference, so the data it refers to cannot be written error: aborting due to previous error For more information about this error, try `rustc --explain E0594`. "}
{"_id":"q-en-rust-2d6d0e084305f1635470585efd47147aa7de827e0abf0c165384833ee73d2d8f","text":"t!(read_byte(file)); // compensate for padding } let numbers_map: HashMap = t! { (0..numbers_count).filter_map(|i| match read_le_u16(file) { Ok(0xFFFF) => None, Ok(n) => Some(Ok((nnames[i].to_string(), n))), Err(e) => Some(Err(e)) let numbers_map: HashMap = t! { (0..numbers_count).filter_map(|i| { let number = if extended { read_le_u32(file) } else { read_le_u16(file).map(Into::into) }; match number { Ok(0xFFFF) => None, Ok(n) => Some(Ok((nnames[i].to_string(), n))), Err(e) => Some(Err(e)) } }).collect() };"}
{"_id":"q-en-rust-2d957e8853b512cb293d28367f823514f973a6f9ed96daa90cfce7922b611606","text":" use crate::mir::interpret::Scalar; use crate::ty::{self, Ty, TyCtxt}; use rustc_ast::ast::{InlineAsmOptions, InlineAsmTemplatePiece}; use super::{ AssertMessage, BasicBlock, InlineAsmOperand, Operand, Place, SourceInfo, Successors, SuccessorsMut, }; pub use rustc_ast::ast::Mutability; use rustc_macros::HashStable; use rustc_span::Span; use std::borrow::Cow; use std::fmt::{self, Debug, Formatter, Write}; use std::iter; use std::slice; pub use super::query::*; #[derive(Clone, RustcEncodable, RustcDecodable, HashStable, PartialEq)] pub enum TerminatorKind<'tcx> { /// Block should have one successor in the graph; we jump there. Goto { target: BasicBlock }, /// Operand evaluates to an integer; jump depending on its value /// to one of the targets, and otherwise fallback to `otherwise`. SwitchInt { /// The discriminant value being tested. discr: Operand<'tcx>, /// The type of value being tested. /// This is always the same as the type of `discr`. /// FIXME: remove this redundant information. Currently, it is relied on by pretty-printing. switch_ty: Ty<'tcx>, /// Possible values. The locations to branch to in each case /// are found in the corresponding indices from the `targets` vector. values: Cow<'tcx, [u128]>, /// Possible branch sites. The last element of this vector is used /// for the otherwise branch, so targets.len() == values.len() + 1 /// should hold. // // This invariant is quite non-obvious and also could be improved. // One way to make this invariant is to have something like this instead: // // branches: Vec<(ConstInt, BasicBlock)>, // otherwise: Option // exhaustive if None // // However we’ve decided to keep this as-is until we figure a case // where some other approach seems to be strictly better than other. targets: Vec, }, /// Indicates that the landing pad is finished and unwinding should /// continue. Emitted by `build::scope::diverge_cleanup`. Resume, /// Indicates that the landing pad is finished and that the process /// should abort. Used to prevent unwinding for foreign items. Abort, /// Indicates a normal return. The return place should have /// been filled in before this executes. This can occur multiple times /// in different basic blocks. Return, /// Indicates a terminator that can never be reached. Unreachable, /// Drop the `Place`. Drop { place: Place<'tcx>, target: BasicBlock, unwind: Option }, /// Drop the `Place` and assign the new value over it. This ensures /// that the assignment to `P` occurs *even if* the destructor for /// place unwinds. Its semantics are best explained by the /// elaboration: /// /// ``` /// BB0 { /// DropAndReplace(P <- V, goto BB1, unwind BB2) /// } /// ``` /// /// becomes /// /// ``` /// BB0 { /// Drop(P, goto BB1, unwind BB2) /// } /// BB1 { /// // P is now uninitialized /// P <- V /// } /// BB2 { /// // P is now uninitialized -- its dtor panicked /// P <- V /// } /// ``` DropAndReplace { place: Place<'tcx>, value: Operand<'tcx>, target: BasicBlock, unwind: Option, }, /// Block ends with a call of a converging function. Call { /// The function that’s being called. func: Operand<'tcx>, /// Arguments the function is called with. /// These are owned by the callee, which is free to modify them. /// This allows the memory occupied by \"by-value\" arguments to be /// reused across function calls without duplicating the contents. args: Vec>, /// Destination for the return value. If some, the call is converging. destination: Option<(Place<'tcx>, BasicBlock)>, /// Cleanups to be done if the call unwinds. cleanup: Option, /// `true` if this is from a call in HIR rather than from an overloaded /// operator. True for overloaded function call. from_hir_call: bool, /// This `Span` is the span of the function, without the dot and receiver /// (e.g. `foo(a, b)` in `x.foo(a, b)` fn_span: Span, }, /// Jump to the target if the condition has the expected value, /// otherwise panic with a message and a cleanup target. Assert { cond: Operand<'tcx>, expected: bool, msg: AssertMessage<'tcx>, target: BasicBlock, cleanup: Option, }, /// A suspend point. Yield { /// The value to return. value: Operand<'tcx>, /// Where to resume to. resume: BasicBlock, /// The place to store the resume argument in. resume_arg: Place<'tcx>, /// Cleanup to be done if the generator is dropped at this suspend point. drop: Option, }, /// Indicates the end of the dropping of a generator. GeneratorDrop, /// A block where control flow only ever takes one real path, but borrowck /// needs to be more conservative. FalseEdge { /// The target normal control flow will take. real_target: BasicBlock, /// A block control flow could conceptually jump to, but won't in /// practice. imaginary_target: BasicBlock, }, /// A terminator for blocks that only take one path in reality, but where we /// reserve the right to unwind in borrowck, even if it won't happen in practice. /// This can arise in infinite loops with no function calls for example. FalseUnwind { /// The target normal control flow will take. real_target: BasicBlock, /// The imaginary cleanup block link. This particular path will never be taken /// in practice, but in order to avoid fragility we want to always /// consider it in borrowck. We don't want to accept programs which /// pass borrowck only when `panic=abort` or some assertions are disabled /// due to release vs. debug mode builds. This needs to be an `Option` because /// of the `remove_noop_landing_pads` and `no_landing_pads` passes. unwind: Option, }, /// Block ends with an inline assembly block. This is a terminator since /// inline assembly is allowed to diverge. InlineAsm { /// The template for the inline assembly, with placeholders. template: &'tcx [InlineAsmTemplatePiece], /// The operands for the inline assembly, as `Operand`s or `Place`s. operands: Vec>, /// Miscellaneous options for the inline assembly. options: InlineAsmOptions, /// Source spans for each line of the inline assembly code. These are /// used to map assembler errors back to the line in the source code. line_spans: &'tcx [Span], /// Destination block after the inline assembly returns, unless it is /// diverging (InlineAsmOptions::NORETURN). destination: Option, }, } #[derive(Clone, Debug, RustcEncodable, RustcDecodable, HashStable)] pub struct Terminator<'tcx> { pub source_info: SourceInfo, pub kind: TerminatorKind<'tcx>, } impl<'tcx> Terminator<'tcx> { pub fn successors(&self) -> Successors<'_> { self.kind.successors() } pub fn successors_mut(&mut self) -> SuccessorsMut<'_> { self.kind.successors_mut() } pub fn unwind(&self) -> Option<&Option> { self.kind.unwind() } pub fn unwind_mut(&mut self) -> Option<&mut Option> { self.kind.unwind_mut() } } impl<'tcx> TerminatorKind<'tcx> { pub fn if_( tcx: TyCtxt<'tcx>, cond: Operand<'tcx>, t: BasicBlock, f: BasicBlock, ) -> TerminatorKind<'tcx> { static BOOL_SWITCH_FALSE: &[u128] = &[0]; TerminatorKind::SwitchInt { discr: cond, switch_ty: tcx.types.bool, values: From::from(BOOL_SWITCH_FALSE), targets: vec![f, t], } } pub fn successors(&self) -> Successors<'_> { use self::TerminatorKind::*; match *self { Resume | Abort | GeneratorDrop | Return | Unreachable | Call { destination: None, cleanup: None, .. } | InlineAsm { destination: None, .. } => None.into_iter().chain(&[]), Goto { target: ref t } | Call { destination: None, cleanup: Some(ref t), .. } | Call { destination: Some((_, ref t)), cleanup: None, .. } | Yield { resume: ref t, drop: None, .. } | DropAndReplace { target: ref t, unwind: None, .. } | Drop { target: ref t, unwind: None, .. } | Assert { target: ref t, cleanup: None, .. } | FalseUnwind { real_target: ref t, unwind: None } | InlineAsm { destination: Some(ref t), .. } => Some(t).into_iter().chain(&[]), Call { destination: Some((_, ref t)), cleanup: Some(ref u), .. } | Yield { resume: ref t, drop: Some(ref u), .. } | DropAndReplace { target: ref t, unwind: Some(ref u), .. } | Drop { target: ref t, unwind: Some(ref u), .. } | Assert { target: ref t, cleanup: Some(ref u), .. } | FalseUnwind { real_target: ref t, unwind: Some(ref u) } => { Some(t).into_iter().chain(slice::from_ref(u)) } SwitchInt { ref targets, .. } => None.into_iter().chain(&targets[..]), FalseEdge { ref real_target, ref imaginary_target } => { Some(real_target).into_iter().chain(slice::from_ref(imaginary_target)) } } } pub fn successors_mut(&mut self) -> SuccessorsMut<'_> { use self::TerminatorKind::*; match *self { Resume | Abort | GeneratorDrop | Return | Unreachable | Call { destination: None, cleanup: None, .. } | InlineAsm { destination: None, .. } => None.into_iter().chain(&mut []), Goto { target: ref mut t } | Call { destination: None, cleanup: Some(ref mut t), .. } | Call { destination: Some((_, ref mut t)), cleanup: None, .. } | Yield { resume: ref mut t, drop: None, .. } | DropAndReplace { target: ref mut t, unwind: None, .. } | Drop { target: ref mut t, unwind: None, .. } | Assert { target: ref mut t, cleanup: None, .. } | FalseUnwind { real_target: ref mut t, unwind: None } | InlineAsm { destination: Some(ref mut t), .. } => Some(t).into_iter().chain(&mut []), Call { destination: Some((_, ref mut t)), cleanup: Some(ref mut u), .. } | Yield { resume: ref mut t, drop: Some(ref mut u), .. } | DropAndReplace { target: ref mut t, unwind: Some(ref mut u), .. } | Drop { target: ref mut t, unwind: Some(ref mut u), .. } | Assert { target: ref mut t, cleanup: Some(ref mut u), .. } | FalseUnwind { real_target: ref mut t, unwind: Some(ref mut u) } => { Some(t).into_iter().chain(slice::from_mut(u)) } SwitchInt { ref mut targets, .. } => None.into_iter().chain(&mut targets[..]), FalseEdge { ref mut real_target, ref mut imaginary_target } => { Some(real_target).into_iter().chain(slice::from_mut(imaginary_target)) } } } pub fn unwind(&self) -> Option<&Option> { match *self { TerminatorKind::Goto { .. } | TerminatorKind::Resume | TerminatorKind::Abort | TerminatorKind::Return | TerminatorKind::Unreachable | TerminatorKind::GeneratorDrop | TerminatorKind::Yield { .. } | TerminatorKind::SwitchInt { .. } | TerminatorKind::FalseEdge { .. } | TerminatorKind::InlineAsm { .. } => None, TerminatorKind::Call { cleanup: ref unwind, .. } | TerminatorKind::Assert { cleanup: ref unwind, .. } | TerminatorKind::DropAndReplace { ref unwind, .. } | TerminatorKind::Drop { ref unwind, .. } | TerminatorKind::FalseUnwind { ref unwind, .. } => Some(unwind), } } pub fn unwind_mut(&mut self) -> Option<&mut Option> { match *self { TerminatorKind::Goto { .. } | TerminatorKind::Resume | TerminatorKind::Abort | TerminatorKind::Return | TerminatorKind::Unreachable | TerminatorKind::GeneratorDrop | TerminatorKind::Yield { .. } | TerminatorKind::SwitchInt { .. } | TerminatorKind::FalseEdge { .. } | TerminatorKind::InlineAsm { .. } => None, TerminatorKind::Call { cleanup: ref mut unwind, .. } | TerminatorKind::Assert { cleanup: ref mut unwind, .. } | TerminatorKind::DropAndReplace { ref mut unwind, .. } | TerminatorKind::Drop { ref mut unwind, .. } | TerminatorKind::FalseUnwind { ref mut unwind, .. } => Some(unwind), } } } impl<'tcx> Debug for TerminatorKind<'tcx> { fn fmt(&self, fmt: &mut Formatter<'_>) -> fmt::Result { self.fmt_head(fmt)?; let successor_count = self.successors().count(); let labels = self.fmt_successor_labels(); assert_eq!(successor_count, labels.len()); match successor_count { 0 => Ok(()), 1 => write!(fmt, \" -> {:?}\", self.successors().next().unwrap()), _ => { write!(fmt, \" -> [\")?; for (i, target) in self.successors().enumerate() { if i > 0 { write!(fmt, \", \")?; } write!(fmt, \"{}: {:?}\", labels[i], target)?; } write!(fmt, \"]\") } } } } impl<'tcx> TerminatorKind<'tcx> { /// Writes the \"head\" part of the terminator; that is, its name and the data it uses to pick the /// successor basic block, if any. The only information not included is the list of possible /// successors, which may be rendered differently between the text and the graphviz format. pub fn fmt_head(&self, fmt: &mut W) -> fmt::Result { use self::TerminatorKind::*; match self { Goto { .. } => write!(fmt, \"goto\"), SwitchInt { discr, .. } => write!(fmt, \"switchInt({:?})\", discr), Return => write!(fmt, \"return\"), GeneratorDrop => write!(fmt, \"generator_drop\"), Resume => write!(fmt, \"resume\"), Abort => write!(fmt, \"abort\"), Yield { value, resume_arg, .. } => write!(fmt, \"{:?} = yield({:?})\", resume_arg, value), Unreachable => write!(fmt, \"unreachable\"), Drop { place, .. } => write!(fmt, \"drop({:?})\", place), DropAndReplace { place, value, .. } => { write!(fmt, \"replace({:?} <- {:?})\", place, value) } Call { func, args, destination, .. } => { if let Some((destination, _)) = destination { write!(fmt, \"{:?} = \", destination)?; } write!(fmt, \"{:?}(\", func)?; for (index, arg) in args.iter().enumerate() { if index > 0 { write!(fmt, \", \")?; } write!(fmt, \"{:?}\", arg)?; } write!(fmt, \")\") } Assert { cond, expected, msg, .. } => { write!(fmt, \"assert(\")?; if !expected { write!(fmt, \"!\")?; } write!(fmt, \"{:?}, \", cond)?; msg.fmt_assert_args(fmt)?; write!(fmt, \")\") } FalseEdge { .. } => write!(fmt, \"falseEdge\"), FalseUnwind { .. } => write!(fmt, \"falseUnwind\"), InlineAsm { template, ref operands, options, .. } => { write!(fmt, \"asm!(\"{}\"\", InlineAsmTemplatePiece::to_string(template))?; for op in operands { write!(fmt, \", \")?; let print_late = |&late| if late { \"late\" } else { \"\" }; match op { InlineAsmOperand::In { reg, value } => { write!(fmt, \"in({}) {:?}\", reg, value)?; } InlineAsmOperand::Out { reg, late, place: Some(place) } => { write!(fmt, \"{}out({}) {:?}\", print_late(late), reg, place)?; } InlineAsmOperand::Out { reg, late, place: None } => { write!(fmt, \"{}out({}) _\", print_late(late), reg)?; } InlineAsmOperand::InOut { reg, late, in_value, out_place: Some(out_place), } => { write!( fmt, \"in{}out({}) {:?} => {:?}\", print_late(late), reg, in_value, out_place )?; } InlineAsmOperand::InOut { reg, late, in_value, out_place: None } => { write!(fmt, \"in{}out({}) {:?} => _\", print_late(late), reg, in_value)?; } InlineAsmOperand::Const { value } => { write!(fmt, \"const {:?}\", value)?; } InlineAsmOperand::SymFn { value } => { write!(fmt, \"sym_fn {:?}\", value)?; } InlineAsmOperand::SymStatic { def_id } => { write!(fmt, \"sym_static {:?}\", def_id)?; } } } write!(fmt, \", options({:?}))\", options) } } } /// Returns the list of labels for the edges to the successor basic blocks. pub fn fmt_successor_labels(&self) -> Vec> { use self::TerminatorKind::*; match *self { Return | Resume | Abort | Unreachable | GeneratorDrop => vec![], Goto { .. } => vec![\"\".into()], SwitchInt { ref values, switch_ty, .. } => ty::tls::with(|tcx| { let param_env = ty::ParamEnv::empty(); let switch_ty = tcx.lift(&switch_ty).unwrap(); let size = tcx.layout_of(param_env.and(switch_ty)).unwrap().size; values .iter() .map(|&u| { ty::Const::from_scalar(tcx, Scalar::from_uint(u, size), switch_ty) .to_string() .into() }) .chain(iter::once(\"otherwise\".into())) .collect() }), Call { destination: Some(_), cleanup: Some(_), .. } => { vec![\"return\".into(), \"unwind\".into()] } Call { destination: Some(_), cleanup: None, .. } => vec![\"return\".into()], Call { destination: None, cleanup: Some(_), .. } => vec![\"unwind\".into()], Call { destination: None, cleanup: None, .. } => vec![], Yield { drop: Some(_), .. } => vec![\"resume\".into(), \"drop\".into()], Yield { drop: None, .. } => vec![\"resume\".into()], DropAndReplace { unwind: None, .. } | Drop { unwind: None, .. } => { vec![\"return\".into()] } DropAndReplace { unwind: Some(_), .. } | Drop { unwind: Some(_), .. } => { vec![\"return\".into(), \"unwind\".into()] } Assert { cleanup: None, .. } => vec![\"\".into()], Assert { .. } => vec![\"success\".into(), \"unwind\".into()], FalseEdge { .. } => vec![\"real\".into(), \"imaginary\".into()], FalseUnwind { unwind: Some(_), .. } => vec![\"real\".into(), \"cleanup\".into()], FalseUnwind { unwind: None, .. } => vec![\"real\".into()], InlineAsm { destination: Some(_), .. } => vec![\"\".into()], InlineAsm { destination: None, .. } => vec![], } } } "}
{"_id":"q-en-rust-2dd7c5780b5cf6ddcfa3e671d81a0b610429615db0337950062f1bb5e7dd4687","text":"//! //! * Should probably have something like this for strings. //! * Should they implement Closable? Would take extra state. use cmp::max; use cmp::min; use prelude::*; use super::*;"}
{"_id":"q-en-rust-2ddf6c58ddf4b601141935c77f885ff7fc81a67e0a3f28728e31de8e60e347d2","text":" #![feature(intrinsics)] extern \"C\" { pub static FOO: extern \"rust-intrinsic\" fn(); } fn main() { FOO() //~ ERROR: use of extern static is unsafe } "}
{"_id":"q-en-rust-2e09a448c19e90d4f6946df4a25a9cdd3446e0f8e18f7b7c713812b29b316860","text":" use std::iter; use either::Either; use hir::PatField; use rustc_data_structures::captures::Captures; use rustc_data_structures::fx::FxIndexSet; use rustc_errors::{"}
{"_id":"q-en-rust-2e1a14cd4d56dc6d49380fddd961ba230ec291dd14e59713838519368dfe0ab9","text":" error[E0371]: the object type `(dyn Object + Marker2 + 'static)` automatically implements the trait `Marker1` --> $DIR/coherence-impl-trait-for-marker-trait-positive.rs:14:1 | LL | impl Marker1 for dyn Object + Marker2 { } //~ ERROR E0371 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `(dyn Object + Marker2 + 'static)` automatically implements trait `Marker1` error[E0371]: the object type `(dyn Object + Marker2 + 'static)` automatically implements the trait `Marker2` --> $DIR/coherence-impl-trait-for-marker-trait-positive.rs:16:1 | LL | impl Marker2 for dyn Object + Marker2 { } //~ ERROR E0371 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `(dyn Object + Marker2 + 'static)` automatically implements trait `Marker2` error[E0117]: only traits defined in the current crate can be implemented for arbitrary types --> $DIR/coherence-impl-trait-for-marker-trait-positive.rs:22:1 | LL | unsafe impl Send for dyn Marker2 {} //~ ERROR E0117 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate | = note: the impl does not reference only types defined in this crate = note: define and implement a trait or new type instead error[E0321]: cross-crate traits with a default impl, like `std::marker::Send`, can only be implemented for a struct/enum type, not `(dyn Object + 'static)` --> $DIR/coherence-impl-trait-for-marker-trait-positive.rs:26:1 | LL | unsafe impl Send for dyn Object {} //~ ERROR E0321 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't implement cross-crate trait with a default impl for non-struct/enum type error[E0321]: cross-crate traits with a default impl, like `std::marker::Send`, can only be implemented for a struct/enum type, not `(dyn Object + Marker2 + 'static)` --> $DIR/coherence-impl-trait-for-marker-trait-positive.rs:27:1 | LL | unsafe impl Send for dyn Object + Marker2 {} //~ ERROR E0321 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't implement cross-crate trait with a default impl for non-struct/enum type error: aborting due to 5 previous errors Some errors occurred: E0117, E0321, E0371. For more information about an error, try `rustc --explain E0117`. "}
{"_id":"q-en-rust-2e3002a0c380ad61b6a4059336640e1e678c6901f22a1f0141ef00524a132b6e","text":"E0696, // `continue` pointing to a labeled block // E0702, // replaced with a generic attribute input check E0703, // invalid ABI E0706, // `async fn` in trait // E0707, // multiple elided lifetimes used in arguments of `async fn` E0708, // `async` non-`move` closures with parameters are not currently // supported"}
{"_id":"q-en-rust-2e41db7ecfa55e9d7859fd33f4eb397dc240165034ad3bfdf7178cf26a90d24a","text":"stride * field } layout::FieldPlacement::Union(count) => { // This is a narrow bug-fix for rust-lang/rust#69191: if we are // trying to access absent field of uninhabited variant, then // signal UB (but don't ICE the compiler). // FIXME temporary hack to work around incoherence between // layout computation and MIR building if field >= count as u64 && base.layout.abi == layout::Abi::Uninhabited { throw_ub!(Unreachable); } assert!( field < count as u64, \"Tried to access field {} of union {:#?} with {} fields\","}
{"_id":"q-en-rust-2e90d062adf875ccf7257471443be2eaa03f3b1f6af92f11879b5f602d0ae660","text":"//! [`Iterator`]: trait.Iterator.html //! [`next`]: trait.Iterator.html#tymethod.next //! [`Option`]: ../../std/option/enum.Option.html //! [`TryIter`]: ../../std/sync/mpsc/struct.TryIter.html //! //! # The three forms of iteration //!"}
{"_id":"q-en-rust-2ec55300b746ef486dbd815c3e3bdfd6fdda2fa40f43f03e62fb4da54c83bcd3","text":" error[E0229]: associated type bindings are not allowed here --> $DIR/issue-102335-const.rs:4:17 | LL | type A: S = 34>; | ^^^^^^^^ associated type not allowed here error: aborting due to previous error For more information about this error, try `rustc --explain E0229`. "}
{"_id":"q-en-rust-2ed2b69f17dce93d81c7a52b2f71965f8d4f1503d93b46234cc16df6ff9b9743","text":"If you’d like to dive into this topic in greater detail, [this paper][wilson] is a great introduction. [wilson]: http://www.cs.northwestern.edu/~pdinda/icsclass/doc/dsa.pdf [wilson]: http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.143.4688 ## Semantic impact"}
{"_id":"q-en-rust-2ee95bfe2a013b85a0bbbacbb8d9f9be332f6959bab06d607257453a4d55ba31","text":" // 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 or the MIT license // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. // error-pattern:bad input fn main() { Some(\"foo\").unwrap_or(fail!(\"bad input\")).to_string(); } "}
{"_id":"q-en-rust-2efaecc423373b5b3c7463a2012e19e4b4ba8817b247643f906d8694c5568456","text":"} #[test] #[cfg_attr(any(target_os = \"vxworks\", target_os = \"android\"), ignore)] #[cfg_attr(any(target_os = \"vxworks\"), ignore)] fn test_process_output_output() { let Output { status, stdout, stderr } = if cfg!(target_os = \"windows\") { Command::new(\"cmd\").args(&[\"/C\", \"echo hello\"]).output().unwrap() } else { Command::new(\"echo\").arg(\"hello\").output().unwrap() shell_cmd().arg(\"-c\").arg(\"echo hello\").output().unwrap() }; let output_str = str::from_utf8(&stdout).unwrap();"}
{"_id":"q-en-rust-2f1c70c6dfa40978ac3022f13e330fb7afdec45697fb65907b6997d54e4e891a","text":" #![feature(prelude_import)] #![no_std] // This test certify that we can mix attribute macros from Rust and external proc-macros. // For instance, `#[derive(Default)]` uses `#[default]` and `#[derive(SmartPointer)]` uses // `#[pointee]`. // The scoping rule should allow the use of the said two attributes when external proc-macros // are in scope. //@ check-pass //@ aux-build: another-proc-macro.rs //@ compile-flags: -Zunpretty=expanded #![feature(derive_smart_pointer)] #[prelude_import] use ::std::prelude::rust_2015::*; #[macro_use] extern crate std; #[macro_use] extern crate another_proc_macro; const _: () = { const POINTEE_MACRO_ATTR_DERIVED: () = (); }; const _: () = { const DEFAULT_MACRO_ATTR_DERIVED: () = (); }; "}
{"_id":"q-en-rust-2f245b11f846beb7037c085ca8b6a127deaa4cd751ceb5f5254b07b5ca8a7e60","text":"} fn write_u16s(handle: c::HANDLE, data: &[u16]) -> io::Result { debug_assert!(data.len() < u32::MAX as usize); let mut written = 0; cvt(unsafe { c::WriteConsoleW("}
{"_id":"q-en-rust-2f25ffd19044c08a25d883b1894d8130df5b4f28c8278fe2cf56668751143a80","text":"/// [`slice_from_raw_parts`]: fn.slice_from_raw_parts.html /// [`from_raw_parts_mut`]: ../../std/slice/fn.from_raw_parts_mut.html #[inline] #[unstable(feature = \"slice_from_raw_parts\", reason = \"recently added\", issue = \"36925\")] #[stable(feature = \"slice_from_raw_parts\", since = \"1.42.0\")] #[rustc_const_unstable(feature = \"const_slice_from_raw_parts\", issue = \"67456\")] pub const fn slice_from_raw_parts_mut(data: *mut T, len: usize) -> *mut [T] { unsafe { Repr { raw: FatPtr { data, len } }.rust_mut }"}
{"_id":"q-en-rust-2f335fc8e52874740f8801f9f97343835d928fff8d837362d20d71b2a46197b9","text":" error: expected expression, found reserved keyword `try` --> $DIR/try-block-in-match.rs:6:11 | LL | match try { false } { _ => {} } | ----- ^^^ expected expression | | | while parsing this match expression error: aborting due to previous error "}
{"_id":"q-en-rust-2f3ce9e644cee8f1089f6fb80c7cf452641843904b4c4984ec22afe2c749d435","text":"} #[test] #[cfg_attr(any(target_os = \"vxworks\", target_os = \"android\"), ignore)] #[cfg_attr(any(target_os = \"vxworks\"), ignore)] fn stdout_works() { if cfg!(target_os = \"windows\") { let mut cmd = Command::new(\"cmd\"); cmd.args(&[\"/C\", \"echo foobar\"]).stdout(Stdio::piped()); assert_eq!(run_output(cmd), \"foobarrn\"); } else { let mut cmd = Command::new(\"echo\"); cmd.arg(\"foobar\").stdout(Stdio::piped()); let mut cmd = shell_cmd(); cmd.arg(\"-c\").arg(\"echo foobar\").stdout(Stdio::piped()); assert_eq!(run_output(cmd), \"foobarn\"); } } #[test] #[cfg_attr(any(windows, target_os = \"android\", target_os = \"vxworks\"), ignore)] #[cfg_attr(any(windows, target_os = \"vxworks\"), ignore)] fn set_current_dir_works() { let mut cmd = Command::new(\"/bin/sh\"); let mut cmd = shell_cmd(); cmd.arg(\"-c\").arg(\"pwd\").current_dir(\"/\").stdout(Stdio::piped()); assert_eq!(run_output(cmd), \"/n\"); } #[test] #[cfg_attr(any(windows, target_os = \"android\", target_os = \"vxworks\"), ignore)] #[cfg_attr(any(windows, target_os = \"vxworks\"), ignore)] fn stdin_works() { let mut p = Command::new(\"/bin/sh\") let mut p = shell_cmd() .arg(\"-c\") .arg(\"read line; echo $line\") .stdin(Stdio::piped())"}
{"_id":"q-en-rust-2f7d38fe58c2bfebf927d95a240b4815c6288769e4dd8c16c554f6603a91c6f6","text":" // Regression test for #81899. // The `panic!()` below is important to trigger the fixed ICE. const _CONST: &[u8] = &f(&[], |_| {}); const fn f(_: &[u8], _: F) -> &[u8] where F: FnMut(&u8), { panic!() //~ ERROR: evaluation of constant value failed } fn main() {} "}
{"_id":"q-en-rust-2f90053f3fc34b398ce3d3ec5c506e7b967ac7d9b46a62bb931089c933447019","text":"use rustc_middle::ty::{ self, fold::BottomUpFolder, print::TraitPredPrintModifiersAndPath, Ty, TypeFoldable, }; use rustc_span::Span; use rustc_span::{symbol::kw, Span}; use rustc_trait_selection::traits; use rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt;"}
{"_id":"q-en-rust-2f9cb41372f86ce0e25501f28387cd5f0da196978315a8e4e2ec474f5a89d8c4","text":"fn the(&self); } } #[cfg(any())] mod nonexistent_file; // Check that unconfigured non-inline modules are not loaded or parsed. "}
{"_id":"q-en-rust-2fa2edbac1ac31bae1caa01af53c882bd72cf99cffed70f61117a95aad06fa4d","text":"(&TestKind::Range { .. }, _) => None, (&TestKind::Eq { .. } | &TestKind::Len { .. }, _) => { // The call to `self.test(&match_pair)` below is not actually used to generate any // MIR. Instead, we just want to compare with `test` (the parameter of the method) // to see if it is the same. // // However, at this point we can still encounter or-patterns that were extracted // from previous calls to `sort_candidate`, so we need to manually address that // case to avoid panicking in `self.test()`. if let PatKind::Or { .. } = &*match_pair.pattern.kind { return None; } // These are all binary tests. // // FIXME(#29623) we can be more clever here"}
{"_id":"q-en-rust-2fb2fd2c43b6f173b8993b904e1a164ef1c139f29bb55f47e943949f042ecc68","text":" // Copyright 2014-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 or the MIT license // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. //! Scoped thread-local storage //! //! This module provides the ability to generate *scoped* thread-local //! variables. In this sense, scoped indicates that thread local storage //! actually stores a reference to a value, and this reference is only placed //! in storage for a scoped amount of time. //! //! There are no restrictions on what types can be placed into a scoped //! variable, but all scoped variables are initialized to the equivalent of //! null. Scoped thread local storage is useful when a value is present for a known //! period of time and it is not required to relinquish ownership of the //! contents. //! //! # Examples //! //! ``` //! # #![feature(scoped_tls)] //! scoped_thread_local!(static FOO: u32); //! //! // Initially each scoped slot is empty. //! assert!(!FOO.is_set()); //! //! // When inserting a value, the value is only in place for the duration //! // of the closure specified. //! FOO.set(&1, || { //! FOO.with(|slot| { //! assert_eq!(*slot, 1); //! }); //! }); //! ``` #![unstable(feature = \"thread_local_internals\")] use prelude::v1::*; // macro hygiene sure would be nice, wouldn't it? #[doc(hidden)] pub mod __impl { pub use super::imp::KeyInner; pub use sys_common::thread_local::INIT as OS_INIT; } /// Type representing a thread local storage key corresponding to a reference /// to the type parameter `T`. /// /// Keys are statically allocated and can contain a reference to an instance of /// type `T` scoped to a particular lifetime. Keys provides two methods, `set` /// and `with`, both of which currently use closures to control the scope of /// their contents. #[unstable(feature = \"scoped_tls\", reason = \"scoped TLS has yet to have wide enough use to fully consider stabilizing its interface\")] pub struct ScopedKey { #[doc(hidden)] pub inner: __impl::KeyInner } /// Declare a new scoped thread local storage key. /// /// This macro declares a `static` item on which methods are used to get and /// set the value stored within. #[macro_export] #[allow_internal_unstable] macro_rules! scoped_thread_local { (static $name:ident: $t:ty) => ( __scoped_thread_local_inner!(static $name: $t); ); (pub static $name:ident: $t:ty) => ( __scoped_thread_local_inner!(pub static $name: $t); ); } #[macro_export] #[doc(hidden)] #[allow_internal_unstable] macro_rules! __scoped_thread_local_inner { (static $name:ident: $t:ty) => ( #[cfg_attr(not(any(windows, target_os = \"android\", target_os = \"ios\", target_os = \"openbsd\", target_arch = \"aarch64\")), thread_local)] static $name: ::std::thread::ScopedKey<$t> = __scoped_thread_local_inner!($t); ); (pub static $name:ident: $t:ty) => ( #[cfg_attr(not(any(windows, target_os = \"android\", target_os = \"ios\", target_os = \"openbsd\", target_arch = \"aarch64\")), thread_local)] pub static $name: ::std::thread::ScopedKey<$t> = __scoped_thread_local_inner!($t); ); ($t:ty) => ({ use std::thread::ScopedKey as __Key; #[cfg(not(any(windows, target_os = \"android\", target_os = \"ios\", target_os = \"openbsd\", target_arch = \"aarch64\")))] const _INIT: __Key<$t> = __Key { inner: ::std::thread::__scoped::KeyInner { inner: ::std::cell::UnsafeCell { value: 0 as *mut _ }, } }; #[cfg(any(windows, target_os = \"android\", target_os = \"ios\", target_os = \"openbsd\", target_arch = \"aarch64\"))] const _INIT: __Key<$t> = __Key { inner: ::std::thread::__scoped::KeyInner { inner: ::std::thread::__scoped::OS_INIT, marker: ::std::marker::PhantomData::<::std::cell::Cell<$t>>, } }; _INIT }) } #[unstable(feature = \"scoped_tls\", reason = \"scoped TLS has yet to have wide enough use to fully consider stabilizing its interface\")] impl ScopedKey { /// Insert a value into this scoped thread local storage slot for a /// duration of a closure. /// /// While `cb` is running, the value `t` will be returned by `get` unless /// this function is called recursively inside of `cb`. /// /// Upon return, this function will restore the previous value, if any /// was available. /// /// # Examples /// /// ``` /// # #![feature(scoped_tls)] /// scoped_thread_local!(static FOO: u32); /// /// FOO.set(&100, || { /// let val = FOO.with(|v| *v); /// assert_eq!(val, 100); /// /// // set can be called recursively /// FOO.set(&101, || { /// // ... /// }); /// /// // Recursive calls restore the previous value. /// let val = FOO.with(|v| *v); /// assert_eq!(val, 100); /// }); /// ``` pub fn set(&'static self, t: &T, cb: F) -> R where F: FnOnce() -> R, { struct Reset<'a, T: 'a> { key: &'a __impl::KeyInner, val: *mut T, } #[unsafe_destructor] impl<'a, T> Drop for Reset<'a, T> { fn drop(&mut self) { unsafe { self.key.set(self.val) } } } let prev = unsafe { let prev = self.inner.get(); self.inner.set(t as *const T as *mut T); prev }; let _reset = Reset { key: &self.inner, val: prev }; cb() } /// Get a value out of this scoped variable. /// /// This function takes a closure which receives the value of this /// variable. /// /// # Panics /// /// This function will panic if `set` has not previously been called. /// /// # Examples /// /// ```no_run /// # #![feature(scoped_tls)] /// scoped_thread_local!(static FOO: u32); /// /// FOO.with(|slot| { /// // work with `slot` /// }); /// ``` pub fn with(&'static self, cb: F) -> R where F: FnOnce(&T) -> R { unsafe { let ptr = self.inner.get(); assert!(!ptr.is_null(), \"cannot access a scoped thread local variable without calling `set` first\"); cb(&*ptr) } } /// Test whether this TLS key has been `set` for the current thread. pub fn is_set(&'static self) -> bool { unsafe { !self.inner.get().is_null() } } } #[cfg(not(any(windows, target_os = \"android\", target_os = \"ios\", target_os = \"openbsd\", target_arch = \"aarch64\")))] mod imp { use std::cell::UnsafeCell; #[doc(hidden)] pub struct KeyInner { pub inner: UnsafeCell<*mut T> } unsafe impl ::marker::Sync for KeyInner { } #[doc(hidden)] impl KeyInner { #[doc(hidden)] pub unsafe fn set(&self, ptr: *mut T) { *self.inner.get() = ptr; } #[doc(hidden)] pub unsafe fn get(&self) -> *mut T { *self.inner.get() } } } #[cfg(any(windows, target_os = \"android\", target_os = \"ios\", target_os = \"openbsd\", target_arch = \"aarch64\"))] mod imp { use marker; use std::cell::Cell; use sys_common::thread_local::StaticKey as OsStaticKey; #[doc(hidden)] pub struct KeyInner { pub inner: OsStaticKey, pub marker: marker::PhantomData>, } unsafe impl ::marker::Sync for KeyInner { } #[doc(hidden)] impl KeyInner { #[doc(hidden)] pub unsafe fn set(&self, ptr: *mut T) { self.inner.set(ptr as *mut _) } #[doc(hidden)] pub unsafe fn get(&self) -> *mut T { self.inner.get() as *mut _ } } } #[cfg(test)] mod tests { use cell::Cell; use prelude::v1::*; scoped_thread_local!(static FOO: u32); #[test] fn smoke() { scoped_thread_local!(static BAR: u32); assert!(!BAR.is_set()); BAR.set(&1, || { assert!(BAR.is_set()); BAR.with(|slot| { assert_eq!(*slot, 1); }); }); assert!(!BAR.is_set()); } #[test] fn cell_allowed() { scoped_thread_local!(static BAR: Cell); BAR.set(&Cell::new(1), || { BAR.with(|slot| { assert_eq!(slot.get(), 1); }); }); } #[test] fn scope_item_allowed() { assert!(!FOO.is_set()); FOO.set(&1, || { assert!(FOO.is_set()); FOO.with(|slot| { assert_eq!(*slot, 1); }); }); assert!(!FOO.is_set()); } } "}
{"_id":"q-en-rust-2fc051868684b25834e540738f2861a5bb14194bc80cdaaf24f1df977d27a5e6","text":" error: this file contains an un-closed delimiter --> $DIR/issue-58094-missing-right-square-bracket.rs:4:4 | LL | #[Ѕ | - ^ | | | un-closed delimiter error: expected item after attributes --> $DIR/issue-58094-missing-right-square-bracket.rs:4:4 | LL | #[Ѕ | ^ error: aborting due to 2 previous errors "}
{"_id":"q-en-rust-2fcc33c22176acb9ff874f5e2f995045d842da2528b3d9e4fa823714fba5d71d","text":"} } impl rustc_errors::IntoDiagnosticArg for PolyExistentialTraitRef<'_> { fn into_diagnostic_arg(self) -> rustc_errors::DiagnosticArgValue<'static> { self.to_string().into_diagnostic_arg() } } #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, TyEncodable, TyDecodable)] #[derive(HashStable)] pub enum BoundVariableKind {"}
{"_id":"q-en-rust-2fdf67d8019f8b3df9db8afb27e5e7cbf7ea05bf4c02f0f1808cede1383368ee","text":"} let sig = tcx.erase_late_bound_regions(sig); if !sig.output().is_unit() { let r = self.check_type_for_ffi(cache, sig.output()); match r { FfiSafe => {} _ => { return r; } } } for arg in sig.inputs() { let r = self.check_type_for_ffi(cache, *arg); match r { match self.check_type_for_ffi(cache, *arg) { FfiSafe => {} _ => { return r; } r => return r, } } FfiSafe let ret_ty = sig.output(); if ret_ty.is_unit() { return FfiSafe; } self.check_type_for_ffi(cache, ret_ty) } ty::Foreign(..) => FfiSafe,"}
{"_id":"q-en-rust-2fe09a1d9b1ec9a3e35e4f857cd8b1e589f84a7826a10e539a13e18cafccce17","text":".filter_map(|lang_item| self.tcx.lang_items().require(*lang_item).ok()) .collect(); never_suggest_borrow.push(self.tcx.get_diagnostic_item(sym::Send).unwrap()); if let Some(def_id) = self.tcx.get_diagnostic_item(sym::Send) { never_suggest_borrow.push(def_id); } let param_env = obligation.param_env; let trait_ref = poly_trait_ref.skip_binder();"}
{"_id":"q-en-rust-2feaaca3798d5a006236a32ea69546d101d90e76d865bbea4c5fd34fadc2e5d3","text":"continue; } let missing = match source { PathSource::Trait(..) | PathSource::TraitItem(..) | PathSource::Type => true, let node_ids = self.r.next_node_ids(expected_lifetimes); self.record_lifetime_res( segment_id, LifetimeRes::ElidedAnchor { start: node_ids.start, end: node_ids.end }, LifetimeElisionCandidate::Ignore, ); let inferred = match source { PathSource::Trait(..) | PathSource::TraitItem(..) | PathSource::Type => false, PathSource::Expr(..) | PathSource::Pat | PathSource::Struct | PathSource::TupleStruct(..) => false, | PathSource::TupleStruct(..) => true, }; if !missing && !segment.has_generic_args { if inferred { // Do not create a parameter for patterns and expressions: type checking can infer // the appropriate lifetime for us. for id in node_ids { self.record_lifetime_res( id, LifetimeRes::Infer, LifetimeElisionCandidate::Named, ); } continue; }"}
{"_id":"q-en-rust-2ffcc7ae7daa266fb3270e7f6c09a630ae622e2753bfffe6a7e4b72de316ba37","text":"move_place: &Place<'tcx>, deref_target_place: &Place<'tcx>, span: Span, use_spans: Option, ) -> DiagnosticBuilder<'a> { // Inspect the type of the content behind the // borrow to provide feedback about why this"}
{"_id":"q-en-rust-3014e8aa21dfd43ddbb5899bc3a7692ec4402f8523fe53a0cf7da729c0aacc98","text":" // compile-flags: -Znext-solver #![feature(lazy_type_alias)] //~^ WARN the feature `lazy_type_alias` is incomplete trait Foo {} type A = T; struct W(T); // For `W>` to be WF, `A: Sized` must hold. However, when assembling // alias bounds for `A`, we try to normalize it, but it doesn't hold because // `usize: Foo` doesn't hold. Therefore we ICE, because we don't expect to still // encounter weak types in `assemble_alias_bound_candidates_recur`. fn hello(_: W>) {} //~^ ERROR the type `W>` is not well-formed fn main() {} "}
{"_id":"q-en-rust-3033ba76e479c58b80f460be40e580316762a63765a63214ad159013475cc53f","text":" // Copyright 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 or the MIT license // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. fn main() { let mut c = (1, \"\".to_owned()); match c { c2 => { c.0 = 2; assert_eq!(c2.0, 1); } } } "}
{"_id":"q-en-rust-30a678fd034cef7e2b3d00f284dd1c23a608a12e8a186d9631180058db60b912","text":"// option. This file may not be copied, modified, or distributed // except according to those terms. #[doc(keyword = \"as\")] // /// The type coercion keyword. /// /// `as` is most commonly used to turn primitive types into other primitive types, but it has other /// uses that include turning pointers into addresses, addresses into pointers, and pointers into /// other pointers. /// /// ```rust /// let thing1: u8 = 89.0 as u8; /// assert_eq!('B' as u32, 66); /// assert_eq!(thing1 as char, 'Y'); /// let thing2: f32 = thing1 as f32 + 10.5; /// assert_eq!(true as u8 + thing2 as u8, 100); /// ``` /// /// In general, any coercion that can be performed via writing out type hints can also be done /// using `as`, so instead of writing `let x: u32 = 123`, you can write `let x = 123 as u32` (Note: /// `let x = 123u32` would be best in that situation). The same is not true in the other direction, /// however, explicitly using `as` allows a few more coercions that aren't allowed implicitly, such /// as changing the type of a raw pointer or turning closures into raw pointers. /// /// For more information on what `as` is capable of, see the [Reference] /// /// [Reference]: https://doc.rust-lang.org/reference/expressions/operator-expr.html#type-cast-expressions mod as_keyword { } #[doc(keyword = \"const\")] // /// The keyword for defining constants. /// /// Sometimes a certain value is used many times throughout a program, and it can become /// inconvenient to copy it over and over. What's more, it's not always possible or desirable to /// make it a variable that gets carried around to each function that needs it. In these cases, the /// `const` keyword provides a convenient alternative to code duplication. /// /// ```rust /// const THING: u32 = 0xABAD1DEA; /// /// let foo = 123 + THING; /// ``` /// /// Constants must be explicitly typed, unlike with `let` you can't ignore its type and let the /// compiler figure it out. Any constant value can be defined in a const, which in practice happens /// to be most things that would be reasonable to have a constant. For example, you can't have a /// File as a `const`. /// /// The only lifetime allowed in a constant is 'static, which is the lifetime that encompasses all /// others in a Rust program. For example, if you wanted to define a constant string, it would look /// like this: /// /// ```rust /// const WORDS: &'static str = \"hello rust!\"; /// ``` /// /// Thanks to static lifetime elision, you usually don't have to explicitly use 'static: /// /// ```rust /// const WORDS: &str = \"hello convenience!\"; /// ``` /// /// `const` items looks remarkably similar to [`static`] items, which introduces some confusion as /// to which one should be used at which times. To put it simply, constants are inlined wherever /// they're used, making using them identical to simply replacing the name of the const with its /// value. Static variables on the other hand point to a single location in memory, which all /// accesses share. This means that, unlike with constants, they can't have destructors, but it /// also means that (via unsafe code) they can be mutable, which is useful for the rare situations /// in which you can't avoid using global state. /// /// Constants, as with statics, should always be in SCREAMING_SNAKE_CASE. /// /// The `const` keyword is also used in raw pointers in combination with `mut`, as seen in `*const /// T` and `*mut T`. More about that can be read at the [pointer] primitive part of the Rust docs. /// /// For more detail on `const`, see the [Rust Book] or the [Reference] /// /// [`static`]: keyword.static.html /// [pointer]: primitive.pointer.html /// [Rust Book]: https://doc.rust-lang.org/stable/book/2018-edition/ch03-01-variables-and-mutability.html#differences-between-variables-and-constants /// [Reference]: https://doc.rust-lang.org/reference/items/constant-items.html mod const_keyword { } #[doc(keyword = \"crate\")] // /// The `crate` keyword. /// /// The primary use of the `crate` keyword is as a part of `extern crate` declarations, which are /// used to specify a dependency on a crate external to the one it's declared in. Crates are the /// fundamental compilation unit of Rust code, and can be seen as libraries or projects. More can /// be read about crates in the [Reference]. /// /// ```rust ignore /// extern crate rand; /// extern crate my_crate as thing; /// extern crate std; // implicitly added to the root of every Rust project /// ``` /// /// The `as` keyword can be used to change what the crate is referred to as in your project. If a /// crate name includes a dash, it is implicitly imported with the dashes replaced by underscores. /// /// `crate` is also used as in conjunction with [`pub`] to signify that the item it's attached to /// is public only to other members of the same crate it's in. /// /// ```rust /// # #[allow(unused_imports)] /// pub(crate) use std::io::Error as IoError; /// pub(crate) enum CoolMarkerType { } /// pub struct PublicThing { /// pub(crate) semi_secret_thing: bool, /// } /// ``` /// /// [Reference]: https://doc.rust-lang.org/reference/items/extern-crates.html /// [`pub`]: keyword.pub.html mod crate_keyword { } #[doc(keyword = \"enum\")] // /// For defining enumerations. /// /// Enums in Rust are similar to those of other compiled languages like C, but have important /// differences that make them considerably more powerful. What Rust calls enums are more commonly /// known as Algebraic Data Types if you're coming from a functional programming background, but /// the important part is that data can go with the enum variants. /// /// ```rust /// # struct Coord; /// enum SimpleEnum { /// FirstVariant, /// SecondVariant, /// ThirdVariant, /// } /// /// enum Location { /// Unknown, /// Anonymous, /// Known(Coord), /// } /// /// enum ComplexEnum { /// Nothing, /// Something(u32), /// LotsOfThings { /// usual_struct_stuff: bool, /// blah: String, /// } /// } /// /// enum EmptyEnum { } /// ``` /// /// The first enum shown is the usual kind of enum you'd find in a C-style language. The second /// shows off a hypothetical example of something storing location data, with Coord being any other /// type that's needed, for example a struct. The third example demonstrates the kind of variant a /// variant can store, ranging from nothing, to a tuple, to an anonymous struct. /// /// Instantiating enum variants involves explicitly using the enum's name as its namespace, /// followed by one of its variants. `SimpleEnum::SecondVariant` would be an example from above. /// When data follows along with a variant, such as with rust's built-in [`Option`] type, the data /// is added as the type describes, for example `Option::Some(123)`. The same follows with /// struct-like variants, with things looking like `ComplexEnum::LotsOfThings { usual_struct_stuff: /// true, blah: \"hello!\".to_string(), }`. Empty Enums are similar to () in that they cannot be /// instantiated at all, and are used mainly to mess with the type system in interesting ways. /// /// For more information, take a look at the [Rust Book] or the [Reference] /// /// [`Option`]: option/enum.Option.html /// [Rust Book]: https://doc.rust-lang.org/book/second-edition/ch06-01-defining-an-enum.html /// [Reference]: https://doc.rust-lang.org/reference/items/enumerations.html mod enum_keyword { } #[doc(keyword = \"extern\")] // /// For external connections in Rust code. /// /// The `extern` keyword is used in two places in Rust. One is in conjunction with the [`crate`] /// keyword to make your Rust code aware of other Rust crates in your project, i.e. `extern crate /// lazy_static;`. The other use is in foreign function interfaces (FFI). /// /// `extern` is used in two different contexts within FFI. The first is in the form of external /// blcoks, for declaring function interfaces that Rust code can call foreign code by. /// /// ```rust ignore /// #[link(name = \"my_c_library\")] /// extern \"C\" { /// fn my_c_function(x: i32) -> bool; /// } /// ``` /// /// This code would attempt to link with libmy_c_library.so on unix-like systems and /// my_c_library.dll on Windows at runtime, and panic if it can't find something to link to. Rust /// code could then use `my_c_function` as if it were any other unsafe Rust function. Working with /// non-Rust languages and FFI is inherently unsafe, so wrappers are usually built around C APIs. /// /// The mirror use case of FFI is also done via the `extern` keyword: /// /// ```rust /// # #![allow(private_no_mangle_fns)] /// #[no_mangle] /// pub extern fn callable_from_c(x: i32) -> bool { /// x % 3 == 0 /// } /// ``` /// /// If compiled as a dylib, the resulting .so could then be linked to from a C library, and the /// function could be used as if it was from any other library. /// /// For more information on FFI, check the [Rust book] or the [Reference]. /// /// [Rust book]: https://doc.rust-lang.org/book/second-edition/ch19-01-unsafe-rust.html#using-extern-functions-to-call-external-code /// [Reference]: https://doc.rust-lang.org/reference/items/external-blocks.html mod extern_keyword { } #[doc(keyword = \"fn\")] // /// The `fn` keyword. /// The keyword for defining functions. /// /// The `fn` keyword is used to declare a function. /// Functions are the primary way code is executed within Rust. Function blocks, usually just /// called functions, can be defined in a variety of different places and be assigned many /// different attributes and modifiers. /// /// Example: /// Standalone functions that just sit within a module not attached to anything else are common, /// but most functions will end up being inside [`impl`] blocks, either on another type itself, or /// as a trait impl for that type. /// /// ```rust /// fn some_function() { /// // code goes in here /// fn standalone_function() { /// // code /// } /// /// pub fn public_thing(argument: bool) -> String { /// // code /// # \"\".to_string() /// } /// /// struct Thing { /// foo: i32, /// } /// /// impl Thing { /// pub fn new() -> Self { /// Self { /// foo: 42, /// } /// } /// } /// ``` /// /// For more information about functions, take a look at the [Rust Book][book]. /// See docs on [`impl`] and [`self`] for relevant details on those. /// /// In addition to presenting fixed types in the form of `fn name(arg: type, ..) -> return_type`, /// functions can also declare a list of type parameters along with trait bounds that they fall /// into. /// /// ```rust /// fn generic_function(x: T) -> (T, T, T) { /// (x.clone(), x.clone(), x.clone()) /// } /// /// [book]: https://doc.rust-lang.org/book/second-edition/ch03-03-how-functions-work.html /// fn generic_where(x: T) -> T /// where T: std::ops::Add mod fn_keyword { } #[doc(keyword = \"for\")] // /// The `for` keyword. /// /// `for` is primarily used in for-in-loops, but it has a few other pieces of syntactic uses such as /// `impl Trait for Type` (see [`impl`] for more info on that). for-in-loops, or to be more /// precise, iterator loops, are a simple syntactic sugar over an exceedingly common practice /// within Rust, which is to loop over an iterator until that iterator returns None (or [`break`] /// is called). /// /// ```rust /// for i in 0..5 { /// println!(\"{}\", i * 2); /// } /// /// for i in std::iter::repeat(5) { /// println!(\"turns out {} never stops being 5\", i); /// break; // would loop forever otherwise /// } /// /// 'outer: for x in 5..50 { /// for y in 0..10 { /// if x == y { /// break 'outer; /// } /// } /// } /// ``` /// /// As shown in the example above, `for` loops (along with all other loops) can be tagged, using /// similar syntax to lifetimes (only visually similar, entirely distinct in practice). Giving the /// same tag to `break` breaks the tagged loop, which is useful for inner loops. It is definitely /// not a goto. /// /// A `for` loop expands as shown: /// /// ```rust /// # fn code() { } /// # let iterator = 0..2; /// for loop_variable in iterator { /// code() /// } /// ``` /// /// ```rust /// # fn code() { } /// # let iterator = 0..2; /// { /// let mut _iter = std::iter::IntoIterator::into_iter(iterator); /// loop { /// match _iter.next() { /// Some(loop_variable) => { /// code() /// }, /// None => break, /// } /// } /// } /// ``` /// /// More details on the functionality shown can be seen at the [`IntoIterator`] docs. /// /// For more information on for-loops, see the [Rust book] or the [Reference]. /// /// [`impl`]: keyword.impl.html /// [`break`]: keyword.break.html /// [`IntoIterator`]: iter/trait.IntoIterator.html /// [Rust book]: https://doc.rust-lang.org/book/2018-edition/ch03-05-control-flow.html#looping-through-a-collection-with-for /// [Reference]: https://doc.rust-lang.org/reference/expressions/loop-expr.html#iterator-loops mod for_keyword { } #[doc(keyword = \"if\")] // /// If statements and expressions. /// /// `if` is a familiar construct to most programmers, and is the main way you'll often do logic in /// your code. However, unlike in most languages, `if` blocks can also act as expressions. /// /// ```rust /// # let rude = true; /// if 1 == 2 { /// println!(\"whoops, mathematics broke\"); /// } else { /// println!(\"everything's fine!\"); /// } /// /// let greeting = if rude { /// \"sup nerd.\" /// } else { /// \"hello, friend!\" /// }; /// /// if let Ok(x) = \"123\".parse::() { /// println!(\"{} double that and you get {}!\", greeting, x * 2); /// } /// ``` /// /// Shown above are the three typical forms an `if` block comes in. First is the usual kind of /// thing you'd see in many languages, with an optional `else` block. Second uses `if` as an /// expression, which is only possible if all branches return the same type. An `if` expression can /// be used everywhere you'd expect. The third kind of `if` block is an `if let` block, which /// behaves similarly to using a [`match`] expression: /// /// ```rust /// if let Some(x) = Some(123) { /// // code /// # let _ = x; /// } else { /// // something else /// } /// /// match Some(123) { /// Some(x) => { /// // code /// # let _ = x; /// }, /// _ => { /// // something else /// }, /// } /// ``` /// /// See [`let`] for more information on pattern bindings. /// /// Each kind of `if` expression can be mixed and matched as needed. /// /// ```rust /// if true == false { /// println!(\"oh no\"); /// } else if \"something\" == \"other thing\" { /// println!(\"oh dear\"); /// } else if let Some(200) = \"blarg\".parse::().ok() { /// println!(\"uh oh\"); /// } else { /// println!(\"phew, nothing's broken\"); /// } /// ``` /// /// The `if` keyword is used in one other place in Rust, namely as a part of pattern matching /// itself, allowing patterns such as `Some(x) if x > 200` to be used. /// /// For more information on `if` expressions, see the [Rust book] or the [Reference]. /// /// [`match`]: keyword.match.html /// [`let`]: keyword.let.html /// [Rust book]: https://doc.rust-lang.org/stable/book/2018-edition/ch03-05-control-flow.html#if-expressions /// [Reference]: https://doc.rust-lang.org/reference/expressions/if-expr.html mod if_keyword { } #[doc(keyword = \"let\")] // /// The `let` keyword."}
{"_id":"q-en-rust-30b78a8222f6ad070f7a432648a0f066164e513def0d1be39dc74aa4dc241f1c","text":" error: expected expression, found reserved keyword `try` --> $DIR/try-block-in-while.rs:6:11 error[E0277]: the trait bound `bool: std::ops::Try` is not satisfied --> $DIR/try-block-in-while.rs:6:15 | LL | while try { false } {} | ^^^ expected expression | ^^^^^^^^^ the trait `std::ops::Try` is not implemented for `bool` | = note: required by `std::ops::Try::from_ok` error: aborting due to previous error For more information about this error, try `rustc --explain E0277`. "}
{"_id":"q-en-rust-30cc380df81c9d9df32374599ff62b4c8fc8de82cd4a3e78d5ade151dae91399","text":".iter() .enumerate() .filter(|x| x.1.hir_id == *hir_id) .map(|(i, _)| init_tup.get(i).unwrap()) .next() .find_map(|(i, _)| init_tup.get(i)) { self.note_type_is_not_clone_inner_expr(init) } else {"}
{"_id":"q-en-rust-30e3677b1f89e86c5797e061a9ca50cc281a58f0b30320568453d8b2f03731e8","text":" struct TestClient; impl TestClient { fn get_inner_ref(&self) -> &Vec { todo!() } } fn main() { let client = TestClient; let inner = client.get_inner_ref(); //~^ HELP consider changing this to be a mutable reference inner.clear(); //~^ ERROR cannot borrow `*inner` as mutable, as it is behind a `&` reference [E0596] } "}
{"_id":"q-en-rust-30f5ca6126caa876b0ec5db591637fe9c6316061f3c77bd8e3ea59ba78594e4f","text":" // 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 or the MIT license // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. "}
{"_id":"q-en-rust-3134d794e867e83734815328645c6d1122a977d62a4f81dbbc2080e0c61bcd71","text":"let _: Wow; //~^ ERROR expected one of //~| HELP expressions must be enclosed in braces to be used as const generic arguments // FIXME(compiler-errors): This one is still unsatisfying, // and probably a case I could see someone typing by accident.. let _: Wow<[]>; //~^ ERROR expected type //~| HELP expressions must be enclosed in braces to be used as const generic arguments let _: Wow<[12]>; //~^ ERROR expected type, found //~| ERROR type provided when a constant was expected //~^ ERROR expected type //~| ERROR invalid const generic expression //~| HELP expressions must be enclosed in braces to be used as const generic arguments let _: Wow<[0, 1, 3]>; //~^ ERROR expected type //~| HELP expressions must be enclosed in braces to be used as const generic arguments let _: Wow<[0xff; 8]>; //~^ ERROR expected type //~| ERROR invalid const generic expression //~| HELP expressions must be enclosed in braces to be used as const generic arguments let _: Wow<[1, 2]>; // Regression test for issue #81698. //~^ ERROR expected type //~| HELP expressions must be enclosed in braces to be used as const generic arguments let _: Wow<&0>; //~^ ERROR expected type //~| HELP expressions must be enclosed in braces to be used as const generic arguments let _: Wow<(\"\", 0)>; //~^ ERROR expected type //~| HELP expressions must be enclosed in braces to be used as const generic arguments let _: Wow<(1 + 2) * 3>; //~^ ERROR expected type //~| HELP expressions must be enclosed in braces to be used as const generic arguments // FIXME(fmease): This one is pretty bad. let _: Wow; //~^ ERROR expected one of //~| HELP you might have meant to end the type parameters here }"}
{"_id":"q-en-rust-316b566c0bc5bd7e7d33e9573a33cd11394c0c0ecb207ede1cf201332a9472e7","text":" // revisions:rpass1 rpass2 struct A; #[cfg(rpass2)] impl From for () { fn from(_: A) {} } fn main() {} "}
{"_id":"q-en-rust-31b5df296b61db95d79ea6c8996d2cec62063ed22c714c59dc3bf35b7eee7934","text":"} /// Builds drops for pop_scope and exit_scope. fn build_scope_drops<'tcx>(mut block: BasicBlock, fn build_scope_drops<'tcx>(cfg: &mut CFG<'tcx>, scope: &Scope<'tcx>, earlier_scopes: &[Scope<'tcx>], cfg: &mut CFG<'tcx>) mut block: BasicBlock) -> BlockAnd<()> { let mut iter = scope.drops.iter().rev().peekable(); while let Some(drop_data) = iter.next() {"}
{"_id":"q-en-rust-31bbae668e53afc6fa1c0de694e8a48d662dd7368cba9620cc37feb87840ea63","text":"DependencyType::TargetSelfContained, ); } let crt_path = builder.ensure(native::CrtBeginEnd { target }); for &obj in &[\"crtbegin.o\", \"crtbeginS.o\", \"crtend.o\", \"crtendS.o\"] { let src = compiler_file(builder, builder.cc(target), target, obj); let src = crt_path.join(obj); let target = libdir_self_contained.join(obj); builder.copy(&src, &target); target_deps.push((target, DependencyType::TargetSelfContained));"}
{"_id":"q-en-rust-31c622facdc72b8fcd4e850ae1de7a1984f801da60ca944a7470b984e759ab8c","text":"cx.generated_synthetics.insert((ty, trait_def_id)); let hir_imp = impl_def_id.as_local() .map(|local| cx.tcx.hir().expect_item(local)) .and_then(|item| if let hir::ItemKind::Impl(i) = &item.kind { Some(i) } else { None }); let items = match hir_imp { Some(imp) => imp .items .iter() .map(|ii| cx.tcx.hir().impl_item(ii.id).clean(cx)) .collect::>(), None => cx.tcx .associated_items(impl_def_id) .in_definition_order() .map(|x| x.clean(cx)) .collect::>(), }; impls.push(Item { name: None, attrs: Default::default(),"}
{"_id":"q-en-rust-31da9f7a7f9ca98537754e695ef3360787cc6bb7d77cd5fd57f165c1e9166b1d","text":" error: expected one of `(`, `,`, `=`, `{`, or `}`, found `#` --> $DIR/help-set-edition-ice-122130.rs:2:6 | LL | s#[c\"owned_box\"] | ^ expected one of `(`, `,`, `=`, `{`, or `}` | = note: you may be trying to write a c-string literal = note: c-string literals require Rust 2021 or later = help: pass `--edition 2021` to `rustc` = note: for more on editions, read https://doc.rust-lang.org/edition-guide error: expected item, found `\"owned_box\"` --> $DIR/help-set-edition-ice-122130.rs:2:9 | LL | s#[c\"owned_box\"] | ^^^^^^^^^^^ expected item | = note: for a full list of items that can appear in modules, see error: aborting due to 2 previous errors "}
{"_id":"q-en-rust-31ddd09d2289304963e559a60187ad9771a989e5ca74fc344e07938e16ddd24a","text":" // Suggest to a user to use the print macros // instead to use the printf. fn main() { let x = 4; printf(\"%d\", x); //~^ ERROR cannot find function `printf` in this scope //~| HELP you may have meant to use the `print` macro } "}
{"_id":"q-en-rust-325bb8b6bcb7528645777c60928f565f8d70978fc8f9bf500aebabdeed8f6a5e","text":"#[subdiagnostic] pub req_introduces_loc: Option, pub has_param_name: bool, pub param_name: String, pub spans_empty: bool, pub has_lifetime: bool, pub lifetime: String,"}
{"_id":"q-en-rust-329103a093abc78d56773f704b6e4e2088ee18996a44128f19d84bd3a57d5272","text":" // force-host // no-prefer-dynamic #![crate_type = \"proc-macro\"] extern crate proc_macro; use proc_macro::TokenStream; #[proc_macro_attribute] pub fn vec_ice(_attr: TokenStream, input: TokenStream) -> TokenStream { // This redundant convert is necessary to reproduce ICE. input.into_iter().collect() } "}
{"_id":"q-en-rust-32e989cba840da736cc43fd5cd32e19f97423db8e68cd3ef9341ab24eac1689d","text":"match view_path.node { ViewPathSimple(binding, ref full_path) => { let source_name = full_path.segments.last().unwrap().identifier.name; if source_name.as_str() == \"mod\" || source_name.as_str() == \"self\" { let mut source = full_path.segments.last().unwrap().identifier; let source_name = source.name.as_str(); if source_name == \"mod\" || source_name == \"self\" { resolve_error(self, view_path.span, ResolutionError::SelfImportsOnlyAllowedWithin); } else if source_name == \"$crate\" && full_path.segments.len() == 1 { let crate_root = self.resolve_crate_var(source.ctxt); let crate_name = match crate_root.kind { ModuleKind::Def(_, name) => name, ModuleKind::Block(..) => unreachable!(), }; source.name = crate_name; self.session.struct_span_warn(item.span, \"`$crate` may not be imported\") .note(\"`use $crate;` was erroneously allowed and will become a hard error in a future release\") .emit(); } let subclass = ImportDirectiveSubclass::single(binding.name, source_name); let subclass = ImportDirectiveSubclass::single(binding.name, source.name); let span = view_path.span; self.add_import_directive(module_path, subclass, span, item.id, vis); }"}
{"_id":"q-en-rust-3313070ce5209085dac4a2d9c9778306f101430f354aea561aaa4dd2629e1ece","text":"//! //! [rustc dev guide]: https://rustc-dev-guide.rust-lang.org/mir/index.html // ignore-tidy-filelength use crate::mir::interpret::{GlobalAlloc, Scalar}; use crate::mir::visit::MirVisitable; use crate::ty::adjustment::PointerCast;"}
{"_id":"q-en-rust-332882707b0fbdda2ffe2717d67a097441a3508ad0f7bb738133c77f9e91fc49","text":"all( not(target_arch = \"aarch64\"), not(target_arch = \"powerpc\"), not(target_arch = \"s390x\"), not(target_arch = \"x86_64\") ), all(target_arch = \"aarch64\", any(target_os = \"macos\", target_os = \"ios\")),"}
{"_id":"q-en-rust-335006f74cd1d0040d621f18a2be34376b8b946937906916914d18f4b568181d","text":"let hir_id = self.tcx().hir().as_local_hir_id(def_id).unwrap(); let instantiated_ty = self.resolve(&opaque_defn.concrete_ty, &hir_id); debug_assert!(!instantiated_ty.has_escaping_bound_vars()); let generics = self.tcx().generics_of(def_id); let definition_ty = if generics.parent.is_some() {"}
{"_id":"q-en-rust-3368bb5bd8b029c59c31b30fc3fd852f381fad0face186ab3e58eea778a5d5a1","text":"src_href: src_href.as_deref(), }; let heading = item_vars.render().unwrap(); buf.write_str(&heading); item_vars.render_into(buf).unwrap(); match *item.kind { clean::ModuleItem(ref m) => item_module(buf, cx, item, &m.items),"}
{"_id":"q-en-rust-337fdd9bfe88cf5729e75e58a4efb2fa462391c50aa54cd0cad8fe6996457a73","text":"expr: &hir::Expr<'_>, found: Ty<'tcx>, expected: Ty<'tcx>, mismatch_span: Span, ) -> bool { let map = self.tcx.hir();"}
{"_id":"q-en-rust-3391dc28404db366c48f0fcc6916b733744b7c52bfe220d4f2ec0cadea625f7c","text":"&& adt.is_fundamental() { for ty in generics { if let Some(did) = ty.def_id(self.cache) { dids.insert(did); } dids.extend(ty.def_id(self.cache)); } } }"}
{"_id":"q-en-rust-339bfca84b1d788d05b5318bd9b4c5dab834c666401e5c1a48e8be85347bfb7c","text":" error: trait objects without an explicit `dyn` are deprecated --> $DIR/issue-61963.rs:20:14 | LL | bar: Box, | ^^^ help: use `dyn`: `dyn Bar` | note: lint level defined here --> $DIR/issue-61963.rs:3:9 | LL | #![deny(bare_trait_objects)] | ^^^^^^^^^^^^^^^^^^ error: aborting due to previous error "}
{"_id":"q-en-rust-33beccab08511dcbaf85b08036652d487aeba0e3a4686e3ec8fcd0e16ea4717a","text":" // Note: this test is paired with logo-class.rs. // @has logo_class_default/struct.SomeStruct.html '//*[@class=\"logo-container\"]/img[@class=\"rust-logo\"]' '' // @has logo_class_default/struct.SomeStruct.html '//*[@class=\"sub-logo-container\"]/img[@class=\"rust-logo\"]' '' pub struct SomeStruct; "}
{"_id":"q-en-rust-33cdb08f334a71c0e69ab4f51e02f2e1c6a34120a8f8de9ac762efd8958a740f","text":".and_modify(|e| { *e = (e.0.clone(), Some(rhs.ty().unwrap().clone())) }) .or_insert((None, Some(rhs.ty().unwrap().clone()))); .or_insert(( PolyTrait { trait_: trait_.clone(), generic_params: Vec::new(), }, Some(rhs.ty().unwrap().clone()), )); continue; }"}
{"_id":"q-en-rust-33da468c3a2500d75564c7516d64a82a2cd88a2dd0a8ab0427b067290e6f77aa","text":"else_ty) } None => { check_block_no_value(fcx, then_blk); ty::mk_nil() infer::common_supertype(fcx.infcx(), infer::IfExpressionWithNoElse(sp), false, then_ty, ty::mk_nil()) } };"}
{"_id":"q-en-rust-33eb9fba36a810b6afa71ca4f8ab2d469d12110766b83ced689dc2639a4c78b3","text":"if !self.any_library { // If we are building an executable, only explicitly extern // types need to be exported. if has_custom_linkage(self.tcx, search_item) { let codegen_attrs = if self.tcx.def_kind(search_item).has_codegen_attrs() { self.tcx.codegen_fn_attrs(search_item) } else { CodegenFnAttrs::EMPTY }; let is_extern = codegen_attrs.contains_extern_indicator(); let std_internal = codegen_attrs.flags.contains(CodegenFnAttrFlags::RUSTC_STD_INTERNAL_SYMBOL); if is_extern || std_internal { self.reachable_symbols.insert(search_item); } } else {"}
{"_id":"q-en-rust-34740624ce78465ee50b9fddc3ec1fe55e851bfb7d105378f97205db170c73da","text":" error[E0271]: type mismatch resolving `<&i32 as Deref>::Target == String` --> $DIR/default-body-type-err.rs:7:22 | LL | fn lol(&self) -> impl Deref { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `i32`, found struct `String` LL | LL | &1i32 | ----- return type was inferred to be `&i32` here error: aborting due to previous error For more information about this error, try `rustc --explain E0271`. "}
{"_id":"q-en-rust-34788456920d71883b72f1bb371883b1f75aee5b2cfd184d07f33d6d2aefc516","text":" trait Trait {} impl Trait for i32 {} // Since `Assoc` doesn't actually exist, it's \"stranded\", and won't show up in // the list of opaques that may be defined by the function. Make sure we don't // ICE in this case. fn produce() -> impl Trait { //~^ ERROR associated type `Assoc` not found for `Trait` 16 } fn main () {} "}
{"_id":"q-en-rust-347db88b9583cffb99f514a6abdc7080778fc486bcce9801ef67e394bb032380","text":" error[E0133]: use of extern static is unsafe and requires unsafe function or block --> $DIR/issue-28575.rs:8:5 | LL | FOO() | ^^^ use of extern static | = note: extern statics are not controlled by the Rust type system: invalid data, aliasing violations or data races will cause undefined behavior error: aborting due to previous error For more information about this error, try `rustc --explain E0133`. "}
{"_id":"q-en-rust-34856d4ceffe671d859ae3f2c9d41d45f5f5311c56f863e5a04717741bd4167c","text":"// *in Rust code* may unwind. Foreign items like `extern \"C\" { // fn foo(); }` are assumed not to unwind **unless** they have // a `#[unwind]` attribute. } else if !cx.tcx.is_foreign_item(id) { } else if id.map(|id| !cx.tcx.is_foreign_item(id)).unwrap_or(false) { Some(true) } else { None"}
{"_id":"q-en-rust-34c1a30035a567b06342242ed6305a19e6f7ad8fe766c3e33e3f24db64428f03","text":"Box::new(MaybeUninit::uninit()) } // FIXME: add a test for a bigger box. Currently broken, see // https://github.com/rust-lang/rust/issues/58201. // https://github.com/rust-lang/rust/issues/58201 #[no_mangle] pub fn box_uninitialized2() -> Box> { // CHECK-LABEL: @box_uninitialized2 // CHECK-NOT: store // CHECK-NOT: alloca // CHECK-NOT: memcpy // CHECK-NOT: memset Box::new(MaybeUninit::uninit()) } // Hide the LLVM 15+ `allocalign` attribute in the declaration of __rust_alloc // from the CHECK-NOT above. We don't check the attributes here because we can't rely"}
{"_id":"q-en-rust-34e2179e87e44d531ab23142a444bbed8fb811809b8dc2e21b05fe43484e2f08","text":"addClass(search, \"hidden\"); removeClass(main, \"hidden\"); document.title = titleBeforeSearch; // We also remove the query parameter from the URL. if (browserSupportsHistoryApi()) { history.replaceState(\"\", window.currentCrate + \" - Rust\", getNakedUrl() + window.location.hash); } } // used for special search precedence"}
{"_id":"q-en-rust-34e6f1ffad1d627e106766e0f2d20d33c41289f2f1d297e5fa1a39981b03a7e6","text":"self.parent_scope.module = old_module; } else { match &item.kind { ItemKind::Impl(box ast::Impl { of_trait: Some(..), .. }) => { ItemKind::Impl(box ast::Impl { of_trait: Some(trait_ref), .. }) => { if let Some(partial_res) = self.resolver.get_partial_res(trait_ref.ref_id) && let Some(res) = partial_res.full_res() && let Some(trait_def_id) = res.opt_def_id() && !trait_def_id.is_local() && self.visited_mods.insert(trait_def_id) { self.resolve_doc_links_extern_impl(trait_def_id, false); } self.all_trait_impls.push(self.resolver.local_def_id(item.id).to_def_id()); } ItemKind::MacroDef(macro_def) if macro_def.macro_rules => {"}
{"_id":"q-en-rust-350b6c188e20f904c4cce4d11f4fb352dfa410456c87a954fadd9fa77c889d20","text":"var params = getQueryStringParams(); if (params && params.search) { var search = getSearchElement(); search.innerHTML = \"
Loading search results...
\"; search.innerHTML = \"
\" + getSearchLoadingText() + \"
\"; showSearchResults(search); }"}
{"_id":"q-en-rust-350e274ef6e82a00ba99357a3982b6ed9d0b64494cf2da840510109239afbd59","text":"/// `&mut T` references can be freely coerced into `&T` references with the same referent type, and /// references with longer lifetimes can be freely coerced into references with shorter ones. /// /// Reference equality by address, instead of comparing the values pointed to, is accomplished via /// implicit reference-pointer coercion and raw pointer equality via [`ptr::eq`], while /// [`PartialEq`] compares values. /// /// [`ptr::eq`]: ptr/fn.eq.html /// [`PartialEq`]: cmp/trait.PartialEq.html /// /// ``` /// use std::ptr; /// /// let five = 5; /// let other_five = 5; /// let five_ref = &five; /// let same_five_ref = &five; /// let other_five_ref = &other_five; /// /// assert!(five_ref == same_five_ref); /// assert!(five_ref == other_five_ref); /// /// assert!(ptr::eq(five_ref, same_five_ref)); /// assert!(!ptr::eq(five_ref, other_five_ref)); /// ``` /// /// For more information on how to use references, see [the book's section on \"References and /// Borrowing\"][book-refs]. /// /// [book-refs]: ../book/second-edition/ch04-02-references-and-borrowing.html /// /// # Trait implementations /// /// The following traits are implemented for all `&T`, regardless of the type of its referent: /// /// * [`Copy`]"}
{"_id":"q-en-rust-3562623152eb4f1f900c204659e0e0165d03898feb11d5bd35ad757c7dd1c7f7","text":"// Ensure that `libLLVM.so` ends up in the newly build compiler directory, // so that it can be found when the newly built `rustc` is run. dist::maybe_install_llvm_dylib(builder, target_compiler.host, &sysroot); dist::maybe_install_llvm_runtime(builder, target_compiler.host, &sysroot); dist::maybe_install_llvm_target(builder, target_compiler.host, &sysroot); // Link the compiler binary itself into place let out_dir = builder.cargo_out(build_compiler, Mode::Rustc, host);"}
{"_id":"q-en-rust-3596632afcb363abe1804f83f4f9d01c1635068d3f51c444dca92bf02f72d022","text":"let mode = match tcx.hir().body_owner_kind(hir_id) { HirKind::Closure => return None, HirKind::Fn if tcx.is_const_fn(def_id) => ConstKind::ConstFn, // Note: this is deliberately checking for `is_const_fn_raw`, as the `is_const_fn` // checks take into account the `rustc_const_unstable` attribute combined with enabled // feature gates. Otherwise, const qualification would _not check_ whether this // function body follows the `const fn` rules, as an unstable `const fn` would // be considered \"not const\". More details are available in issue #67053. HirKind::Fn if tcx.is_const_fn_raw(def_id) => ConstKind::ConstFn, HirKind::Fn => return None, HirKind::Const => ConstKind::Const,"}
{"_id":"q-en-rust-359ce110518f4dcf7ee91cbbd47f71476a6a0efcebab9c6cb3b37f947166dcde","text":"/// # Examples /// /// ``` /// #![feature(ptr_hash)] /// use std::collections::hash_map::DefaultHasher; /// use std::hash::{Hash, Hasher}; /// use std::ptr;"}
{"_id":"q-en-rust-35ad80325bccd0931513fbd142737f4db00603b474839407738d9b3299cc8654","text":" use crate::spec::{LinkerFlavor, PanicStrategy, Target, TargetResult}; use crate::spec::{LinkerFlavor, Target, TargetResult}; pub fn target() -> TargetResult { let mut base = super::windows_msvc_base::opts();"}
{"_id":"q-en-rust-35eafdd4fe8a1b7e1706cfc2162a0385368852c9bdaec6f0cc44dbe6013bfead","text":"//~^ ERROR doesn't implement } pub fn main() { } trait Foo { const SIZE: usize = core::mem::size_of::(); //~^ ERROR the size for values of type `Self` cannot be known at compilation time } trait Bar: std::fmt::Display { const SIZE: usize = core::mem::size_of::(); //~^ ERROR the size for values of type `Self` cannot be known at compilation time } trait Baz where Self: std::fmt::Display { const SIZE: usize = core::mem::size_of::(); //~^ ERROR the size for values of type `Self` cannot be known at compilation time } trait Qux where Self: std::fmt::Display { const SIZE: usize = core::mem::size_of::(); //~^ ERROR the size for values of type `Self` cannot be known at compilation time } trait Bat: std::fmt::Display { const SIZE: usize = core::mem::size_of::(); //~^ ERROR the size for values of type `Self` cannot be known at compilation time } fn main() { } "}
{"_id":"q-en-rust-35ebb959043a1df702c95597acf873c949122b97ee8b114652fd76c5e5e350f1","text":"AscribeUserTy, /// The data of a user variable, for debug info. VarDebugInfo, /// PlaceMention statement. PlaceMention, } #[derive(Copy, Clone, Debug, PartialEq, Eq)]"}
{"_id":"q-en-rust-35f26f6c70075da353f91a6dc5159e024ba2dba8062dc5b2715abc149b048d30","text":"let node_id = scope.node_id(self.tcx, &self.region_scope_tree); match self.tcx.hir.find(node_id) { Some(hir_map::NodeStmt(_)) => { db.note(\"consider using a `let` binding to increase its lifetime\"); if *sub_scope != ty::ReStatic { db.note(\"consider using a `let` binding to increase its lifetime\"); } } _ => {} }"}
{"_id":"q-en-rust-3649528ba598b8a6e72900bdf35539f64d05e0caefdc9503310d3b63a77d1413","text":" error[E0596]: cannot borrow immutable `Box` content `*x` as mutable --> $DIR/issue-36400.rs:15:12 | 14 | let x = Box::new(3); | - consider changing this to `mut x` 15 | f(&mut *x); | ^^ cannot borrow as mutable error: aborting due to previous error "}
{"_id":"q-en-rust-3682b6ee88f5c7a3bca30b48d47a21cc26e9b44f8ba19876d34432f4a212a41d","text":"[[package]] name = \"ar_archive_writer\" version = \"0.4.0\" version = \"0.4.2\" source = \"registry+https://github.com/rust-lang/crates.io-index\" checksum = \"de11a9d32db3327f981143bdf699ade4d637c6887b13b97e6e91a9154666963c\" checksum = \"01667f6f40216b9a0b2945e05fed5f1ad0ab6470e69cb9378001e37b1c0668e4\" dependencies = [ \"object 0.36.2\", ]"}
{"_id":"q-en-rust-36e124e3f02bec6f5dc8d47d7666f21b90483c5d8afdba78c68a66cead465744","text":"if let (Some(fmt_str), expr) = self.check_tts(cx, &mac.args.inner_tokens(), true) { if fmt_str.symbol == Symbol::intern(\"\") { let mut applicability = Applicability::MachineApplicable; let suggestion = if let Some(e) = expr { snippet_with_applicability(cx, e.span, \"v\", &mut applicability) } else { applicability = Applicability::HasPlaceholders; Cow::Borrowed(\"v\") let suggestion = match expr { Some(expr) => snippet_with_applicability(cx, expr.span, \"v\", &mut applicability), None => { applicability = Applicability::HasPlaceholders; Cow::Borrowed(\"v\") }, }; span_lint_and_sugg("}
{"_id":"q-en-rust-36f9325d69fd64e6dc9c2f2f927259746c874cd36210f4b1f948d0571580aee2","text":"fBopt-levelfR=fIVALfR Optimize with possible levels 0[en]3 .SH ENVIRONMENT VARIABLES Some of these affect the output of the compiler, while others affect programs which link to the standard library. .TP fBRUST_TEST_THREADSfR The test framework Rust provides executes tests in parallel. This variable sets the maximum number of threads used for this purpose. .TP fBRUST_TEST_NOCAPTUREfR A synonym for the --nocapture flag. .TP fBRUST_MIN_STACKfR Sets the minimum stack size for new threads. .TP fBRUST_BACKTRACEfR If set, produces a backtrace in the output of a program which panics. .SH \"EXAMPLES\" To build an executable from a source file with a main function: $ rustc -o hello hello.rs"}
{"_id":"q-en-rust-3703476de2a433b067e9e5d1340076399cc6db1956fd8bb1793504d4804eda43","text":"self.tcx.struct_span_lint_hir( lint::builtin::RUST_2021_INCOMPATIBLE_CLOSURE_CAPTURES, closure_hir_id, closure_head_span, closure_head_span, |lint| { let mut diagnostics_builder = lint.build( format!("}
{"_id":"q-en-rust-374f7e4ded3dfde98cc0d22bfcf2f3d97ea5bcd65c41685fda3b78dc9021f1cd","text":" Subproject commit 5399a24c66cb6164cf32280e7d300488c90d5765 Subproject commit b31c30a9bb4dbbd13c359d0e2bea7f65d20adf3f "}
{"_id":"q-en-rust-3755f3304f4532c8a77407e85c1454024a8458be170ff5343a14cf323954a73c","text":" #![feature(unboxed_closures)] #![feature(fn_traits)] fn main() { let handlers: Option FnMut<&'a mut (), Output=()>>> = None; handlers.unwrap().as_mut().call_mut(&mut ()); //~ ERROR: `&mut ()` is not a tuple } "}
{"_id":"q-en-rust-375dff0c7ed4845ee310ca8a172e319c6814830cdf76b816944c66f83e16192c","text":"#[cfg(test)] mod tests; #[doc(no_inline)] pub use hir::*; pub use hir_id::*; pub use lang_items::{LangItem, LanguageItems};"}
{"_id":"q-en-rust-378cdea484745759f3db7e8a10f32572d4fb2a7bd19cf594b90fbd480ddeae15","text":"src = t!(fs::canonicalize(src)); } else { let link = t!(fs::read_link(src)); t!(self.symlink_file(link, dst)); t!(self.config.symlink_file(link, dst)); return; } }"}
{"_id":"q-en-rust-37a55016b058c0271a10130298bf40bb94ceafb5ec74320883c4f0c5fd45a04d","text":" // Regression test for #100143 use std::iter::Peekable; pub struct Span { inner: Peekable>, } pub struct ConditionalIterator { f: F, } // @has 'fn_bound/struct.ConditionalIterator.html' '//h3[@class=\"code-header in-band\"]' 'impl Iterator for ConditionalIterator' impl Iterator for ConditionalIterator { type Item = (); fn next(&mut self) -> Option { todo!() } } "}
{"_id":"q-en-rust-37c7bf3f65929fdbbb00da2b40e29c800797449881eb623beb4e79da85d5b5b4","text":"// Types of fields (other than the last) in a struct must be sized. FieldSized, // Only Sized types can be made into objects ObjectSized, } pub type Obligations<'tcx> = subst::VecPerParamSpace>;"}
{"_id":"q-en-rust-37ce7a5cded8fa1a83cbaa541efa180fd2ca6d01ced7f3cf0d14b251e0fa7ab9","text":"pub fn read_line(&self, buf: &mut String) -> io::Result { self.lock().read_line(buf) } // Locks this handle with any lifetime. This depends on the // implementation detail that the underlying `Mutex` is static. fn lock_any<'a>(&self) -> StdinLock<'a> { StdinLock { inner: self.inner.lock().unwrap_or_else(|e| e.into_inner()) } } /// Consumes this handle to the standard input stream, locking the /// shared global buffer associated with the stream and returning a /// readable guard. /// /// The lock is released when the returned guard goes out of scope. The /// returned guard also implements the [`Read`] and [`BufRead`] traits /// for accessing the underlying data. /// /// It is often simpler to directly get a locked handle using the /// [`stdin_locked`] function instead, unless nearby code also needs to /// use an unlocked handle. /// /// # Examples /// /// ```no_run /// #![feature(stdio_locked)] /// use std::io::{self, Read}; /// /// fn main() -> io::Result<()> { /// let mut buffer = String::new(); /// let mut handle = io::stdin().into_locked(); /// /// handle.read_to_string(&mut buffer)?; /// Ok(()) /// } /// ``` #[unstable(feature = \"stdio_locked\", issue = \"none\")] pub fn into_locked(self) -> StdinLock<'static> { self.lock_any() } } #[stable(feature = \"std_debug\", since = \"1.16.0\")]"}
{"_id":"q-en-rust-37e07c6e8ec8b3e9489a0efd45b79b2e543e2644c2a6049f817c05ea0d8f9f34","text":" error[E0310]: the associated type `<&'a V as IntoIterator>::Item` may not live long enough --> $DIR/issue-71546.rs:12:27 | LL | let csv_str: String = value | ___________________________^ LL | | .into_iter() LL | | .map(|elem| elem.to_string()) | |_____________________________________^ | = help: consider adding an explicit lifetime bound `<&'a V as IntoIterator>::Item: 'static`... = note: ...so that the type `<&'a V as IntoIterator>::Item` will meet its required lifetime bounds... note: ...that is required by this bound --> $DIR/issue-71546.rs:10:55 | LL | for<'a> <&'a V as IntoIterator>::Item: ToString + 'static, | ^^^^^^^ error: aborting due to previous error For more information about this error, try `rustc --explain E0310`. "}
{"_id":"q-en-rust-37ef005a0d5e1ff2b5fd6b0287bd243ab156c4c8c78eeab282ac933d977dfd25","text":"#![feature(cfg_target_has_atomic)] #![feature(cfg_target_thread_local)] #![feature(char_error_internals)] #![feature(char_internals)] #![feature(clamp)] #![feature(concat_idents)] #![feature(const_cstr_unchecked)]"}
{"_id":"q-en-rust-381c86e22eede4c19910636a9560f397ec9c98b858eec22247df5ff4d3b74f0e","text":"), .. }) => { let hir::Ty { span, .. } = inputs[local.index() - 1]; let hir::Ty { span, .. } = *inputs.get(local.index() - 1)?; Some(span) } _ => None,"}
{"_id":"q-en-rust-3840dfcbc5ee1e4419c0e365cfc855000516ff5815884d1eb3f2abf7697d9df8","text":"true } // Suggest to change `Option<&Vec>::unwrap_or(&[])` to `Option::map_or(&[], |v| v)`. #[instrument(level = \"trace\", skip(self, err, provided_expr))] pub(crate) fn suggest_deref_unwrap_or( &self, err: &mut Diag<'_>, error_span: Span, callee_ty: Option>, call_ident: Option, expected_ty: Ty<'tcx>, provided_ty: Ty<'tcx>, provided_expr: &Expr<'tcx>, is_method: bool, ) { if !is_method { return; } let Some(callee_ty) = callee_ty else { return; }; let ty::Adt(callee_adt, _) = callee_ty.peel_refs().kind() else { return; }; let adt_name = if self.tcx.is_diagnostic_item(sym::Option, callee_adt.did()) { \"Option\" } else if self.tcx.is_diagnostic_item(sym::Result, callee_adt.did()) { \"Result\" } else { return; }; let Some(call_ident) = call_ident else { return; }; if call_ident.name != sym::unwrap_or { return; } let ty::Ref(_, peeled, _mutability) = provided_ty.kind() else { return; }; // NOTE: Can we reuse `suggest_deref_or_ref`? // Create an dummy type `&[_]` so that both &[] and `&Vec` can coerce to it. let dummy_ty = if let ty::Array(elem_ty, size) = peeled.kind() && let ty::Infer(_) = elem_ty.kind() && size.try_eval_target_usize(self.tcx, self.param_env) == Some(0) { let slice = Ty::new_slice(self.tcx, *elem_ty); Ty::new_imm_ref(self.tcx, self.tcx.lifetimes.re_static, slice) } else { provided_ty }; if !self.can_coerce(expected_ty, dummy_ty) { return; } let msg = format!(\"use `{adt_name}::map_or` to deref inner value of `{adt_name}`\"); err.multipart_suggestion_verbose( msg, vec![ (call_ident.span, \"map_or\".to_owned()), (provided_expr.span.shrink_to_hi(), \", |v| v\".to_owned()), ], Applicability::MachineApplicable, ); } /// Suggest wrapping the block in square brackets instead of curly braces /// in case the block was mistaken array syntax, e.g. `{ 1 }` -> `[ 1 ]`. pub(crate) fn suggest_block_to_brackets("}
{"_id":"q-en-rust-38649e0aec17295d9e8e822f06c7ca6ab06291a13c4db93213eaea9030999d00","text":"/// ``` #[stable(feature = \"rust1\", since = \"1.0.0\")] pub fn lock(&self) -> StdinLock<'_> { StdinLock { inner: self.inner.lock().unwrap_or_else(|e| e.into_inner()) } self.lock_any() } /// Locks this handle and reads a line of input, appending it to the specified buffer."}
{"_id":"q-en-rust-38655975827e6779b36a5d46a21fa4555edcd7f0be4686e0f885b955afbe595b","text":"bug!(\"expected capture to be an upvar\"); }; assert!(child_capture.place.projections.len() >= parent_capture.place.projections.len()); parent_base.var_path.hir_id == child_base.var_path.hir_id && std::iter::zip(&child_capture.place.projections, &parent_capture.place.projections) .all(|(child, parent)| child.kind == parent.kind)"}
{"_id":"q-en-rust-38acc9426095ef138b47954ff1a2a1ee23e2ffc3f284a4507f849241171b2408","text":"span: Span, self_expr: &'tcx hir::Expr<'tcx>, call_expr: &'tcx hir::Expr<'tcx>, skip_record_for_diagnostics: bool, } impl<'a, 'tcx> Deref for ConfirmContext<'a, 'tcx> {"}
{"_id":"q-en-rust-38d022e19c6f1473fc7b8fd1bb90956b4fa6e32dae8394a1456d0ba32838b533","text":"rm_rf(&build.out.join(\"tmp\")); rm_rf(&build.out.join(\"dist\")); rm_rf(&build.out.join(\"bootstrap\")); rm_rf(&build.out.join(\"rustfmt.stamp\")); for host in &build.hosts { let entries = match build.out.join(host.triple).read_dir() {"}
{"_id":"q-en-rust-38d707cc27cfe5001b059dcafbd71979fa92b0c524183475f6f3df64ba576791","text":"#[rustc_builtin_macro] #[macro_export] #[rustc_diagnostic_item = \"assert_macro\"] #[allow_internal_unstable(panic_internals, edition_panic, generic_assert_internals)] #[allow_internal_unstable( core_intrinsics, panic_internals, edition_panic, generic_assert_internals )] macro_rules! assert { ($cond:expr $(,)?) => {{ /* compiler built-in */ }}; ($cond:expr, $($arg:tt)+) => {{ /* compiler built-in */ }};"}
{"_id":"q-en-rust-38ea093413814d3ccc8adcb42a471178c4d2cf80f290932216c9ced8333df094","text":"use syntax::visit; use syntax::visit::Visitor; // An error has already been reported to the user, so no need to continue checking. // Useful type to use with `Result<>` indicate that an error has already // been reported to the user, so no need to continue checking. #[deriving(Clone,Show)] pub struct ErrorReported;"}
{"_id":"q-en-rust-391bf7ffdd79953c8689f97e2982e1cf22e40c1b25d926e40535f8d1eb1d19f8","text":" Subproject commit 01c8b654f9a01371414d1fd69cba38b289510a9e Subproject commit 2b9078f4afae82f60c5ac0fdb4af42d269e2f2f3 "}
{"_id":"q-en-rust-3927c5d92901dbf1b2edff7220842e19bf3b79ff2a8b4d0f4557bfcaf555796a","text":"assert::>(); assert::>(); assert::>(); assert::>(); assert::<&AssertRecoverSafe>(); assert::>>(); assert::>>(); } }"}
{"_id":"q-en-rust-3937befccddb58fa4371176614abea8e7a98d3b3e724af484a168849f34a4552","text":"rc::Rc, }; use std::time::Duration; //~^ ERROR expected item, found `require` use std::time::Instant; //~^ ERROR expected item, found `include` pub use std::io; //~^ ERROR expected item, found `using` fn main() { let x = Rc::new(1); let _ = write!(io::stdout(), \"{:?}\", x); let _ = Duration::new(5, 0); let _ = Instant::now(); }"}
{"_id":"q-en-rust-39565ca976f806c69887d6f3d87a9c6020c82eaf6ee3bfada3837329bb8246de","text":"See the specification for the [GitHub Tables extension][tables] for more details on the exact syntax supported. ### Task lists Task lists can be used as a checklist of items that have been completed. Example: ```md - [x] Complete task - [ ] IncComplete task ``` This will render as
\"; var search = getSearchElement(); search.innerHTML = output; showSearchResults(search); var tds = search.getElementsByTagName(\"td\");"}
{"_id":"q-en-rust-3c0ec9f8f159d529f9e284edf7da506df923395f2b0be7aa7ae3704bc8f41b48","text":"use std::rc::Rc; use std::{i8, i16, i32, i64}; use syntax::abi::{X86, X86_64, Arm, Mips, Mipsel, Rust, RustCall}; use syntax::abi::{RustIntrinsic, Abi}; use syntax::abi::{RustIntrinsic, Abi, OsWindows}; use syntax::ast_util::{local_def, is_local}; use syntax::attr::AttrMetaMethods; use syntax::attr;"}
{"_id":"q-en-rust-3c2a07a887b78150e77ed30e87d9ec8676afa8f15c9fc36324cec2a5f66a1581","text":" //! Regression test for #![feature(no_core)] #![no_core] #![crate_name = \"export_extern_crate_as_self\"] // ignore-tidy-linelength // @is export_extern_crate_as_self.json \"$.index[*][?(@.kind=='module')].name\" \"export_extern_crate_as_self\" pub extern crate self as export_extern_crate_as_self; // Must be the same name as the crate already has "}
{"_id":"q-en-rust-3c2e6e20ac2c33f651dedcc82cbb0a4b261ea8422447ecda6ad11b0427d48f32","text":" An inherent `impl` was written on a dyn auto trait. Erroneous code example: ```compile_fail,E0785 #![feature(auto_traits)] auto trait AutoTrait {} impl dyn AutoTrait {} ``` Dyn objects allow any number of auto traits, plus at most one non-auto trait. The non-auto trait becomes the \"principal trait\". When checking if an impl on a dyn trait is coherent, the principal trait is normally the only one considered. Since the erroneous code has no principal trait, it cannot be implemented at all. Working example: ``` #![feature(auto_traits)] trait PrincipalTrait {} auto trait AutoTrait {} impl dyn PrincipalTrait + AutoTrait + Send {} ``` "}
{"_id":"q-en-rust-3c4637964e266535b4a68d554b201b5b72f18828eb09fc30bd7ba37110705045","text":"match context { PlaceContext::MutatingUse(_) => ty::Invariant, PlaceContext::NonUse(StorageDead | StorageLive | PlaceMention | VarDebugInfo) => { ty::Invariant } PlaceContext::NonUse(StorageDead | StorageLive | VarDebugInfo) => ty::Invariant, PlaceContext::NonMutatingUse( Inspect | Copy | Move | SharedBorrow | ShallowBorrow | UniqueBorrow | AddressOf | Projection, Inspect | Copy | Move | PlaceMention | SharedBorrow | ShallowBorrow | UniqueBorrow | AddressOf | Projection, ) => ty::Covariant, PlaceContext::NonUse(AscribeUserTy) => ty::Covariant, }"}
{"_id":"q-en-rust-3c4aa2bcc0f77b295fcfd52c2c7981bb97a505650564d31e2245293f3e412a46","text":" // Copyright 2017 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 or the MIT license // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. pub struct X([u8]); pub static Y: &'static X = { const Y: &'static [u8] = b\"\"; &X(*Y) //~^ ERROR cannot move out //~^^ ERROR cannot move a //~^^^ ERROR cannot move a }; fn main() {} "}
{"_id":"q-en-rust-3c635f7cda8927744817a50f9b0c989213ad3ae14864b6c4a80fef0b9db48d85","text":"// take the \"else\" branch if self.option_loud_drop(6).is_some() // 2 && self.option_loud_drop(5).is_some() // 1 && let None = self.option_loud_drop(7) { // 3 && let None = self.option_loud_drop(8) { // 4 unreachable!(); } else { self.print(8); // 4 self.print(7); // 3 } // let exprs interspersed"}
{"_id":"q-en-rust-3c67f3d8a82571a493ab36d4fa849a23734985131cb4ed05fce9a11d9801d60c","text":" // This code (probably) _should_ compile, but it currently does not because we // are not smart enough about implied bounds. use std::io; fn real_dispatch(f: F) -> Result<(), io::Error> //~^ NOTE required by a bound in this where F: FnOnce(&mut UIView) -> Result<(), io::Error> + Send + 'static, //~^ NOTE required by this bound in `real_dispatch` //~| NOTE required by a bound in `real_dispatch` { todo!() } #[derive(Debug)] struct UIView<'a, T: 'a> { _phantom: std::marker::PhantomData<&'a mut T>, } trait Handle<'a, T: 'a, V, R> { fn dispatch(&self, f: F) -> Result<(), io::Error> where F: FnOnce(&mut V) -> R + Send + 'static; } #[derive(Debug, Clone)] struct TUIHandle { _phantom: std::marker::PhantomData, } impl<'a, T: 'a> Handle<'a, T, UIView<'a, T>, Result<(), io::Error>> for TUIHandle { fn dispatch(&self, f: F) -> Result<(), io::Error> where F: FnOnce(&mut UIView<'a, T>) -> Result<(), io::Error> + Send + 'static, { real_dispatch(f) //~^ ERROR expected a `FnOnce<(&mut UIView<'_, T>,)>` closure, found `F` //~| NOTE expected an `FnOnce<(&mut UIView<'_, T>,)>` closure, found `F` //~| NOTE expected a closure with arguments //~| NOTE required by a bound introduced by this call } } fn main() {} "}
{"_id":"q-en-rust-3c9e7c40229cbb08f05d3abfdfe6f77e55c887ac5591aeda4cbb8444a0a222de","text":"/// Parse a `mod { ... }` or `mod ;` item fn parse_item_mod(&mut self, outer_attrs: &[Attribute]) -> PResult<'a, ItemInfo> { let outer_attrs = ::config::StripUnconfigured { config: &self.cfg, sess: self.sess, should_test: false, // irrelevant features: None, // don't perform gated feature checking }.process_cfg_attrs(outer_attrs.to_owned()); let (in_cfg, outer_attrs) = { let mut strip_unconfigured = ::config::StripUnconfigured { config: &self.cfg, sess: self.sess, should_test: false, // irrelevant features: None, // don't perform gated feature checking }; let outer_attrs = strip_unconfigured.process_cfg_attrs(outer_attrs.to_owned()); (strip_unconfigured.in_cfg(&outer_attrs), outer_attrs) }; let id_span = self.span; let id = self.parse_ident()?; if self.check(&token::Semi) { self.bump(); // This mod is in an external file. Let's go get it! let (m, attrs) = self.eval_src_mod(id, &outer_attrs, id_span)?; Ok((id, m, Some(attrs))) if in_cfg { // This mod is in an external file. Let's go get it! let (m, attrs) = self.eval_src_mod(id, &outer_attrs, id_span)?; Ok((id, m, Some(attrs))) } else { let placeholder = ast::Mod { inner: syntax_pos::DUMMY_SP, items: Vec::new() }; Ok((id, ItemKind::Mod(placeholder), None)) } } else { let directory = self.directory.clone(); self.push_directory(id, &outer_attrs);"}
{"_id":"q-en-rust-3cad91aecd4e16bc0bb4538bf9a7ff58711f49cbee591fbcdc318d148de348a8","text":"} function showResults(results) { if (results.others.length === 1 && getCurrentValue(\"rustdoc-go-to-only-result\") === \"true\") { var search = getSearchElement(); if (results.others.length === 1 && getCurrentValue(\"rustdoc-go-to-only-result\") === \"true\" // By default, the search DOM element is \"empty\" (meaning it has no children not // text content). Once a search has been run, it won't be empty, even if you press // ESC or empty the search input (which also \"cancels\" the search). && (!search.firstChild || search.firstChild.innerText !== getSearchLoadingText())) { var elem = document.createElement(\"a\"); elem.href = results.others[0].href; elem.style.display = \"none\"; // For firefox, we need the element to be in the DOM so it can be clicked. document.body.appendChild(elem); elem.click(); return; } var query = getQuery(search_input.value);"}
{"_id":"q-en-rust-3ccaab2ef4b88e33980298293a34d1b040802d03268593f97983389147e1b0d2","text":"impl Encodable for Span { fn encode(&self, s: &mut S) -> Result<(), S::Error> { try!(s.emit_u32(self.lo.0)); s.emit_u32(self.hi.0) s.emit_struct(\"Span\", 2, |s| { try!(s.emit_struct_field(\"lo\", 0, |s| { self.lo.encode(s) })); s.emit_struct_field(\"hi\", 1, |s| { self.hi.encode(s) }) }) } } impl Decodable for Span { fn decode(d: &mut D) -> Result { let lo = BytePos(try! { d.read_u32() }); let hi = BytePos(try! { d.read_u32() }); Ok(mk_sp(lo, hi)) d.read_struct(\"Span\", 2, |d| { let lo = try!(d.read_struct_field(\"lo\", 0, |d| { BytePos::decode(d) })); let hi = try!(d.read_struct_field(\"hi\", 1, |d| { BytePos::decode(d) })); Ok(mk_sp(lo, hi)) }) } }"}
{"_id":"q-en-rust-3ce3565dc94075dd25406b13013454791752addc274f11a27fc00f7193a1b264","text":"self.r .session .struct_span_warn(item.span, \"`$crate` may not be imported\") .note( \"`use $crate;` was erroneously allowed and will become a hard error in a future release\", ) .struct_span_err(item.span, \"`$crate` may not be imported\") .emit(); } }"}
{"_id":"q-en-rust-3d34218f53f4568aaa5171d48936b3d2397882883114659a18c1397c45a6bd3a","text":"pub(crate) fn unsafety(&self, tcx: TyCtxt<'_>) -> hir::Unsafety { tcx.trait_def(self.def_id).unsafety } pub(crate) fn is_object_safe(&self, tcx: TyCtxt<'_>) -> bool { tcx.check_is_object_safe(self.def_id) } } #[derive(Clone, Debug)]"}
{"_id":"q-en-rust-3d58f75c42cf639e7111c39af8eab1576b11b115c6a23420aee2d2b54a25eab5","text":"val.into() } Aggregate(ref kind, ref fields) => Value::Aggregate { fields: fields .iter() .map(|field| self.eval_operand(field).map_or(Value::Uninit, Value::Immediate)) .collect(), variant: match **kind { AggregateKind::Adt(_, variant, _, _, _) => variant, AggregateKind::Array(_) | AggregateKind::Tuple | AggregateKind::Closure(_, _) | AggregateKind::Coroutine(_, _) | AggregateKind::CoroutineClosure(_, _) => VariantIdx::new(0), }, }, Aggregate(ref kind, ref fields) => { // Do not const pop union fields as they can be // made to produce values that don't match their // underlying layout's type (see ICE #121534). // If the last element of the `Adt` tuple // is `Some` it indicates the ADT is a union if let AggregateKind::Adt(_, _, _, _, Some(_)) = **kind { return None; }; Value::Aggregate { fields: fields .iter() .map(|field| { self.eval_operand(field).map_or(Value::Uninit, Value::Immediate) }) .collect(), variant: match **kind { AggregateKind::Adt(_, variant, _, _, _) => variant, AggregateKind::Array(_) | AggregateKind::Tuple | AggregateKind::Closure(_, _) | AggregateKind::Coroutine(_, _) | AggregateKind::CoroutineClosure(_, _) => VariantIdx::new(0), }, } } Repeat(ref op, n) => { trace!(?op, ?n);"}
{"_id":"q-en-rust-3d651afbd895ffa4b4c367de0760227a7166689f3d23a312d9ddd7006df90de9","text":"Some(x) => x, }; if local_tmp_s0 != local_tmp_s1 // The field-and-variant information match up. || vf_s0 != vf_s1 // Source and target locals have the same type. // FIXME(Centril | oli-obk): possibly relax to same layout? || local_decls[local_0].ty != local_decls[local_1].ty // We're setting the discriminant of `local_0` to this variant. || Some((local_0, vf_s0.var_idx)) != match_set_discr(s2) { continue;"}
{"_id":"q-en-rust-3d7a462c364e8519fb0d9d19c83c3c3e8e9749ebf929ac56abae8fcdebaed149","text":"req_introduces_loc: subdiag, has_lifetime: sup_r.has_name(), lifetime: sup_r.to_string(), lifetime: lifetime_name.clone(), has_param_name: simple_ident.is_some(), param_name: simple_ident.map(|x| x.to_string()).unwrap_or_default(), spans_empty, bound, };"}
{"_id":"q-en-rust-3da4ee4949f8586c82eec9279e4f211919b959c151c92fd2be5c098401363c3d","text":"pub use self::scoped_tls::ScopedKey; #[doc(hidden)] pub use self::local::__KeyInner as __LocalKeyInner; #[doc(hidden)] pub use self::scoped_tls::__KeyInner as __ScopedKeyInner; //////////////////////////////////////////////////////////////////////////////// // Builder"}
{"_id":"q-en-rust-3e1d92c8ffc40aa82d752a257b29ea2abfe0bcdf3bad19633b08b741135b7677","text":" // run-rustfix // Regression test for #54505 - range borrowing suggestion had // incorrect syntax (missing parentheses). use std::ops::RangeBounds; // take a reference to any built-in range fn take_range(_r: &impl RangeBounds) {} fn main() { take_range(0..1); //~^ ERROR mismatched types [E0308] //~| HELP consider borrowing here //~| SUGGESTION &(0..1) take_range(1..); //~^ ERROR mismatched types [E0308] //~| HELP consider borrowing here //~| SUGGESTION &(1..) take_range(..); //~^ ERROR mismatched types [E0308] //~| HELP consider borrowing here //~| SUGGESTION &(..) take_range(0..=1); //~^ ERROR mismatched types [E0308] //~| HELP consider borrowing here //~| SUGGESTION &(0..=1) take_range(..5); //~^ ERROR mismatched types [E0308] //~| HELP consider borrowing here //~| SUGGESTION &(..5) take_range(..=42); //~^ ERROR mismatched types [E0308] //~| HELP consider borrowing here //~| SUGGESTION &(..=42) } "}
{"_id":"q-en-rust-3e2869a84f816d2ea3d9f1fd21a5cea1a75641aad366b5dcc17f6109e8aef1cd","text":" // Verify that lifetime resolution correctly accounts for `Fn` bare trait objects. // check-pass #![allow(bare_trait_objects)] // This should work as: fn next_u32(fill_buf: &mut dyn FnMut(&mut [u8])) fn next_u32(fill_buf: &mut FnMut(&mut [u8])) { let mut buf: [u8; 4] = [0; 4]; fill_buf(&mut buf); } fn explicit(fill_buf: &mut dyn FnMut(&mut [u8])) { let mut buf: [u8; 4] = [0; 4]; fill_buf(&mut buf); } fn main() { let _: fn(&mut FnMut(&mut [u8])) = next_u32; let _: &dyn Fn(&mut FnMut(&mut [u8])) = &next_u32; let _: fn(&mut FnMut(&mut [u8])) = explicit; let _: &dyn Fn(&mut FnMut(&mut [u8])) = &explicit; let _: fn(&mut dyn FnMut(&mut [u8])) = next_u32; let _: &dyn Fn(&mut dyn FnMut(&mut [u8])) = &next_u32; let _: fn(&mut dyn FnMut(&mut [u8])) = explicit; let _: &dyn Fn(&mut dyn FnMut(&mut [u8])) = &explicit; } "}
{"_id":"q-en-rust-3e622b64796f2df9438daa5085efd645455088db88cf66cc380d6967de259bb0","text":"// components like the llvm tools and LLD. LLD is included below and // tools/LLDB come later, so let's just throw it in the rustc // component for now. maybe_install_llvm_dylib(builder, host, image); maybe_install_llvm_runtime(builder, host, image); // Copy over lld if it's there if builder.config.lld_enabled {"}
{"_id":"q-en-rust-3ecc911466585e00e2f74f598c05e59e65995d63ca5ca849817d23323b7ffd07","text":" error: `impl Trait` can only mention lifetimes bound at the fn or impl level error: `impl Trait` can only mention lifetimes from an fn or impl --> $DIR/universal_wrong_hrtb.rs:5:73 | LL | fn test_argument_position(x: impl for<'a> Trait<'a, Assoc = impl Copy + 'a>) {} | ^^ | note: lifetime declared here --> $DIR/universal_wrong_hrtb.rs:5:39 | LL | fn test_argument_position(x: impl for<'a> Trait<'a, Assoc = impl Copy + 'a>) {} | ^^ | -- lifetime declared here ^^ error: aborting due to previous error"}
{"_id":"q-en-rust-3ed4ca481a56e699b3fe64de75cf3d2b4fe2bac050fc432135ee4f9bab5b0776","text":"echo '{\"ipv6\":true,\"fixed-cidr-v6\":\"fd9a:8454:6789:13f7::/64\"}' | sudo tee /etc/docker/daemon.json sudo service docker restart displayName: Enable IPv6 condition: and(succeeded(), eq(variables['Agent.OS'], 'Linux')) condition: and(succeeded(), not(variables.SKIP_JOB), eq(variables['Agent.OS'], 'Linux')) # Check out all our submodules, but more quickly than using git by using one of # our custom scripts"}
{"_id":"q-en-rust-3ef4c0e38067e2aef641bf113e317d72efecdb738c14237cc1cc0cbff2b6ab60","text":"cx: &MatchCheckCtxt<'p, 'tcx>, column: &[&DeconstructedPat<'p, 'tcx>], ) -> Vec> { if column.is_empty() { return Vec::new(); } let ty = column[0].ty(); let pcx = &PatCtxt { cx, ty, span: DUMMY_SP, is_top_level: false };"}
{"_id":"q-en-rust-3f0e9a6d5393396ee4158df3114ab8e5fc4930bd56ae8c99188f57577e0c3931","text":"// We use the *previous* span because if the type is known *here* it means // it was *evaluated earlier*. We don't do this for method calls because we // evaluate the method's self type eagerly, but not in any other case. err.span_label( span, with_forced_trimmed_paths!(format!( \"here the type of `{ident}` is inferred to be `{ty}`\", )), ); if !span.overlaps(mismatch_span) { err.span_label( span, with_forced_trimmed_paths!(format!( \"here the type of `{ident}` is inferred to be `{ty}`\", )), ); } break; } prev = ty;"}
{"_id":"q-en-rust-3f2189e4afc63123acc822b72535fa9f141271f8fb7194fc4be8e17ffcc82fa3","text":"} 0 => {} _ => { // linux returns POLLOUT|POLLERR|POLLHUP for refused connections (!), so look // for POLLHUP rather than read readiness if pollfd.revents & libc::POLLHUP != 0 { let e = self.take_error()?.unwrap_or_else(|| { io::const_io_error!( io::ErrorKind::Uncategorized, \"no error set after POLLHUP\", ) }); return Err(e); if cfg!(target_os = \"vxworks\") { // VxWorks poll does not return POLLHUP or POLLERR in revents. Check if the // connnection actually succeeded and return ok only when the socket is // ready and no errors were found. if let Some(e) = self.take_error()? { return Err(e); } } else { // linux returns POLLOUT|POLLERR|POLLHUP for refused connections (!), so look // for POLLHUP or POLLERR rather than read readiness if pollfd.revents & (libc::POLLHUP | libc::POLLERR) != 0 { let e = self.take_error()?.unwrap_or_else(|| { io::const_io_error!( io::ErrorKind::Uncategorized, \"no error set after POLLHUP\", ) }); return Err(e); } } return Ok(());"}
{"_id":"q-en-rust-3f371092a5563ab1f1ce31b708d09768f114e2d7c87282a56fedfad0a86fdf50","text":"impl<'tcx> MirPass<'tcx> for SimplifyArmIdentity { fn run_pass(&self, _: TyCtxt<'tcx>, _: MirSource<'tcx>, body: &mut Body<'tcx>) { for bb in body.basic_blocks_mut() { let (basic_blocks, local_decls) = body.basic_blocks_and_local_decls_mut(); for bb in basic_blocks { // Need 3 statements: let (s0, s1, s2) = match &mut *bb.statements { [s0, s1, s2] => (s0, s1, s2),"}
{"_id":"q-en-rust-3f5fed3ca494f56c57922995e36653ccb585fde7dffd940f5b85ad6caacc73df","text":"loop { let tree = iter.stack.pop().or_else(|| { let next = iter.cursor.next_with_joint()?; let lookahead = iter.cursor.look_ahead(0); Some(TokenTree::from_internal((next, lookahead, self.sess, &mut iter.stack))) Some(TokenTree::from_internal((next, self.sess, &mut iter.stack))) })?; // A hack used to pass AST fragments to attribute and derive macros // as a single nonterminal token instead of a token stream."}
{"_id":"q-en-rust-3f694d36853a102dc2ba7648d051647fc3daac7d90584ec4b80653a294aef9f3","text":"#[license = \"MIT/ASL2\"]; #[crate_type = \"rlib\"]; #[crate_type = \"dylib\"]; #[doc(html_logo_url = \"http://www.rust-lang.org/logos/rust-logo-128x128-blk.png\", #[doc(html_logo_url = \"http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png\", html_favicon_url = \"http://www.rust-lang.org/favicon.ico\", html_root_url = \"http://static.rust-lang.org/doc/master\")];"}
{"_id":"q-en-rust-3fdee19ac9208241370e709a476c18e58d68594e3df1e634e36c506d818e7756","text":"optopt(\"\", \"host\", \"the host to build for\", \"HOST\"), optopt(\"\", \"gdb-version\", \"the version of GDB used\", \"VERSION STRING\"), optopt(\"\", \"lldb-version\", \"the version of LLDB used\", \"VERSION STRING\"), optopt(\"\", \"llvm-version\", \"the version of LLVM used\", \"VERSION STRING\"), optopt(\"\", \"android-cross-path\", \"Android NDK standalone path\", \"PATH\"), optopt(\"\", \"adb-path\", \"path to the android debugger\", \"PATH\"), optopt(\"\", \"adb-test-dir\", \"path to tests for the android debugger\", \"PATH\"),"}
{"_id":"q-en-rust-3ff26bdd798062f08cd4b9059753cd03abd3ccd65e61b01847fc159fd60806b4","text":"'{' => { let curr_last_brace = self.last_opening_brace; let byte_pos = self.to_span_index(pos); let lbrace_end = InnerOffset(byte_pos.0 + 1); let lbrace_end = self.to_span_index(pos + 1); self.last_opening_brace = Some(byte_pos.to(lbrace_end)); self.cur.next(); if self.consume('{') {"}
{"_id":"q-en-rust-3fff1a5a87e1d25d5bb2b8e788aa4a3fea18ff9c258bdfa1763e89d8bc45f626","text":"} #[stable(feature = \"rust1\", since = \"1.0.0\")] impl Read for File { impl Read for &File { fn read(&mut self, buf: &mut [u8]) -> io::Result { self.inner.read(buf) }"}
{"_id":"q-en-rust-40270ec2a030828a0f18fc0ca5c6822e18741ec5304d9b51ba1599fdb53445b8","text":" //@ run-rustfix // Check the `unused_parens` suggestion for paren_expr with attributes. // The suggestion should retain attributes in the front. #![feature(stmt_expr_attributes)] #![deny(unused_parens)] pub fn foo() -> impl Fn() { let _ = (#[inline] #[allow(dead_code)] || println!(\"Hello!\")); //~ERROR unnecessary parentheses (#[inline] #[allow(dead_code)] || println!(\"Hello!\")) //~ERROR unnecessary parentheses } fn main() { let _ = foo(); } "}
{"_id":"q-en-rust-4046c081ea22421fed505940fd3e4a6b13fa2c26aec9cf7803b4a970d9049f4e","text":"lt_op: |_| self.tcx.lifetimes.re_erased, ct_op: |c| c, ty_op: |t| match *t.kind() { ty::Infer(ty::TyVar(vid)) => self.tcx.mk_ty_infer(ty::TyVar(self.root_var(vid))), ty::Infer(ty::TyVar(_)) => self.tcx.mk_ty_var(ty::TyVid::from_u32(0)), ty::Infer(ty::IntVar(_)) => { self.tcx.mk_ty_infer(ty::IntVar(ty::IntVid { index: 0 })) }"}
{"_id":"q-en-rust-40d23a88bfac19015b570512fa64a89d4bcbf8d0021dbce3991f828d59bafffb","text":"fn report(&mut self, error: GroupedMoveError<'tcx>) { let (mut err, err_span) = { let (span, original_path, kind): (Span, &Place<'tcx>, &IllegalMoveOriginKind<'_>) = let (span, use_spans, original_path, kind,): ( Span, Option, &Place<'tcx>, &IllegalMoveOriginKind<'_>, ) = match error { GroupedMoveError::MovesFromPlace { span, ref original_path, ref kind, .. } | GroupedMoveError::MovesFromValue { span, ref original_path, ref kind, .. } => { (span, original_path, kind) (span, None, original_path, kind) } GroupedMoveError::OtherIllegalMove { use_spans, ref original_path, ref kind } => { (use_spans.args_or_use(), original_path, kind) (use_spans.args_or_use(), Some(use_spans), original_path, kind) }, }; debug!(\"report: original_path={:?} span={:?}, kind={:?} "}
{"_id":"q-en-rust-40d657760ff7ef31649bac6241e45094e51b2d1342ec07320bfbbabb74499699","text":"0, ); if result != stackaddr || result == MAP_FAILED { panic!(\"failed to allocate a guard page\"); panic!(\"failed to allocate a guard page: {}\", io::Error::last_os_error()); } let result = mprotect(stackaddr, page_size, PROT_NONE); if result != 0 { panic!(\"failed to protect the guard page\"); panic!(\"failed to protect the guard page: {}\", io::Error::last_os_error()); } let guardaddr = stackaddr as usize;"}
{"_id":"q-en-rust-412d7a59d478ac0ae1c22ef453aa06a8c8c9ab647fada861511be9b18bd08e64","text":"// no number between dots let none: Option = \"255.0..1\".parse().ok(); assert_eq!(None, none); // octal let none: Option = \"255.0.0.01\".parse().ok(); assert_eq!(None, none); // octal zero let none: Option = \"255.0.0.00\".parse().ok(); assert_eq!(None, none); let none: Option = \"255.0.00.0\".parse().ok(); assert_eq!(None, none); } #[test]"}
{"_id":"q-en-rust-41396f09f31ee4ad3b6759a18710504407a874f360bd9cb5cf912304b2bb9f20","text":"r: A+'static } fn new_struct(r: A+'static) -> Struct { fn new_struct(r: A+'static) -> Struct { //~^ ERROR the trait `core::kinds::Sized` is not implemented //~^ ERROR the trait `core::kinds::Sized` is not implemented Struct { r: r } //~^ ERROR the trait `core::kinds::Sized` is not implemented"}
{"_id":"q-en-rust-4139d2a522af7d6da54eba9c2b614589cc0e3471ee48200d5d069a0c7d75a6cf","text":" // Copyright 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 or the MIT license // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. struct GradFn usize>(F); fn main() { let GradFn(x_squared) : GradFn<_> = GradFn(|| -> usize { 2 }); let _ = x_squared(); } "}
{"_id":"q-en-rust-413d97e62737bc7760ae359e2838d8c16860946923624eb511028bcbde9b5c38","text":"return exports.iter().map(ToString::to_string).collect(); } let mut symbols = Vec::new(); if let CrateType::ProcMacro = crate_type { exported_symbols_for_proc_macro_crate(tcx) } else { exported_symbols_for_non_proc_macro(tcx, crate_type) } } fn exported_symbols_for_non_proc_macro(tcx: TyCtxt<'_>, crate_type: CrateType) -> Vec { let mut symbols = Vec::new(); let export_threshold = symbol_export::crates_export_threshold(&[crate_type]); for_each_exported_symbols_include_dep(tcx, crate_type, |symbol, info, cnum| { if info.level.is_below_threshold(export_threshold) {"}
{"_id":"q-en-rust-4145100ef47a2226af9a96f27f2b6b8ea22b57ec58f99012c5f105b59b01e533","text":"{ err.note(\"you may be trying to write a c-string literal\"); err.note(\"c-string literals require Rust 2021 or later\"); HelpUseLatestEdition::new().add_to_diagnostic(&mut err); err.subdiagnostic(self.dcx(), HelpUseLatestEdition::new()); } // `pub` may be used for an item or `pub(crate)`"}
{"_id":"q-en-rust-415d44ca465098ed89900c939017379e995c3b0ac7561538ee879a39bb1699f2","text":"); } else if matches!(span.desugaring_kind(), Some(DesugaringKind::ForLoop(_))) { let suggest = match self.infcx.tcx.get_diagnostic_item(sym::IntoIterator) { Some(def_id) => type_known_to_meet_bound_modulo_regions( &self.infcx, self.param_env, self.infcx.tcx.mk_imm_ref(self.infcx.tcx.lifetimes.re_erased, ty), def_id, DUMMY_SP, ), Some(def_id) => self.infcx.tcx.infer_ctxt().enter(|infcx| { type_known_to_meet_bound_modulo_regions( &infcx, self.param_env, infcx .tcx .mk_imm_ref(infcx.tcx.lifetimes.re_erased, infcx.tcx.erase_regions(ty)), def_id, DUMMY_SP, ) }), _ => false, }; if suggest {"}
{"_id":"q-en-rust-41676ff2faaadd10f46689cf19203ec9b27382ba6adcae49e46cbe92cdd40639","text":"symbols } fn exported_symbols_for_proc_macro_crate(tcx: TyCtxt<'_>) -> Vec { // `exported_symbols` will be empty when !should_codegen. if !tcx.sess.opts.output_types.should_codegen() { return Vec::new(); } let stable_crate_id = tcx.sess.local_stable_crate_id(); let proc_macro_decls_name = tcx.sess.generate_proc_macro_decls_symbol(stable_crate_id); let metadata_symbol_name = exported_symbols::metadata_symbol_name(tcx); vec![proc_macro_decls_name, metadata_symbol_name] } pub(crate) fn linked_symbols( tcx: TyCtxt<'_>, crate_type: CrateType,"}
{"_id":"q-en-rust-41b925b7a5e6a36ab25e29fdd5717a1273be81d8bf620d47a354ebdc24774a62","text":" error: lifetime may not live long enough --> $DIR/issue-54779-anon-static-lifetime.rs:34:24 | LL | cx: &dyn DebugContext, | - let's call the lifetime of this reference `'1` ... LL | bar.debug_with(cx); | ^^ cast requires that `'1` must outlive `'static` error: aborting due to previous error "}
{"_id":"q-en-rust-41d669167072ca0c51c9deced606ef1579a1ed87d798a3942ea57fb2085df1f3","text":" // 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 or the MIT license // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. // forbid-output: &mut mut self struct Struct; impl Struct { fn foo(&mut self) { (&mut self).bar(); //~^ ERROR cannot borrow immutable argument `self` as mutable // ... and no SUGGESTION that suggests `&mut mut self` } // In this case we could keep the suggestion, but to distinguish the // two cases is pretty hard. It's an obscure case anyway. fn bar(self: &mut Self) { (&mut self).bar(); //~^ ERROR cannot borrow immutable argument `self` as mutable } } fn main () {} "}
{"_id":"q-en-rust-41f5ec1ee96e019f47ca44ccd464b5624d9530dcfdc6badadbd085e5dcd3d1f2","text":".map_or(false, |output| output.status.success()) } fn ensure_stage1_toolchain_placeholder_exists(stage_path: &str) -> bool { let pathbuf = PathBuf::from(stage_path); if fs::create_dir_all(pathbuf.join(\"lib\")).is_err() { return false; }; let pathbuf = pathbuf.join(\"bin\"); if fs::create_dir_all(&pathbuf).is_err() { return false; }; let pathbuf = pathbuf.join(format!(\"rustc{}\", EXE_SUFFIX)); if pathbuf.exists() { return true; } // Take care not to overwrite the file let result = File::options().append(true).create(true).open(&pathbuf); if result.is_err() { return false; } return true; } // Used to get the path for `Subcommand::Setup` pub fn interactive_path() -> io::Result { fn abbrev_all() -> impl Iterator {"}
{"_id":"q-en-rust-4206ed09b1a782ddf0928c3fa34e1ec577a59c6331f3aa925706580411e48c22","text":"} } impl<'tcx> Debug for TerminatorKind<'tcx> { fn fmt(&self, fmt: &mut Formatter<'_>) -> fmt::Result { self.fmt_head(fmt)?; let successor_count = self.successors().count(); let labels = self.fmt_successor_labels(); assert_eq!(successor_count, labels.len()); match successor_count { 0 => Ok(()), 1 => write!(fmt, \" -> {:?}\", self.successors().next().unwrap()), _ => { write!(fmt, \" -> [\")?; for (i, target) in self.successors().enumerate() { if i > 0 { write!(fmt, \", \")?; } write!(fmt, \"{}: {:?}\", labels[i], target)?; } write!(fmt, \"]\") } } } } impl<'tcx> TerminatorKind<'tcx> { /// Writes the \"head\" part of the terminator; that is, its name and the data it uses to pick the /// successor basic block, if any. The only information not included is the list of possible /// successors, which may be rendered differently between the text and the graphviz format. pub fn fmt_head(&self, fmt: &mut W) -> fmt::Result { use self::TerminatorKind::*; match self { Goto { .. } => write!(fmt, \"goto\"), SwitchInt { discr, .. } => write!(fmt, \"switchInt({:?})\", discr), Return => write!(fmt, \"return\"), GeneratorDrop => write!(fmt, \"generator_drop\"), Resume => write!(fmt, \"resume\"), Abort => write!(fmt, \"abort\"), Yield { value, resume_arg, .. } => write!(fmt, \"{:?} = yield({:?})\", resume_arg, value), Unreachable => write!(fmt, \"unreachable\"), Drop { place, .. } => write!(fmt, \"drop({:?})\", place), DropAndReplace { place, value, .. } => { write!(fmt, \"replace({:?} <- {:?})\", place, value) } Call { func, args, destination, .. } => { if let Some((destination, _)) = destination { write!(fmt, \"{:?} = \", destination)?; } write!(fmt, \"{:?}(\", func)?; for (index, arg) in args.iter().enumerate() { if index > 0 { write!(fmt, \", \")?; } write!(fmt, \"{:?}\", arg)?; } write!(fmt, \")\") } Assert { cond, expected, msg, .. } => { write!(fmt, \"assert(\")?; if !expected { write!(fmt, \"!\")?; } write!(fmt, \"{:?}, \", cond)?; msg.fmt_assert_args(fmt)?; write!(fmt, \")\") } FalseEdge { .. } => write!(fmt, \"falseEdge\"), FalseUnwind { .. } => write!(fmt, \"falseUnwind\"), InlineAsm { template, ref operands, options, .. } => { write!(fmt, \"asm!(\"{}\"\", InlineAsmTemplatePiece::to_string(template))?; for op in operands { write!(fmt, \", \")?; let print_late = |&late| if late { \"late\" } else { \"\" }; match op { InlineAsmOperand::In { reg, value } => { write!(fmt, \"in({}) {:?}\", reg, value)?; } InlineAsmOperand::Out { reg, late, place: Some(place) } => { write!(fmt, \"{}out({}) {:?}\", print_late(late), reg, place)?; } InlineAsmOperand::Out { reg, late, place: None } => { write!(fmt, \"{}out({}) _\", print_late(late), reg)?; } InlineAsmOperand::InOut { reg, late, in_value, out_place: Some(out_place), } => { write!( fmt, \"in{}out({}) {:?} => {:?}\", print_late(late), reg, in_value, out_place )?; } InlineAsmOperand::InOut { reg, late, in_value, out_place: None } => { write!(fmt, \"in{}out({}) {:?} => _\", print_late(late), reg, in_value)?; } InlineAsmOperand::Const { value } => { write!(fmt, \"const {:?}\", value)?; } InlineAsmOperand::SymFn { value } => { write!(fmt, \"sym_fn {:?}\", value)?; } InlineAsmOperand::SymStatic { def_id } => { write!(fmt, \"sym_static {:?}\", def_id)?; } } } write!(fmt, \", options({:?}))\", options) } } } /// Returns the list of labels for the edges to the successor basic blocks. pub fn fmt_successor_labels(&self) -> Vec> { use self::TerminatorKind::*; match *self { Return | Resume | Abort | Unreachable | GeneratorDrop => vec![], Goto { .. } => vec![\"\".into()], SwitchInt { ref values, switch_ty, .. } => ty::tls::with(|tcx| { let param_env = ty::ParamEnv::empty(); let switch_ty = tcx.lift(&switch_ty).unwrap(); let size = tcx.layout_of(param_env.and(switch_ty)).unwrap().size; values .iter() .map(|&u| { ty::Const::from_scalar(tcx, Scalar::from_uint(u, size), switch_ty) .to_string() .into() }) .chain(iter::once(\"otherwise\".into())) .collect() }), Call { destination: Some(_), cleanup: Some(_), .. } => { vec![\"return\".into(), \"unwind\".into()] } Call { destination: Some(_), cleanup: None, .. } => vec![\"return\".into()], Call { destination: None, cleanup: Some(_), .. } => vec![\"unwind\".into()], Call { destination: None, cleanup: None, .. } => vec![], Yield { drop: Some(_), .. } => vec![\"resume\".into(), \"drop\".into()], Yield { drop: None, .. } => vec![\"resume\".into()], DropAndReplace { unwind: None, .. } | Drop { unwind: None, .. } => { vec![\"return\".into()] } DropAndReplace { unwind: Some(_), .. } | Drop { unwind: Some(_), .. } => { vec![\"return\".into(), \"unwind\".into()] } Assert { cleanup: None, .. } => vec![\"\".into()], Assert { .. } => vec![\"success\".into(), \"unwind\".into()], FalseEdge { .. } => vec![\"real\".into(), \"imaginary\".into()], FalseUnwind { unwind: Some(_), .. } => vec![\"real\".into(), \"cleanup\".into()], FalseUnwind { unwind: None, .. } => vec![\"real\".into()], InlineAsm { destination: Some(_), .. } => vec![\"\".into()], InlineAsm { destination: None, .. } => vec![], } } } /////////////////////////////////////////////////////////////////////////// // Statements"}
{"_id":"q-en-rust-4259335d70dc59775ed920b76dbcb64de0f70a8006dbfd47a99982c1812ba7ed","text":" #![deny(improper_ctypes_definitions)] #[repr(C)] pub struct Foo { a: u8, b: (), } extern \"C\" fn foo(x: Foo) -> Foo { todo!() } struct NotSafe(u32); #[repr(C)] pub struct Bar { a: u8, b: (), c: NotSafe, } extern \"C\" fn bar(x: Bar) -> Bar { //~^ ERROR `extern` fn uses type `NotSafe`, which is not FFI-safe //~^^ ERROR `extern` fn uses type `NotSafe`, which is not FFI-safe todo!() } fn main() {} "}
{"_id":"q-en-rust-425b140502bb95495f5d2cb3cd4c710b1572231a617a7e224277c15bef657fd7","text":" #![warn(unused)] #![allow(dead_code)] #![deny(non_snake_case)] mod Impl {} //~^ ERROR module `Impl` should have a snake case name fn While() {} //~^ ERROR function `While` should have a snake case name fn main() { let Mod: usize = 0; //~^ ERROR variable `Mod` should have a snake case name //~^^ WARN unused variable: `Mod` let Super: usize = 0; //~^ ERROR variable `Super` should have a snake case name //~^^ WARN unused variable: `Super` } "}
{"_id":"q-en-rust-429541631ecbc6391826bf0fa0fa03766272d4d3ffefda90f9e0d2eaf9ec8881","text":"} } fn record_pat_span(&mut self, node: NodeId, span: Span) { debug!(\"(recording pat) recording {:?} for {:?}\", node, span); self.pat_span_map.insert(node, span); } fn is_accessible_from(&self, vis: ty::Visibility, module: Module<'a>) -> bool { vis.is_accessible_from(module.nearest_parent_mod, self) }"}
{"_id":"q-en-rust-42a66441552c00558ae31b5fb18f88e4860cae053fcae377d9004104e52b1923","text":"never_suggest_borrow.push(self.tcx.get_diagnostic_item(sym::send_trait).unwrap()); let param_env = obligation.param_env; let trait_ref = trait_ref.skip_binder(); let trait_ref = poly_trait_ref.skip_binder(); let found_ty = trait_ref.self_ty(); let found_ty_str = found_ty.to_string();"}
{"_id":"q-en-rust-42dea4edb0f108b4a62037ef429eb3046c7cb70148f5e1c1a5f88fa71fd8f057","text":"return tcx.arena.alloc(IndexVec::new()); } let tainted_by_errors = tcx.mir_borrowck(def).tainted_by_errors; tcx.ensure_with_value().mir_borrowck(def); let mut promoted = tcx.mir_promoted(def).1.steal(); for body in &mut promoted { if let Some(error_reported) = tainted_by_errors { body.tainted_by_errors = Some(error_reported); } run_analysis_to_runtime_passes(tcx, body); }"}
{"_id":"q-en-rust-4307849d65139f41fe99cd76847e681ab11c3626205325f3caccd7c8ae63c1cb","text":"Variant2, } #[derive(Debug)] enum TupleVariant { Variant1(i32), //~ ERROR: variant `Variant1` is never constructed Variant2, } #[derive(Debug)] enum StructVariant { Variant1 { id: i32 }, //~ ERROR: variant `Variant1` is never constructed Variant2, } fn main() { let e = Enum::Variant2; e.clone(); let _ = TupleVariant::Variant2; let _ = StructVariant::Variant2; }"}
{"_id":"q-en-rust-4317c2b6f5e201c179427d5f74ddb77a69164ab8526b169c21c13a2aab0060f0","text":"tool::Rustfmt, tool::Miri, tool::CargoMiri, native::Lld native::Lld, native::CrtBeginEnd ), Kind::Check | Kind::Clippy { .. } | Kind::Fix | Kind::Format => describe!( check::Std,"}
{"_id":"q-en-rust-431bcee076070adec1817fba05204727576e0301c72d668b3179f1dd53812c7d","text":"#[derive(Copy, Clone, RustcEncodable, RustcDecodable)] enum EntryKind { AnonConst(mir::ConstQualifs, Lazy), Const(mir::ConstQualifs, Lazy), ImmStatic, MutStatic,"}
{"_id":"q-en-rust-431fe7339dd9dcbdf4ecae5336a17fe625bf820ac699dee046b93b3295423592","text":"}; // rhs has holes ( `$id` and `$(...)` that need filled) let tts = transcribe(&cx.parse_sess.span_diagnostic, Some(named_matches), rhs); if cx.trace_macros() { trace_macros_note(cx, sp, format!(\"to `{}`\", tts)); } let directory = Directory { path: cx.current_expansion.module.directory.clone(), ownership: cx.current_expansion.directory_ownership,"}
{"_id":"q-en-rust-4359ffb0a9c65ad66132921add3af2a898ca8b1bc59639d3be3377c6618a1e44","text":"}); cx.emit_spanned_lint(DEREF_INTO_DYN_SUPERTRAIT, cx.tcx.def_span(item.owner_id.def_id), SupertraitAsDerefTarget { t, target_principal: target_principal.to_string(), target_principal, label, }); }"}
{"_id":"q-en-rust-43662f92a6b73ed585ac2484c25073ec74ccab11e3cbbad6af729e23b9a48703","text":"return; }; let coroutine_ty = body.local_decls[ty::CAPTURE_STRUCT_LOCAL].ty; let ty::Coroutine(_, args) = *coroutine_ty.kind() else { bug!() }; if coroutine_ty.references_error() { return; } let ty::Coroutine(_, args) = *coroutine_ty.kind() else { bug!(\"{body:#?}\") }; let coroutine_kind = args.as_coroutine().kind_ty().to_opt_closure_kind().unwrap(); if coroutine_kind == ty::ClosureKind::FnOnce {"}
{"_id":"q-en-rust-436dac458f919ca6eb9e5719ef0c9eb3390e13092b2f3c2b52210ac6444f1ad4","text":"}; if let ObligationCauseCode::ImplDerivedObligation(obligation) = &*code { let expected_trait_ref = obligation.parent_trait_ref.skip_binder(); let new_imm_trait_ref = ty::TraitRef::new(obligation.parent_trait_ref.def_id(), imm_substs); let new_mut_trait_ref = ty::TraitRef::new(obligation.parent_trait_ref.def_id(), mut_substs); let expected_trait_ref = obligation.parent_trait_ref; let new_imm_trait_ref = poly_trait_ref .rebind(ty::TraitRef::new(obligation.parent_trait_ref.def_id(), imm_substs)); let new_mut_trait_ref = poly_trait_ref .rebind(ty::TraitRef::new(obligation.parent_trait_ref.def_id(), mut_substs)); return try_borrowing(new_imm_trait_ref, new_mut_trait_ref, expected_trait_ref, &[]); } else if let ObligationCauseCode::BindingObligation(_, _) | ObligationCauseCode::ItemObligation(_) = &*code { return try_borrowing( ty::TraitRef::new(trait_ref.def_id, imm_substs), ty::TraitRef::new(trait_ref.def_id, mut_substs), trait_ref, poly_trait_ref.rebind(ty::TraitRef::new(trait_ref.def_id, imm_substs)), poly_trait_ref.rebind(ty::TraitRef::new(trait_ref.def_id, mut_substs)), *poly_trait_ref, &never_suggest_borrow[..], ); } else {"}
{"_id":"q-en-rust-43d5d818e48a5913b60d2d7ac0126a2a6291cb0de44f11cbb65617b328b3a2a8","text":"error: invalid register `invalid`: unknown register --> $DIR/issue-72570.rs:7:18 --> $DIR/issue-72570.rs:9:18 | LL | asm!(\"\", in(\"invalid\") \"\".len()); | ^^^^^^^^^^^^^^^^^^^^^^"}
{"_id":"q-en-rust-43dc284e9e3f89d0e139760138b629f3acb9515e78999abb6aec56ae8150cff7","text":" error[E0004]: non-exhaustive patterns: `(A, Some(A))`, `(A, Some(B))`, `(B, Some(B))` and 2 more not covered --> $DIR/issue-72377.rs:8:11 | LL | match (x, y) { | ^^^^^^ patterns `(A, Some(A))`, `(A, Some(B))`, `(B, Some(B))` and 2 more not covered | = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `(X, Option)` error: aborting due to previous error For more information about this error, try `rustc --explain E0004`. "}
{"_id":"q-en-rust-43e5286036b784140f68ab93146a1b58fc99c5718889507d26b2dc4b4f5862f8","text":"#[test] #[cfg(unix)] #[cfg_attr(any(target_os = \"vxworks\", target_os = \"android\"), ignore)] #[cfg_attr(any(target_os = \"vxworks\"), ignore)] fn signal_reported_right() { use crate::os::unix::process::ExitStatusExt; let mut p = Command::new(\"/bin/sh\").arg(\"-c\").arg(\"read a\").stdin(Stdio::piped()).spawn().unwrap(); let mut p = shell_cmd().arg(\"-c\").arg(\"read a\").stdin(Stdio::piped()).spawn().unwrap(); p.kill().unwrap(); match p.wait().unwrap().signal() { Some(9) => {}"}
{"_id":"q-en-rust-444fe71db728ebb039b3e5b0b24eb0bafe1cc054e6e81fb8c2879ffd0a88fd8e","text":" // check-pass // https://github.com/rust-lang/rust/issues/113257 #![deny(trivial_casts)] // The casts here are not trivial. struct Foo<'a> { a: &'a () } fn extend_lifetime_very_very_safely<'a>(v: *const Foo<'a>) -> *const Foo<'static> { // This should pass because raw pointer casts can do anything they want. v as *const Foo<'static> } trait Trait {} fn assert_static<'a>(ptr: *mut (dyn Trait + 'a)) -> *mut (dyn Trait + 'static) { ptr as _ } fn main() { let unit = (); let foo = Foo { a: &unit }; let _long: *const Foo<'static> = extend_lifetime_very_very_safely(&foo); } "}
{"_id":"q-en-rust-447810dc35ba00207d5579b2f97c2aed83adfb191076ee7e26cebbb7d97ecaf2","text":"// If this is a floating point literal that ends with '.', // get rid of it to stop this from becoming a member access. let snippet = snippet.strip_suffix('.').unwrap_or(&snippet); err.span_suggestion( lit.span, &format!("}
{"_id":"q-en-rust-44d029639f0fd754793906f833bf935cde35c11025fc1707168403d4eeaf8859","text":"let _a = stderr(); let _a = _a.lock(); } #[test] #[cfg_attr(target_os = \"emscripten\", ignore)] fn test_lock_stderr() { test_lock(stderr, stderr_locked); } #[test] #[cfg_attr(target_os = \"emscripten\", ignore)] fn test_lock_stdin() { test_lock(stdin, stdin_locked); } #[test] #[cfg_attr(target_os = \"emscripten\", ignore)] fn test_lock_stdout() { test_lock(stdout, stdout_locked); } // Helper trait to make lock testing function generic. trait Stdio<'a>: 'static where Self::Lock: 'a, { type Lock; fn lock(&'a self) -> Self::Lock; } impl<'a> Stdio<'a> for Stderr { type Lock = StderrLock<'a>; fn lock(&'a self) -> StderrLock<'a> { self.lock() } } impl<'a> Stdio<'a> for Stdin { type Lock = StdinLock<'a>; fn lock(&'a self) -> StdinLock<'a> { self.lock() } } impl<'a> Stdio<'a> for Stdout { type Lock = StdoutLock<'a>; fn lock(&'a self) -> StdoutLock<'a> { self.lock() } } // Helper trait to make lock testing function generic. trait StdioOwnedLock: 'static {} impl StdioOwnedLock for StderrLock<'static> {} impl StdioOwnedLock for StdinLock<'static> {} impl StdioOwnedLock for StdoutLock<'static> {} // Tests locking on stdio handles by starting two threads and checking that // they block each other appropriately. fn test_lock(get_handle: fn() -> T, get_locked: fn() -> U) where T: for<'a> Stdio<'a>, U: StdioOwnedLock, { // State enum to track different phases of the test, primarily when // each lock is acquired and released. #[derive(Debug, PartialEq)] enum State { Start1, Acquire1, Start2, Release1, Acquire2, Release2, } use State::*; // Logging vector to be checked to make sure lock acquisitions and // releases happened in the correct order. let log = Arc::new(Mutex::new(Vec::new())); let ((tx1, rx1), (tx2, rx2)) = (sync_channel(0), sync_channel(0)); let th1 = { let (log, tx) = (Arc::clone(&log), tx1); thread::spawn(move || { log.lock().unwrap().push(Start1); let handle = get_handle(); { let locked = handle.lock(); log.lock().unwrap().push(Acquire1); tx.send(Acquire1).unwrap(); // notify of acquisition tx.send(Release1).unwrap(); // wait for release command log.lock().unwrap().push(Release1); } tx.send(Acquire1).unwrap(); // wait for th2 acquire { let locked = handle.lock(); log.lock().unwrap().push(Acquire1); } log.lock().unwrap().push(Release1); }) }; let th2 = { let (log, tx) = (Arc::clone(&log), tx2); thread::spawn(move || { tx.send(Start2).unwrap(); // wait for start command let locked = get_locked(); log.lock().unwrap().push(Acquire2); tx.send(Acquire2).unwrap(); // notify of acquisition tx.send(Release2).unwrap(); // wait for release command log.lock().unwrap().push(Release2); }) }; assert_eq!(rx1.recv().unwrap(), Acquire1); // wait for th1 acquire log.lock().unwrap().push(Start2); assert_eq!(rx2.recv().unwrap(), Start2); // block th2 assert_eq!(rx1.recv().unwrap(), Release1); // release th1 assert_eq!(rx2.recv().unwrap(), Acquire2); // wait for th2 acquire assert_eq!(rx1.recv().unwrap(), Acquire1); // block th1 assert_eq!(rx2.recv().unwrap(), Release2); // release th2 th2.join().unwrap(); th1.join().unwrap(); assert_eq!( *log.lock().unwrap(), [Start1, Acquire1, Start2, Release1, Acquire2, Release2, Acquire1, Release1] ); } "}
{"_id":"q-en-rust-44e5bfbbafe9f01b86d20b8d8bc17367822fb73226e80a299ecf4ef64998e078","text":"use rustc_metadata::creader::{CStore, LoadedMacro}; use rustc_middle::ty::fast_reject::SimplifiedType; use rustc_middle::ty::{self, TyCtxt}; use rustc_span::def_id::LOCAL_CRATE; use rustc_span::hygiene::MacroKind; use rustc_span::symbol::{kw, sym, Symbol};"}
{"_id":"q-en-rust-4513b3f27568368132aa9521b214883c6add324fa9377f256736b428f171d20a","text":"} } /// Suggest using `while let` for call `next` on an iterator in a for loop. /// /// For example: /// ```ignore (illustrative) /// /// for x in iter { /// ... /// iter.next() /// } /// ``` pub(crate) fn explain_iterator_advancement_in_for_loop_if_applicable( &self, err: &mut Diagnostic, span: Span, issued_spans: &UseSpans<'tcx>, ) { let issue_span = issued_spans.args_or_use(); let tcx = self.infcx.tcx; let hir = tcx.hir(); let Some(body_id) = hir.get(self.mir_hir_id()).body_id() else { return }; let typeck_results = tcx.typeck(self.mir_def_id()); struct ExprFinder<'hir> { issue_span: Span, expr_span: Span, body_expr: Option<&'hir hir::Expr<'hir>>, loop_bind: Option, } impl<'hir> Visitor<'hir> for ExprFinder<'hir> { fn visit_expr(&mut self, ex: &'hir hir::Expr<'hir>) { if let hir::ExprKind::Loop(hir::Block{ stmts: [stmt, ..], ..}, _, hir::LoopSource::ForLoop, _) = ex.kind && let hir::StmtKind::Expr(hir::Expr{ kind: hir::ExprKind::Match(call, [_, bind, ..], _), ..}) = stmt.kind && let hir::ExprKind::Call(path, _args) = call.kind && let hir::ExprKind::Path(hir::QPath::LangItem(LangItem::IteratorNext, _, _, )) = path.kind && let hir::PatKind::Struct(path, [field, ..], _) = bind.pat.kind && let hir::QPath::LangItem(LangItem::OptionSome, _, _) = path && let PatField { pat: hir::Pat{ kind: hir::PatKind::Binding(_, _, ident, ..), .. }, ..} = field && self.issue_span.source_equal(call.span) { self.loop_bind = Some(ident.name); } if let hir::ExprKind::MethodCall(body_call, _recv, ..) = ex.kind && body_call.ident.name == sym::next && ex.span.source_equal(self.expr_span) { self.body_expr = Some(ex); } hir::intravisit::walk_expr(self, ex); } } let mut finder = ExprFinder { expr_span: span, issue_span, loop_bind: None, body_expr: None }; finder.visit_expr(hir.body(body_id).value); if let Some(loop_bind) = finder.loop_bind && let Some(body_expr) = finder.body_expr && let Some(def_id) = typeck_results.type_dependent_def_id(body_expr.hir_id) && let Some(trait_did) = tcx.trait_of_item(def_id) && tcx.is_diagnostic_item(sym::Iterator, trait_did) { err.note(format!( \"a for loop advances the iterator for you, the result is stored in `{}`.\", loop_bind )); err.help(\"if you want to call `next` on a iterator within the loop, consider using `while let`.\"); } } /// Suggest using closure argument instead of capture. /// /// For example:"}
{"_id":"q-en-rust-457d30e763d5cb3f464ad416df72b4d9952f6c4a4606b0ede4489624c7b6719a","text":"_ => false, } } fn is_local(&self) -> bool { self.normal_ancestor_id.is_some() } } impl<'a> fmt::Debug for ModuleS<'a> {"}
{"_id":"q-en-rust-458097da950ec73b1580b21c6e2853992946e901d33970069de8e47ddd9f26b4","text":"[dependencies] core = { path = \"../core\" } compiler_builtins = { version = \"0.1.114\", features = ['rustc-dep-of-std'] } [target.'cfg(not(any(target_arch = \"aarch64\", target_arch = \"x86\", target_arch = \"x86_64\")))'.dependencies] compiler_builtins = { version = \"0.1.114\", features = [\"no-f16-f128\"] } compiler_builtins = { version = \"0.1.117\", features = ['rustc-dep-of-std'] } [dev-dependencies] rand = { version = \"0.8.5\", default-features = false, features = [\"alloc\"] }"}
{"_id":"q-en-rust-45922678c6cd755ce6ecfaa0e30bc4c92cbbe26c66d7b2eec5bc0a0213c1a5c5","text":" // 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 or the MIT license // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. pub trait AbstractRenderer {} fn _create_render(_: &()) -> AbstractRenderer //~^ ERROR: the trait `core::kinds::Sized` is not implemented { match 0u { _ => unimplemented!() } } fn main() { } "}
{"_id":"q-en-rust-45abac779ba62e64385d7b7c09408840139887910fc042d52bbf34c42bfc768f","text":" Subproject commit a416c5e0f7c4c9473069a58410d3ec3e86b1ac0d Subproject commit fc24fce73f878e641094b1802df1e748c5fe233a "}
{"_id":"q-en-rust-460406f8aedb72cf7fa98dd1ecf366988a5e89fc483c4488b4773d9b0e08da77","text":" error[E0308]: mismatched types --> $DIR/issue-30904.rs:20:45 | LL | let _: for<'a> fn(&'a str) -> Str<'a> = Str; | ^^^ expected concrete lifetime, found bound lifetime parameter 'a | = note: expected type `for<'a> fn(&'a str) -> Str<'a>` found type `fn(&str) -> Str<'_> {Str::<'_>}` error[E0631]: type mismatch in function arguments --> $DIR/issue-30904.rs:26:10 | LL | fn test FnOnce<(&'x str,)>>(_: F) {} | ---- -------------------------- required by this bound in `test` ... LL | struct Str<'a>(&'a str); | ------------------------ found signature of `fn(&str) -> _` ... LL | test(Str); | ^^^ expected signature of `for<'x> fn(&'x str) -> _` error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0308`. "}
{"_id":"q-en-rust-460abba7299293c4c60b0a9bed6a278d2fd4f9d30413216aed4241d8ca606875","text":" // aux-build:issue-99221-aux.rs // build-aux-docs // ignore-cross-compile #![crate_name = \"foo\"] #[macro_use] extern crate issue_99221_aux; pub use issue_99221_aux::*; // @count foo/index.html '//a[@class=\"macro\"]' 1 #[macro_export] macro_rules! print { () => () } "}
{"_id":"q-en-rust-460bc02f2906b536d6632564d5ff6d28d01bfadf95abf160699c1e959e435df6","text":"}) } pub fn predicate_for_default_trait_impl<'tcx>( pub fn predicate_for_trait_def<'tcx>( tcx: &ty::ctxt<'tcx>, cause: ObligationCause<'tcx>, trait_def_id: ast::DefId,"}
{"_id":"q-en-rust-4617c87aa4cb7463e8024de9e528d9cc1b0ae8e05e0a738c718108a2b446c54f","text":"| ^ expected identifier, found reserved identifier error: associated constant in `impl` without body --> $DIR/typeck_type_placeholder_item.rs:203:5 --> $DIR/typeck_type_placeholder_item.rs:205:5 | LL | const C: _; | ^^^^^^^^^^-"}
{"_id":"q-en-rust-46385bdfdfc6713809a49e57556dd4ca22b367884ca82beafac27918284a7470","text":"install_sh(builder, \"clippy\", self.compiler.stage, Some(self.target), &tarball); }; Miri, alias = \"miri\", Self::should_build(_config), only_hosts: true, { let tarball = builder .ensure(dist::Miri { compiler: self.compiler, target: self.target }) .expect(\"missing miri\"); install_sh(builder, \"miri\", self.compiler.stage, Some(self.target), &tarball); if let Some(tarball) = builder.ensure(dist::Miri { compiler: self.compiler, target: self.target }) { install_sh(builder, \"miri\", self.compiler.stage, Some(self.target), &tarball); } else { // Miri is only available on nightly builder.info( &format!(\"skipping Install miri stage{} ({})\", self.compiler.stage, self.target), ); } }; LlvmTools, alias = \"llvm-tools\", Self::should_build(_config), only_hosts: true, { let tarball = builder"}
{"_id":"q-en-rust-465874c591121798bda7ed6e101f5fe43694be5c2bd7d5a505846f26b581ed1d","text":" // 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 or the MIT license // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. // Test that methods from shadowed traits cannot be used mod foo { pub trait T { fn f(&self) {} } impl T for () {} } mod bar { pub use foo::T; } fn main() { pub use bar::*; struct T; ().f() //~ ERROR no method } "}
{"_id":"q-en-rust-4665f46eb0b8ad421c119012ea1b0e351258193696747b9f304649d5ba5c2436","text":" warning: the feature `non_lifetime_binders` is incomplete and may not be safe to use and/or cause compiler crashes --> $DIR/nested-apit-mentioning-outer-bound-var.rs:1:12 | LL | #![feature(non_lifetime_binders)] | ^^^^^^^^^^^^^^^^^^^^ | = note: see issue #108185 for more information = note: `#[warn(incomplete_features)]` on by default error: `impl Trait` can only mention type parameters from an fn or impl --> $DIR/nested-apit-mentioning-outer-bound-var.rs:8:52 | LL | fn uwu(_: impl for Trait<(), Assoc = impl Trait>) {} | - type parameter declared here ^ error: aborting due to previous error; 1 warning emitted "}
{"_id":"q-en-rust-46719821122b85a78f7448084df56ecd160704f5bf89f1539a55a2a5722c50f9","text":"// Once we're done with llvm 14 and earlier, this test can be deleted. #![crate_type=\"lib\"] #![crate_type = \"lib\"] use std::mem::MaybeUninit;"}
{"_id":"q-en-rust-46a2f5337ca3948d757befb3b56c36a4d8b3d78d02dfa1196aaa1f9032005bab","text":"// and about 2 * (len1 + len2) comparisons in the worst case // while `extend` takes O(len2 * log(len1)) operations // and about 1 * len2 * log_2(len1) comparisons in the worst case, // assuming len1 >= len2. // assuming len1 >= len2. For larger heaps, the crossover point // no longer follows this reasoning and was determined empirically. #[inline] fn better_to_rebuild(len1: usize, len2: usize) -> bool { 2 * (len1 + len2) < len2 * log2_fast(len1) let tot_len = len1 + len2; if tot_len <= 2048 { 2 * tot_len < len2 * log2_fast(len1) } else { 2 * tot_len < len2 * 11 } } if better_to_rebuild(self.len(), other.len()) {"}
{"_id":"q-en-rust-46b87280fdbbcb4b43e37584c4b92a35404f0cdeba3223fb84b6edfd59b06fa4","text":"} _ => token.span, }, Some(tree) => tree.span(), None => colon_span, // Invalid, return a nice source location _ => colon_span.with_lo(start_sp.lo()), } } Some(tree) => tree.span(), None => start_sp, // Whether it's none or some other tree, it doesn't belong to // the current meta variable, returning the original span. _ => start_sp, }; result.push(TokenTree::MetaVarDecl(span, ident, None));"}
{"_id":"q-en-rust-470047959fbfebe645cdbb434c662d167811f1f74b5823b08b96ea0c30cba562","text":" #![feature(fn_traits, unboxed_closures)] fn test FnOnce<(&'x str,)>>(_: F) {} struct Compose(F,G); impl FnOnce<(T,)> for Compose where F: FnOnce<(T,)>, G: FnOnce<(F::Output,)> { type Output = G::Output; extern \"rust-call\" fn call_once(self, (x,): (T,)) -> G::Output { (self.1)((self.0)(x)) } } fn bad(f: fn(&'static str) -> T) { test(Compose(f, |_| {})); //~ ERROR: mismatched types } fn main() {} "}
{"_id":"q-en-rust-47104bea46e135e0d9c604e79a1859f0561ff9fc06fe92c1cd46eb910d6f33d7","text":"/// A type that allows convenient usage of a UDP stream connected to one /// address via the `Reader` and `Writer` traits. /// /// # Note /// /// This structure has been deprecated because `Reader` is a stream-oriented API but UDP /// is a packet-oriented protocol. Every `Reader` method will read a whole packet and /// throw all superfluous bytes away so that they are no longer available for further /// method calls. #[deprecated] pub struct UdpStream { socket: UdpSocket, connected_to: SocketAddr"}
{"_id":"q-en-rust-477897e687659744c894fe1aac9e3800ca4e0a0d8d655da2d9e7dbd6b511c7b1","text":"continue; } // HACK: `async fn() -> Self` in traits is \"ok\"... // This is not really that great, but it's similar to why the `-> Self` // return type is well-formed in traits even when `Self` isn't sized. if let ty::Param(param_ty) = *proj_term.kind() && param_ty.name == kw::SelfUpper && matches!(opaque.origin, hir::OpaqueTyOrigin::AsyncFn(_)) && opaque.in_trait { continue; } let proj_ty = Ty::new_projection(cx.tcx, proj.projection_ty.def_id, proj.projection_ty.args); // For every instance of the projection type in the bounds,"}
{"_id":"q-en-rust-477f8fbd795faaff6d558dfa155d83ae0a8c438038479e4aedbd66438652063c","text":"// panicking thread consumes at least 2 bytes of address space. static GLOBAL_PANIC_COUNT: AtomicUsize = AtomicUsize::new(0); // Return the state of the ALWAYS_ABORT_FLAG and number of panics. // // If ALWAYS_ABORT_FLAG is not set, the number is determined on a per-thread // base (stored in LOCAL_PANIC_COUNT), i.e. it is the amount of recursive calls // of the calling thread. // If ALWAYS_ABORT_FLAG is set, the number equals the *global* number of panic // calls. See above why LOCAL_PANIC_COUNT is not used. pub fn increase() -> (bool, usize) { ( GLOBAL_PANIC_COUNT.fetch_add(1, Ordering::Relaxed) & ALWAYS_ABORT_FLAG != 0, let global_count = GLOBAL_PANIC_COUNT.fetch_add(1, Ordering::Relaxed); let must_abort = global_count & ALWAYS_ABORT_FLAG != 0; let panics = if must_abort { global_count & !ALWAYS_ABORT_FLAG } else { LOCAL_PANIC_COUNT.with(|c| { let next = c.get() + 1; c.set(next); next }), ) }) }; (must_abort, panics) } pub fn decrease() {"}
{"_id":"q-en-rust-4792491bf44403791ab6ddef82010f9640fe8ddf85cf664b7cf12dca367bf439","text":" error[E0644]: closure/coroutine type that references itself --> $DIR/cyclic_type_ice.rs:3:7 | LL | f(f); | ^ cyclic type of infinite size | = note: closures cannot capture themselves or take themselves as argument; this error may be the result of a recent compiler bug-fix, see issue #46062 for more information error[E0057]: this function takes 2 arguments but 1 argument was supplied --> $DIR/cyclic_type_ice.rs:3:5 | LL | f(f); | ^--- an argument is missing | note: closure defined here --> $DIR/cyclic_type_ice.rs:2:13 | LL | let f = |_, _| (); | ^^^^^^ help: provide the argument | LL | f(/* */, /* */); | ~~~~~~~~~~~~~~~~ error: aborting due to 2 previous errors Some errors have detailed explanations: E0057, E0644. For more information about an error, try `rustc --explain E0057`. "}
{"_id":"q-en-rust-47a5ff8b9c9b64b5bbc33cc06e8bcf785b7f91e698adedd610a6cc24e0727db0","text":"\"concatenates all document attributes into one document attribute\"), (\"strip-private\", passes::strip_private, \"strips all private items from a crate which cannot be seen externally\"), (\"strip-priv-imports\", passes::strip_priv_imports, \"strips all private import statements (`use`, `extern crate`) from a crate\"), ]; const DEFAULT_PASSES: &'static [&'static str] = &["}
{"_id":"q-en-rust-47c1b4f8a083832b3041731aee1f828dcd153905dde6a5e7ef61db92a56aeefb","text":" # only-linux # ignore-32bit -include ../tools.mk all: $(RUSTC) eh_frame-terminator.rs $(call RUN,eh_frame-terminator) | $(CGREP) '1122334455667788' objdump --dwarf=frames $(TMPDIR)/eh_frame-terminator | $(CGREP) 'ZERO terminator' "}
{"_id":"q-en-rust-47c44d7c6511699b5de95af0a39df5617cb64d3aaa5f64cc4006cec6b5ba24a7","text":" // check-fail // dont-check-compiler-stdout // dont-check-compiler-stderr fn�a(){fn�p(){e}} //~ ERROR unknown start of token: u{fffd} //~^ ERROR unknown start of token: u{fffd} //~^^ ERROR can't use generic parameters from outer function [E0401] //~^^^ WARN type parameter `e` should have an upper camel case name fn main(){} "}
{"_id":"q-en-rust-47c9388906f9cd01ba6a1c417ae610ab2dffec6a1c1b94ea03b39f5982115642","text":" error[E0308]: mismatched types --> $DIR/suggest-call-on-pat-mismatch.rs:7:12 | LL | if let E::One(var1, var2) = var { | ^^^^^^^^^^^^^^^^^^ --- this expression has type `fn(i32, i32) -> E {E::One}` | | | expected enum constructor, found `E` | = note: expected enum constructor `fn(i32, i32) -> E {E::One}` found enum `E` help: use parentheses to construct this tuple variant | LL | if let E::One(var1, var2) = var(/* i32 */, /* i32 */) { | ++++++++++++++++++++++ error[E0308]: mismatched types --> $DIR/suggest-call-on-pat-mismatch.rs:13:9 | LL | let Some(x) = Some; | ^^^^^^^ ---- this expression has type `fn(_) -> Option<_> {Option::<_>::Some}` | | | expected enum constructor, found `Option<_>` | = note: expected enum constructor `fn(_) -> Option<_> {Option::<_>::Some}` found enum `Option<_>` help: use parentheses to construct this tuple variant | LL | let Some(x) = Some(/* value */); | +++++++++++++ error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0308`. "}
{"_id":"q-en-rust-480e4999eedf29a07ccb329cadfbac13342d259faafad324bb21afb178f54968","text":"/// /// [`to_ascii_uppercase()`]: #method.to_ascii_uppercase #[stable(feature = \"ascii_methods_on_intrinsics\", since = \"1.23.0\")] #[rustc_const_unstable(feature = \"const_make_ascii\", issue = \"130698\")] #[rustc_const_stable(feature = \"const_make_ascii\", since = \"CURRENT_RUSTC_VERSION\")] #[inline] #[cfg_attr(bootstrap, rustc_allow_const_fn_unstable(const_mut_refs))] pub const fn make_ascii_uppercase(&mut self) { *self = self.to_ascii_uppercase(); }"}
{"_id":"q-en-rust-4859dba805b4aedef0c5aaa685857e3d03391d958dd397bd3ec098acd6c0a7fe","text":"> { after_tail: usize, after_head: usize, iter: Iter<'a, T>, ring: NonNull<[T]>, tail: usize, head: usize, deque: NonNull>, _phantom: PhantomData<&'a T>, } impl<'a, T, A: Allocator> Drain<'a, T, A> { pub(super) unsafe fn new( after_tail: usize, after_head: usize, iter: Iter<'a, T>, ring: &'a [MaybeUninit], tail: usize, head: usize, deque: NonNull>, ) -> Self { Drain { after_tail, after_head, iter, deque } let ring = unsafe { NonNull::new_unchecked(ring as *const [MaybeUninit] as *mut _) }; Drain { after_tail, after_head, ring, tail, head, deque, _phantom: PhantomData } } }"}
{"_id":"q-en-rust-485cef9d24680d2ce45c51072ac86201f707be02d53112990319d03af3d99ab8","text":"use crate::io::ErrorKind; use crate::str; // FIXME(#10380) these tests should not all be ignored on android. #[cfg(target_os = \"android\")] fn shell_cmd() -> Command { Command::new(\"/system/bin/sh\") } #[cfg(not(target_os = \"android\"))] fn shell_cmd() -> Command { Command::new(\"/bin/sh\") } #[test] #[cfg_attr(any(target_os = \"vxworks\", target_os = \"android\"), ignore)] #[cfg_attr(any(target_os = \"vxworks\"), ignore)] fn smoke() { let p = if cfg!(target_os = \"windows\") { Command::new(\"cmd\").args(&[\"/C\", \"exit 0\"]).spawn() } else { Command::new(\"true\").spawn() shell_cmd().arg(\"-c\").arg(\"true\").spawn() }; assert!(p.is_ok()); let mut p = p.unwrap();"}
{"_id":"q-en-rust-487988aa2fcabe0988b35c1577b6f68d164831619d684fea06b8a1c91ae26b53","text":"LL | | /// Some docs. LL | | ... | LL | | pub fn bar() {} LL | | } LL | | } | |_^ |"}
{"_id":"q-en-rust-48bb7baad74252d6e43b5c7fb176c756d0ced926e45444df08180c6dde62d841","text":" // check-pass // Regression test for issue #55099 // Tests that we don't incorrectly consider a lifetime to part // of the concrete type #![feature(type_alias_impl_trait)] trait Future { } struct AndThen(F); impl Future for AndThen { } struct Foo<'a> { x: &'a mut (), } type F = impl Future; impl<'a> Foo<'a> { fn reply(&mut self) -> F { AndThen(|| ()) } } fn main() {} "}
{"_id":"q-en-rust-48f3ca2d7004293ac665d412326679077c0f4660be775f5e0156481dd8af5931","text":" Subproject commit 20da8f45c601d0eec8af8c0897abd536ad57951f Subproject commit 71be6f62fa920c0bd10cdf3a29aeb8c6719a8075 "}
{"_id":"q-en-rust-48f4a25ce59414d6101941a099113e3f9794d6ff3bb3586641b83d6f0a3879de","text":" warning: `extern` block uses type `TransparentCustomZst`, which is not FFI-safe --> $DIR/repr-transparent-issue-87496.rs:8:18 | LL | fn good17(p: TransparentCustomZst); | ^^^^^^^^^^^^^^^^^^^^ not FFI-safe | = note: `#[warn(improper_ctypes)]` on by default = note: this struct contains only zero-sized fields note: the type is defined here --> $DIR/repr-transparent-issue-87496.rs:6:1 | LL | struct TransparentCustomZst(()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: 1 warning emitted "}
{"_id":"q-en-rust-48fe015cef09fe09ef24fdc75e7368ce68531f91742b41d0774387485baa8b63","text":"| NonMutatingUseContext::Copy | NonMutatingUseContext::Inspect | NonMutatingUseContext::Move | NonMutatingUseContext::PlaceMention | NonMutatingUseContext::ShallowBorrow | NonMutatingUseContext::SharedBorrow | NonMutatingUseContext::UniqueBorrow,"}
{"_id":"q-en-rust-48ff830bba11678ea901c9ff0be96d9937fe6f6bc1a3e507bdf978d1fb435acd","text":"// Check whether a span corresponding to a range expression is a // range literal, rather than an explicit struct or `new()` call. fn is_lit(sm: &SourceMap, span: &Span) -> bool { let end_point = sm.end_point(*span); if let Ok(end_string) = sm.span_to_snippet(end_point) { !(end_string.ends_with('}') || end_string.ends_with(')')) } else { false } sm.span_to_snippet(*span).map(|range_src| range_src.contains(\"..\")).unwrap_or(false) }; match expr.kind {"}
{"_id":"q-en-rust-4911a8bf87fd99b511f8624a3b3387ab21fb441f28cd25ff92d20b1d431f4ed6","text":"// @has blanket_with_local.json \"$.index[*][?(@.name=='Load')]\" pub trait Load { // @has - \"$.index[*][?(@.name=='load')]\" fn load() {} // @has - \"$.index[*][?(@.name=='write')]\" fn write(self) {} } impl
\")?; for (field, ty) in fields { let id = derive_id(format!(\"{}.{}\", ItemType::StructField,"}
{"_id":"q-en-rust-92d9db5bb6412bb74d32167054807c2e283d30f778508c7ae0305dcaa5a3df01","text":" // Regression test for #84632: Recursion limit is ignored // for builtin macros that eagerly expands. #![recursion_limit = \"15\"] macro_rules! a { () => (\"\"); (A) => (concat!(\"\", a!())); (A, $($A:ident),*) => (concat!(\"\", a!($($A),*))) //~^ ERROR recursion limit reached //~| HELP consider adding } fn main() { a!(A, A, A, A, A); a!(A, A, A, A, A, A, A, A, A, A, A); } "}
{"_id":"q-en-rust-92f147f2422f5e4ca956d9e29c73a73440ea8a4e95a10c9c37cf981347635b62","text":"if let hir::Node::Pat(parent_pat) = cx.tcx.hir().get(cx.tcx.hir().get_parent_node(hid)) { if let PatKind::Struct(_, field_pats, _) = &parent_pat.kind { for field in field_pats.iter() { if field.ident != ident { // Only check if a new name has been introduced, to avoid warning // on both the struct definition and this pattern. self.check_snake_case(cx, \"variable\", &ident); } if field_pats .iter() .any(|field| !field.is_shorthand && field.pat.hir_id == p.hir_id) { // Only check if a new name has been introduced, to avoid warning // on both the struct definition and this pattern. self.check_snake_case(cx, \"variable\", &ident); } return; }"}
{"_id":"q-en-rust-92fe64d4d20f36fa773f102b0c10addb82b3272606d97f3efb90b4d9b6d78974","text":"assert!(prev_predicates.is_none()); } fn ty_generics_for_type_or_impl<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, generics: &hir::Generics) -> ty::Generics<'tcx> { ty_generics(ccx, TypeSpace, generics, &ty::Generics::empty()) fn ty_generics_for_type<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, generics: &hir::Generics) -> ty::Generics<'tcx> { ty_generics(ccx, TypeSpace, generics, &ty::Generics::empty(), true) } fn ty_generics_for_impl<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, generics: &hir::Generics) -> ty::Generics<'tcx> { ty_generics(ccx, TypeSpace, generics, &ty::Generics::empty(), false) } fn ty_generic_predicates_for_type_or_impl<'a,'tcx>(ccx: &CrateCtxt<'a,'tcx>,"}
{"_id":"q-en-rust-9345a0bb5081fd40fcfafa648f9b385c3b581385f02761ab590cf02a2d004770","text":" // no-system-llvm // compile-flags: -O -C overflow-checks=on #![crate_type = \"lib\"] pub struct S1<'a> { data: &'a [u8], position: usize, } // CHECK-LABEL: @slice_no_index_order #[no_mangle] pub fn slice_no_index_order<'a>(s: &'a mut S1, n: usize) -> &'a [u8] { // CHECK-NOT: slice_index_order_fail let d = &s.data[s.position..s.position+n]; s.position += n; return d; } // CHECK-LABEL: @test_check #[no_mangle] pub fn test_check<'a>(s: &'a mut S1, x: usize, y: usize) -> &'a [u8] { // CHECK: slice_index_order_fail &s.data[x..y] } "}
{"_id":"q-en-rust-93a774019249441d096053b2a132b8bcbc3a95b72d1e8565d76abbc2d4ef5905","text":"expr_span, scope, result, value.ty, expr.ty, ); }"}
{"_id":"q-en-rust-93c5d7f2a630f97ac407877601acccd389796dd1dff540f8070f22652cbb7a0f","text":"/// # Example /// /// ```rust /// # #![allow(deprecated)] /// use url::Url; /// /// let raw = \"https://username@example.com:8080/foo/bar?baz=qux#quz\";"}
{"_id":"q-en-rust-93d5f79b0b43b1dfe46b96de3b6d26a69441c5afc455d3f0a758eecf6b088eb3","text":"exact_paths: Default::default(), modules: vec![om], is_importable_from_parent: true, inside_body: false, } }"}
{"_id":"q-en-rust-941a5bcaae25b8d6c5a7651e9ac1a2a66ee0b39634feb3b95b83a6c8d64ca355","text":" #![feature(unsize)] use std::marker::Unsize; use std::ops::Deref; trait Foo: Bar {} trait Bar {} impl Bar for T where dyn Foo: Unsize {} impl Bar for () {} //~^ ERROR conflicting implementations of trait `Bar` for type `()` fn main() {} "}
{"_id":"q-en-rust-945ed25d597111e6502ab5a2c0d9195132035086a3750e2e2ec750213485a0a8","text":"// seemingly completely unrelated change. // Unfortunately, LLVM has no \"disable\" option for this, so we have to set // \"enable\" to 0 instead. // compile-flags:-g -Cllvm-args=-enable-tail-merge=0 // ignore-pretty as this critically relies on line numbers"}
{"_id":"q-en-rust-94b314e710e59f5735d6e4bf461d6ffcc9f7938b076a3f9b6d2361a24af05189","text":"&self.buf } /// Returns a mutable reference to the internal buffer. /// /// This can be used to write data directly into the buffer without triggering writers /// to the underlying writer. /// /// That the buffer is a `Vec` is an implementation detail. /// Callers should not modify the capacity as there currently is no public API to do so /// and thus any capacity changes would be unexpected by the user. pub(in crate::io) fn buffer_mut(&mut self) -> &mut Vec { &mut self.buf } /// Returns the number of bytes the internal buffer can hold without flushing. /// /// # Examples"}
{"_id":"q-en-rust-94e678d82531d8dfe8ca4b466957a8e3f60d04895a557e2ffd73f4d551bcbe11","text":" #![feature(const_generics)] pub struct Num; // Braces around const expression causes crash impl Num<{5}> { pub fn five(&self) { } } "}
{"_id":"q-en-rust-951b062a7684667b6bed67f2c9d08d2b36a3955c8e81bc0b8b2fad743f49b207","text":"} pub fn foobar() {} pub type Alias = u32; pub struct Foo { pub x: Alias, } impl Foo { pub fn a_method(&self) {} } pub trait Trait { type X; const Y: u32; } impl Trait for Foo { type X = u32; const Y: u32 = 0; } "}
{"_id":"q-en-rust-956236d378b8ecbe56c79b3ba61aadf72739a2ec79a3184555e94b8c8b70a4d5","text":" // Copyright 2017 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 or the MIT license // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. #![crate_type=\"lib\"] pub extern crate core; "}
{"_id":"q-en-rust-95f67363c05a07d11ad38b3a11f6d80ca4d4434dabe747071df1522e4ff19ab0","text":"} /* Code highlighting */ .cm-s-default span.cm-keyword {color: #803C8D;} .cm-s-default span.cm-keyword {color: #8959A8;} .cm-s-default span.cm-atom {color: #219;} .cm-s-default span.cm-number {color: #2AA198;} .cm-s-default span.cm-def {color: #256EB8;} .cm-s-default span.cm-variable {color: black;} .cm-s-default span.cm-variable-2 {color: #817E61;} .cm-s-default span.cm-variable-3 {color: #085;} .cm-s-default span.cm-number {color: #3E999F;} .cm-s-default span.cm-def {color: #4271AE;} /*.cm-s-default span.cm-variable {color: #C82829;}*/ .cm-s-default span.cm-variable-2 {color: #6F906C;} .cm-s-default span.cm-variable-3 {color: #B76514;} .cm-s-default span.cm-property {color: black;} .cm-s-default span.cm-operator {color: black;} .cm-s-default span.cm-comment {color: #A82323;} .cm-s-default span.cm-string {color: #866544;} .cm-s-default span.cm-string-2 {color: #F50;} .cm-s-default span.cm-comment {color: #8E908C;} .cm-s-default span.cm-string {color: #718C00;} .cm-s-default span.cm-string-2 {color: #866544;} .cm-s-default span.cm-meta {color: #555;} /*.cm-s-default span.cm-error {color: #F00;}*/ .cm-s-default span.cm-qualifier {color: #555;} .cm-s-default span.cm-builtin {color: #30A;} .cm-s-default span.cm-bracket {color: #CC7;} .cm-s-default span.cm-tag {color: #170;} .cm-s-default span.cm-tag {color: #C82829;} .cm-s-default span.cm-attribute {color: #00C;} /* The rest"}
{"_id":"q-en-rust-95f8174e409eb14948ae38b7be2278263b81f729e7edd8728f7dd6228ed70b7c","text":"/// as the compiler doesn't need to prove that it's sound to elide the /// copy. /// /// Unaligned values cannot be dropped in place, they must be copied to an aligned /// location first using [`ptr::read_unaligned`]. /// /// [`ptr::read`]: ../ptr/fn.read.html /// [`ptr::read_unaligned`]: ../ptr/fn.read_unaligned.html /// /// # Safety ///"}
{"_id":"q-en-rust-9602aaaf9568f0a6e14b73c897ea554d07869e497a0b7c9d037405f2ded07d09","text":"pub const FILE_TYPE_PIPE: u32 = 3; pub const CP_UTF8: DWORD = 65001; pub const MB_ERR_INVALID_CHARS: DWORD = 0x08; pub const WC_ERR_INVALID_CHARS: DWORD = 0x80; #[repr(C)] #[derive(Copy)] pub struct WIN32_FIND_DATAW {"}
{"_id":"q-en-rust-9619a628619f9cddf6c0065f81c1b28170de527fc907a1ee22528915bdd895cb","text":"// inferred in this method call. let arg = &args[i]; let arg_ty = self.node_ty(arg.hir_id); err.span_label( arg.span, &format!( \"this is of type `{arg_ty}`, which causes `{ident}` to be inferred as `{ty}`\", ), ); if !arg.span.overlaps(mismatch_span) { err.span_label( arg.span, &format!( \"this is of type `{arg_ty}`, which causes `{ident}` to be inferred as `{ty}`\", ), ); } param_args.insert(param_ty, (arg, arg_ty)); } }"}
{"_id":"q-en-rust-961ae737335d238454454212b32b10c17004edd64ebe48a8dd59d12e5f656061","text":"} } fn handle_assign(&mut self, expr: &'tcx hir::Expr<'tcx>) { if self .typeck_results() .expr_adjustments(expr) .iter() .any(|adj| matches!(adj.kind, ty::adjustment::Adjust::Deref(_))) { self.visit_expr(expr); } else if let hir::ExprKind::Field(base, ..) = expr.kind { // Ignore write to field self.handle_assign(base); } else { self.visit_expr(expr); } } fn handle_field_pattern_match( &mut self, lhs: &hir::Pat<'_>,"}
{"_id":"q-en-rust-964c47af66daa0c54d4f44cf54a601c968f3052f4e9fa68c603933d15cfbb4fb","text":"rbml_w.wr_tagged_str(tag_crate_hash, hash.as_str()); } fn encode_rustc_version(rbml_w: &mut Encoder) { rbml_w.wr_tagged_str(tag_rustc_version, &rustc_version()); } fn encode_crate_name(rbml_w: &mut Encoder, crate_name: &str) { rbml_w.wr_tagged_str(tag_crate_crate_name, crate_name); }"}
{"_id":"q-en-rust-966927011ed4577f751ec7616e477b720a677f0821fbb62cbbfa91c4c0c02471","text":" #![deny(warnings)] //! Email me at . //~^ ERROR unknown disambiguator `hello` //! This should *not* warn: . "}
{"_id":"q-en-rust-967377bc971643eafe310c00fd42d239b0a9e2076cba8b3ff755552b66209d35","text":" // This used to cause an ICE for an internal index out of range due to simd_shuffle_indices being // passed the wrong Instance, causing issues with inlining. See #67557. // // run-pass // compile-flags: -Zmir-opt-level=3 #![feature(platform_intrinsics, repr_simd)] extern \"platform-intrinsic\" { fn simd_shuffle2(x: T, y: T, idx: [u32; 2]) -> U; } #[repr(simd)] #[derive(Debug, PartialEq)] struct Simd2(u8, u8); fn main() { unsafe { let _: Simd2 = inline_me(); } } #[inline(always)] unsafe fn inline_me() -> Simd2 { simd_shuffle2(Simd2(10, 11), Simd2(12, 13), [0, 3]) } "}
{"_id":"q-en-rust-967d4587c96ae89db5e0c8387e349918baf5ada2274601c0e8144cb481245981","text":"#[derive(Copy, Clone)] pub struct Quad { a: u64, b: u64, c: u64, d: u64 } #[derive(Copy, Clone)] pub struct QuadFloats { a: f32, b: f32, c: f32, d: f32 } #[repr(C)] #[derive(Copy, Clone)] pub struct Floats { a: f64, b: u8, c: f64 }"}
{"_id":"q-en-rust-967d761536f9f624c4011cde0d78ec6de11d3bfb430c32fa3ba4d1795284d55c","text":"#[doc(keyword = \"CookieMonster\")] pub mod keyword {} /// Just some type alias. pub type SomeType = u32; "}
{"_id":"q-en-rust-96f878071f8ed91f1beac421fd106df256abbceef9f2f69fe313e9311a1b31ca","text":"} }; if let Some(path) = path && let Ok(mut out) = crate::fs::File::options().create(true).append(true).open(&path) { write(&mut out, BacktraceStyle::full()); } if let Some(local) = set_output_capture(None) { write(&mut *local.lock().unwrap_or_else(|e| e.into_inner()), backtrace); write(&mut *local.lock().unwrap_or_else(|e| e.into_inner())); set_output_capture(Some(local)); } else if let Some(mut out) = panic_output() { write(&mut out, backtrace); write(&mut out); } }"}
{"_id":"q-en-rust-96ff70d36f9a86a98fa88ffddf590b5f3da4877a3fd334d9c5652afabd8f8955","text":" // aux-build:issue-66286.rs // Regression test for #66286. extern crate issue_66286; #[issue_66286::vec_ice] pub extern fn foo(_: Vec(u32)) -> u32 { //~^ ERROR: parenthesized type parameters may only be used with a `Fn` trait 0 } fn main() {} "}
{"_id":"q-en-rust-97012b5169c70a71eb10017b06cb61561a0891dda569f4b730880695e4bf9d40","text":"// option. This file may not be copied, modified, or distributed // except according to those terms. // ignore-android: FIXME(#9116) Bus error use std::mem; #[repr(packed)]"}
{"_id":"q-en-rust-9764cffd5b0ecfaa8f69fafdf87e473ee0145080a5513ac830ea2f67934abe06","text":"actual: Ty<'tcx>, ti: TopInfo<'tcx>, ) -> Option> { self.demand_eqtype_with_origin(&self.pattern_cause(ti, cause_span), expected, actual) let mut diag = self.demand_eqtype_with_origin(&self.pattern_cause(ti, cause_span), expected, actual)?; if let Some(expr) = ti.origin_expr { self.suggest_fn_call(&mut diag, expr, expected, |output| { self.can_eq(self.param_env, output, actual).is_ok() }); } Some(diag) } fn demand_eqtype_pat("}
{"_id":"q-en-rust-9775b20ffe0eb9261b568f8560db36445c6cc50d082c9f3f781f6421d37d265a","text":"infer::RelateOutputImplTypes(_) => \"mismatched types\", infer::MatchExpressionArm(_, _) => \"match arms have incompatible types\", infer::IfExpression(_) => \"if and else have incompatible types\", infer::IfExpressionWithNoElse(_) => \"if may be missing an else clause\", }; self.tcx.sess.span_err("}
{"_id":"q-en-rust-97920d9745b15a12b7d0d8a64c1afd68341cf0eee0df8b490bcbff5283a7e97d","text":" // The various #[inline(never)] annotations and std::hint::black_box calls are // an attempt to make unwinding as non-flaky as possible on i686-pc-windows-msvc. #[inline(never)] fn generate_backtrace(x: &u32) { std::hint::black_box(x); let bt = std::backtrace::Backtrace::force_capture(); println!(\"{}\", bt); std::hint::black_box(x); } #[inline(never)] fn fn_in_backtrace(x: &u32) { std::hint::black_box(x); generate_backtrace(x); std::hint::black_box(x); } fn main() { let x = &41; std::hint::black_box(x); fn_in_backtrace(x); std::hint::black_box(x); } "}
{"_id":"q-en-rust-97d517284db96bebeca19834b53c5f62df229657d49964953ebf6a281fc3335d","text":"); } else { // Trivial case: `T` needs an extra bound: `T: Bound`. let (sp, suggestion) = match super_traits { None => predicate_constraint( let (sp, suggestion) = match ( generics .params .iter() .filter( |p| !matches!(p.kind, hir::GenericParamKind::Type { synthetic: Some(_), ..}), ) .next(), super_traits, ) { (_, None) => predicate_constraint( generics, trait_ref.without_const().to_predicate(tcx).to_string(), ), Some((ident, bounds)) => match bounds { [.., bound] => ( bound.span().shrink_to_hi(), format!(\" + {}\", trait_ref.print_only_trait_path().to_string()), ), [] => ( ident.span.shrink_to_hi(), format!(\": {}\", trait_ref.print_only_trait_path().to_string()), ), }, (None, Some((ident, []))) => ( ident.span.shrink_to_hi(), format!(\": {}\", trait_ref.print_only_trait_path().to_string()), ), (_, Some((_, [.., bounds]))) => ( bounds.span().shrink_to_hi(), format!(\" + {}\", trait_ref.print_only_trait_path().to_string()), ), (Some(_), Some((_, []))) => ( generics.span.shrink_to_hi(), format!(\": {}\", trait_ref.print_only_trait_path().to_string()), ), }; err.span_suggestion_verbose("}
{"_id":"q-en-rust-97e50e8d079d3d8f8ceb0b52e286281de77e2d6d3c5104bfb081590e1e28c45e","text":"LLC_$(1)=$$(CFG_LLVM_INST_DIR_$(1))/bin/llc$$(X_$(1)) LLVM_ALL_COMPONENTS_$(1)=$$(shell \"$$(LLVM_CONFIG_$(1))\" --components) LLVM_VERSION_$(1)=$$(shell \"$$(LLVM_CONFIG_$(1))\" --version) endef"}
{"_id":"q-en-rust-97f2cbf2ad1edd12f89a181133c454920619a378555a9c679cee499e4a80362c","text":"/// assert_eq!(v.len(), 42); /// } /// ``` /// should be /// /// ```rust /// // should be /// fn foo(v: &[i32]) { /// assert_eq!(v.len(), 42); /// }"}
{"_id":"q-en-rust-98027f8125565fc865c324caeadf90e86a033a026c5a00911403b7dbcda842c6","text":" // Copyright 2018 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 or the MIT license // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. #![feature(conservative_impl_trait)] fn foo() -> impl Copy { foo } fn main() { foo(); } "}
{"_id":"q-en-rust-980d7f030d892694b33c3e08c636091011bde80e8752517ba81710c04e45de5e","text":"LL | foo::<_, L>([(); L + 1 + L]); | ^^^^^^^^^^^ error: aborting due to 5 previous errors error: unconstrained generic constant `{const expr}` --> $DIR/issue_114151.rs:17:5 | LL | foo::<_, L>([(); L + 1 + L]); | ^^^^^^^^^^^ | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: aborting due to 6 previous errors Some errors have detailed explanations: E0107, E0308. For more information about an error, try `rustc --explain E0107`."}
{"_id":"q-en-rust-980fafab5248679656d839e562ce5656600a5c1cee7811b2a01ed8b0d84b5fbb","text":"target_os = \"openbsd\", target_arch = \"aarch64\", no_elf_tls))] #[doc(hidden)] mod imp { use prelude::v1::*;"}
{"_id":"q-en-rust-981b13079f89610cb3380d7510b27ea87becc9cffe9e97da3d35926af069623e","text":" // 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 or the MIT license // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. fn main() { let mut array = [1, 2, 3]; //~^ ERROR cannot determine a type for this local variable: cannot determine the type of this integ let pie_slice = array.slice(1, 2); } "}
{"_id":"q-en-rust-984c27af0f3b93ce3522f5f6e42b74dc1ced4ffca72ae381fd4f60adf5fbc84c","text":"// handled below clean::ModuleItem(..) => {} // impls/tymethods have no control over privacy clean::ImplItem(..) | clean::TyMethodItem(..) => {} // trait impls for private items should be stripped clean::ImplItem(clean::Impl{ for_: clean::ResolvedPath{ id: ref for_id, .. }, .. }) => { if !self.exported_items.contains(for_id) { return None; } } clean::ImplItem(..) => {} // tymethods have no control over privacy clean::TyMethodItem(..) => {} } let fastreturn = match i.inner {"}
{"_id":"q-en-rust-984c87334b2ef8517af776162a872d75140772d595f7ba1c81241b6b3d033f7d","text":" // Previously, in addition to the real cause of the problem as seen below, // the compiler would tell the user: // // ``` // error[E0207]: the type parameter `T` is not constrained by the impl trait, self type, or // predicates // ``` // // With this test, we check that only the relevant error is emitted. trait Foo {} impl Foo for Bar {} //~ ERROR cannot find type `Bar` in this scope fn main() {} "}
{"_id":"q-en-rust-98747260d72fda2cced72558c85f638ff9b8219c32b1e8f6b2a7f29fe9757e2e","text":" pub trait MyTrait { type Assoc; } pub fn foo(_s: S, _t: T) where S: MyTrait, T: MyTrait, //~^ ERROR: expected one of `,` or `>`, found `==` //~| ERROR: this trait takes 0 generic arguments but 1 generic argument was supplied { } fn main() {} "}
{"_id":"q-en-rust-98cb5d336ee7c1c17377245480c0b3c2fe28de3f89cec96455c085b1de348f54","text":"let tokens = match *nt { Nonterminal::NtItem(ref item) => prepend_attrs(sess, &item.attrs, nt, item.tokens.as_ref()), Nonterminal::NtBlock(ref block) => convert_tokens(block.tokens.as_ref()), Nonterminal::NtStmt(ref stmt) => prepend_attrs(sess, stmt.attrs(), nt, stmt.tokens()), Nonterminal::NtStmt(ref stmt) => { let do_prepend = |tokens| prepend_attrs(sess, stmt.attrs(), nt, tokens); if let ast::StmtKind::Empty = stmt.kind { let tokens: TokenStream = tokenstream::TokenTree::token(token::Semi, stmt.span).into(); do_prepend(Some(&LazyTokenStream::new(tokens))) } else { do_prepend(stmt.tokens()) } } Nonterminal::NtPat(ref pat) => convert_tokens(pat.tokens.as_ref()), Nonterminal::NtTy(ref ty) => convert_tokens(ty.tokens.as_ref()), Nonterminal::NtIdent(ident, is_raw) => {"}
{"_id":"q-en-rust-98da410409623c2422723a5d235608ad82f0ef42b7b02db4fd69f46331593e11","text":"} bb0: { StorageLive(_2); // scope 0 at $DIR/issue-73223.rs:2:23: 2:30 ((_2 as Some).0: i32) = const 1_i32; // scope 0 at $DIR/issue-73223.rs:2:23: 2:30 discriminant(_2) = 1; // scope 0 at $DIR/issue-73223.rs:2:23: 2:30 _1 = ((_2 as Some).0: i32); // scope 0 at $DIR/issue-73223.rs:3:14: 3:15 StorageDead(_2); // scope 0 at $DIR/issue-73223.rs:5:6: 5:7 ((_3 as Some).0: i32) = _1; // scope 1 at $DIR/issue-73223.rs:7:22: 7:27 StorageLive(_1); // scope 0 at $DIR/issue-73223.rs:2:23: 2:30 ((_1 as Some).0: i32) = const 1_i32; // scope 0 at $DIR/issue-73223.rs:2:23: 2:30 discriminant(_1) = 1; // scope 0 at $DIR/issue-73223.rs:2:23: 2:30 _2 = ((_1 as Some).0: i32); // scope 0 at $DIR/issue-73223.rs:3:14: 3:15 StorageDead(_1); // scope 0 at $DIR/issue-73223.rs:5:6: 5:7 ((_3 as Some).0: i32) = _2; // scope 1 at $DIR/issue-73223.rs:7:22: 7:27 discriminant(_3) = 1; // scope 1 at $DIR/issue-73223.rs:7:17: 7:28 (_4.0: &i32) = &_1; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL (_4.0: &i32) = &_2; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL (_4.1: &i32) = const main::promoted[1]; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL // ty::Const // + ty: &i32"}
{"_id":"q-en-rust-98ef3f188d5702529fce9353062d6979c18de5abd71a1f9f11f540bea37b3d0e","text":"// Create generics from the generics specified in the impl head. debug!(\"convert: ast_generics={:?}\", generics); let def_id = ccx.tcx.map.local_def_id(it.id); let ty_generics = ty_generics_for_type_or_impl(ccx, generics); let ty_generics = ty_generics_for_impl(ccx, generics); let mut ty_predicates = ty_generic_predicates_for_type_or_impl(ccx, generics); debug!(\"convert: impl_bounds={:?}\", ty_predicates);"}
{"_id":"q-en-rust-98fd8470f0fa04f374dab8de32093ac13d46cc82e5151353b4ee66e3a9cfc39c","text":" // Test for #78438: ensure underline alignment with many tabs on the left, long line on the right // ignore-tidy-linelength // ignore-tidy-tab fn main() { let money = 42i32; match money { v @ 1 | 2 | 3 => panic!(\"You gave me too little money {}\", v), // Long text here: TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT //~^ ERROR variable `v` is not bound in all patterns v => println!(\"Enough money {}\", v), } } "}
{"_id":"q-en-rust-99435767189c6292b7f996e187992b261db742e5ecf70838937104b9863499e8","text":"#[stable(feature = \"rust1\", since = \"1.0.0\")] pub use self::mutex::{Mutex, MutexGuard}; #[stable(feature = \"rust1\", since = \"1.0.0\")] #[allow(deprecated)] pub use self::once::{Once, OnceState, ONCE_INIT}; #[stable(feature = \"rust1\", since = \"1.0.0\")] pub use crate::sys_common::poison::{PoisonError, TryLockError, TryLockResult, LockResult};"}
{"_id":"q-en-rust-995f9bd299b34b8865670ecc7f24a6abc3a21dc62436f45501ba4bfd4d024743","text":"let mut lifetime_to_bounds: FxHashMap<_, FxHashSet<_>> = Default::default(); let mut ty_to_traits: FxHashMap> = Default::default(); let mut ty_to_fn: FxHashMap, Option)> = Default::default(); let mut ty_to_fn: FxHashMap)> = Default::default(); for p in clean_where_predicates { let (orig_p, p) = (p, p.clean(self.cx));"}
{"_id":"q-en-rust-998ce5a7fc5ed73a10b07a8b3a4a98420af6e34d65033f17b5cc9096023128a4","text":"if let mir::PlaceRef { base: &PlaceBase::Static(box Static { kind: StaticKind::Promoted(promoted, _), kind: StaticKind::Promoted(promoted, substs), ty, def_id: _, def_id, }), projection: &[], } = place.as_ref() { let c = bx.tcx().const_eval_promoted(self.instance, promoted); let c = bx.tcx().const_eval_promoted( Instance::new(def_id, self.monomorphize(&substs)), promoted, ); let (llval, ty) = self.simd_shuffle_indices( &bx, terminator.source_info.span,"}
{"_id":"q-en-rust-999012b538eb07386801f970e976d709f9b01a8a370a52c0a89713dd16e224db","text":"use crate::errors::OpaqueHiddenTypeDiag; use crate::infer::{DefiningAnchor, InferCtxt, InferOk}; use crate::traits; use hir::def::DefKind; use hir::def_id::{DefId, LocalDefId}; use hir::{HirId, OpaqueTyOrigin}; use rustc_data_structures::sync::Lrc;"}
{"_id":"q-en-rust-99a58b41e386ad42e1c1caf94bb987a25f615e80bb60350708b01c0f48fbbf7d","text":" struct RGB { g: f64, b: f64, } fn main() { let (r, alone_in_path, b): (f32, f32, f32) = (e.clone(), e.clone()); //~^ ERROR cannot find value `e` in this scope //~| ERROR cannot find value `e` in this scope //~| ERROR mismatched types let _ = RGB { r, g, b }; //~^ ERROR cannot find value `g` in this scope //~| ERROR struct `RGB` has no field named `r` //~| ERROR mismatched types } "}
{"_id":"q-en-rust-99e8fdd487264f4961f91d4b1db0f3021a382901510efc39a03ff14b12418de7","text":" macro_rules! many_args { ([$($t:tt)*]#$($h:tt)*) => { many_args!{[$($t)*$($t)*]$($h)*} }; ([$($t:tt)*]) => { fn _f($($t: ()),*) {} //~ ERROR function can not have more than 65535 arguments } } many_args!{[_]########## ######} fn main() {} "}
{"_id":"q-en-rust-99efb1d3836dfc4d88452875ba8fdddb45b56e7a96c462d4ea579d0f57b5e99c","text":"} item_mac(ref m) => { // FIXME #2888: we might actually want to do something here. item_mac(copy *m) // ... okay, we're doing something. It would probably be nicer // to add something to the ast_fold trait, but I'll defer // that work. item_mac(fold_mac_(m,fld)) } } }"}
{"_id":"q-en-rust-99fe33717729c7a7cde21babe9bdddecc8c7cff6b96a039cd121ad5249dd4b83","text":" error: internal compiler error error: internal compiler error encountered ... with incompatible types: left-hand side has type: >::Item right-hand side has type: usize --> $DIR/select-param-env-instead-of-blanket.rs:42:5 | LL | let mut x: >::Item = bar::(); | ---------- in this inlined function call ... LL | 0usize | ^^^^^^ | = note: delayed at compiler/rustc_const_eval/src/transform/validate.rs:128:36 thread 'rustc' panicked "}
{"_id":"q-en-rust-9a54589799f65ca17772a5911f76204ddba6361d869e2b6312b894d2960a6c93","text":"} } #[stable(feature = \"rust1\", since = \"1.0.0\")] impl Write for File { impl Write for &File { fn write(&mut self, buf: &[u8]) -> io::Result { self.inner.write(buf) }"}
{"_id":"q-en-rust-9a70068f3c3b7f315509caa1b30288e6bb037254cb946fac7223167a489f50b5","text":" #![doc(html_logo_url = \"https://raw.githubusercontent.com/sagebind/isahc/master/media/isahc.svg.png\")] // Note: this test is paired with logo-class-default.rs. // @has logo_class/struct.SomeStruct.html '//*[@class=\"logo-container\"]/img[@src=\"https://raw.githubusercontent.com/sagebind/isahc/master/media/isahc.svg.png\"]' '' // @!has logo_class/struct.SomeStruct.html '//*[@class=\"logo-container\"]/img[@class=\"rust-logo\"]' '' // // @has logo_class/struct.SomeStruct.html '//*[@class=\"sub-logo-container\"]/img[@src=\"https://raw.githubusercontent.com/sagebind/isahc/master/media/isahc.svg.png\"]' '' // @!has logo_class/struct.SomeStruct.html '//*[@class=\"sub-logo-container\"]/img[@class=\"rust-logo\"]' '' pub struct SomeStruct; "}
{"_id":"q-en-rust-9a72f6281b069ce56204eb6702e865405e1be5beabc98814d7c4b1e931a5a7e8","text":" warning: the feature `non_lifetime_binders` is incomplete and may not be safe to use and/or cause compiler crashes --> $DIR/unifying-placeholders-in-query-response-2.rs:5:12 | LL | #![feature(non_lifetime_binders)] | ^^^^^^^^^^^^^^^^^^^^ | = note: see issue #108185 for more information = note: `#[warn(incomplete_features)]` on by default warning: 1 warning emitted "}
{"_id":"q-en-rust-9a7fd2d89e1fad0c81cbdf730af0b05a6fa88fd16d9483a14beb2dd17330b8f8","text":" // 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. // The Computer Language Benchmarks Game // http://benchmarksgame.alioth.debian.org/ // // Licensed under the Apache License, Version 2.0 or the MIT license // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. // contributed by the Rust Project Developers // Copyright (c) 2012-2014 The Rust Project Developers // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // // - Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // // - Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in // the documentation and/or other materials provided with the // distribution. // // - Neither the name of \"The Computer Language Benchmarks Game\" nor // the name of \"The Computer Language Shootout Benchmarks\" nor the // names of its contributors may be used to endorse or promote // products derived from this software without specific prior // written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED // OF THE POSSIBILITY OF SUCH DAMAGE. #![feature(phase)] #[phase(plugin)] extern crate green;"}
{"_id":"q-en-rust-9aa747c886ba67ed723b04e24310fff65f219cd40a8cf045bdb8ebd0e53993e1","text":"} } // See comments in `interpolated_to_tokenstream` for why we care about // *probably* equal here rather than actual equality // // This is otherwise the same as `eq_unspanned`, only recursing with a // different method. pub fn probably_equal_for_proc_macro(&self, other: &TokenTree) -> bool { match (self, other) { (&TokenTree::Token(_, ref tk), &TokenTree::Token(_, ref tk2)) => { tk.probably_equal_for_proc_macro(tk2) } (&TokenTree::Delimited(_, ref dl), &TokenTree::Delimited(_, ref dl2)) => { dl.delim == dl2.delim && dl.stream().probably_equal_for_proc_macro(&dl2.stream()) } (_, _) => false, } } /// Retrieve the TokenTree's span. pub fn span(&self) -> Span { match *self {"}
{"_id":"q-en-rust-9aadddc8e55230bea5a7f39939d643549395a2c39592ac3948c71d146c50416e","text":"let mut buf = [0; 2]; self.code_points.next().map(|code_point| { let c = unsafe { char::from_u32_unchecked(code_point.value) }; let n = c.encode_utf16(&mut buf).len(); let n = char::encode_utf16_raw(code_point.value, &mut buf).len(); if n == 2 { self.extra = buf[1]; }"}
{"_id":"q-en-rust-9ac6cc83698af6f9c586bac34fb886ba0af73c21b32e918d510a9d5ca3f9e5b8","text":"#![omit_gdb_pretty_printer_section] // ignore-android: FIXME(#10381) // min-lldb-version: 310 // aux-build:cross_crate_spans.rs"}
{"_id":"q-en-rust-9ad35718cef8166a1fd1e5ba251b14cfccb2c3d12ae631bd290960882905e9fd","text":"/// If the hash of the input doesn't match or no input is supplied via None, /// it is interpreted as an error and the corresponding enum variant is set. /// The return value signifies whether some kind of source is present. pub fn add_external_src(&self, src: Option) -> bool { pub fn add_external_src(&self, get_src: F) -> bool where F: FnOnce() -> Option { if *self.external_src.borrow() == ExternalSource::AbsentOk { let src = get_src(); let mut external_src = self.external_src.borrow_mut(); if let Some(src) = src { let mut hasher: StableHasher = StableHasher::new();"}
{"_id":"q-en-rust-9ad6931871f8c5f486b1ce778c44c750f5b088ca206156ef6d6e45519986f200","text":" #![feature(const_generics)] #![allow(incomplete_features)] struct Test(*const usize); type PassArg = (); unsafe extern \"C\" fn pass(args: PassArg) { println!(\"Hello, world!\"); } impl Test { pub fn call_me(&self) { //~^ ERROR: using function pointers as const generic parameters is forbidden self.0 = Self::trampiline:: as _ } unsafe extern \"C\" fn trampiline< Args: Sized, const IDX: usize, const FN: unsafe extern \"C\" fn(Args), //~^ ERROR: using function pointers as const generic parameters is forbidden >( args: Args, ) { FN(args) } } fn main() { let x = Test(); x.call_me::() } "}
{"_id":"q-en-rust-9af53743d4c0e3709a2bd747243c83639e44d503707124364dd744d82f116094","text":"#[stable(feature = \"unicode_encode_char\", since = \"1.15.0\")] #[inline] pub fn encode_utf16(self, dst: &mut [u16]) -> &mut [u16] { let mut code = self as u32; // SAFETY: each arm checks whether there are enough bits to write into unsafe { if (code & 0xFFFF) == code && !dst.is_empty() { // The BMP falls through (assuming non-surrogate, as it should) *dst.get_unchecked_mut(0) = code as u16; slice::from_raw_parts_mut(dst.as_mut_ptr(), 1) } else if dst.len() >= 2 { // Supplementary planes break into surrogates. code -= 0x1_0000; *dst.get_unchecked_mut(0) = 0xD800 | ((code >> 10) as u16); *dst.get_unchecked_mut(1) = 0xDC00 | ((code as u16) & 0x3FF); slice::from_raw_parts_mut(dst.as_mut_ptr(), 2) } else { panic!( \"encode_utf16: need {} units to encode U+{:X}, but the buffer has {}\", from_u32_unchecked(code).len_utf16(), code, dst.len(), ) } } encode_utf16_raw(self as u32, dst) } /// Returns `true` if this `char` has the `Alphabetic` property."}
{"_id":"q-en-rust-9b0e6cb5caa2c5a534fc7748fe8654e5c2d755ebcc0312dded109b0caa5e586d","text":".lifetime_ribs .iter() .rev() .take_while(|rib| !matches!(rib.kind, LifetimeRibKind::Item)) .take_while(|rib| { !matches!(rib.kind, LifetimeRibKind::Item | LifetimeRibKind::ConstParamTy) }) .flat_map(|rib| rib.bindings.iter()) .map(|(&ident, &res)| (ident, res)) .filter(|(ident, _)| ident.name != kw::UnderscoreLifetime)"}
{"_id":"q-en-rust-9b24e04338b56b3bdc07a8eee5223e694c19dd35b54ae20344fb0b25a11572a6","text":"/// both arguments were negative, then it is -0.0. Subtraction `a - b` is /// regarded as a sum `a + (-b)`. /// /// For more information on floating point numbers, see [Wikipedia][wikipedia]. /// For more information on floating-point numbers, see [Wikipedia][wikipedia]. /// /// *[See also the `std::f32::consts` module](crate::f32::consts).* ///"}
{"_id":"q-en-rust-9b66978004e6c3dd8adc6b45dead2b7f5a46767f3c972662e0499cd5828ae748","text":"\"num_cpus\", \"ordslice\", \"racer\", \"rand 0.6.1\", \"rand 0.7.0\", \"rayon\", \"regex\", \"rls-analysis\","}
{"_id":"q-en-rust-9ba801badb2f99b1e076943b4b95922617ddd9ee9a6fb18165fe900dbb743b31","text":"AR_x86_64_pc_solaris=x86_64-pc-solaris2.10-ar CC_x86_64_pc_solaris=x86_64-pc-solaris2.10-gcc CXX_x86_64_pc_solaris=x86_64-pc-solaris2.10-g++ AR_x86_64_sun_solaris=x86_64-sun-solaris2.10-ar CC_x86_64_sun_solaris=x86_64-sun-solaris2.10-gcc CXX_x86_64_sun_solaris=x86_64-sun-solaris2.10-g++ CC_armv7_unknown_linux_gnueabi=arm-linux-gnueabi-gcc-8 CXX_armv7_unknown_linux_gnueabi=arm-linux-gnueabi-g++-8 AR_x86_64_fortanix_unknown_sgx=ar "}
{"_id":"q-en-rust-9bbda2951bd1d422a0299f321743b1ffc80223d3d2b4feb84ae91e1615131b62","text":" // edition:2018 use std::sync::{Arc, Mutex}; pub async fn f(_: ()) {} pub async fn run() { let x: Arc> = unimplemented!(); f(*x.lock().unwrap()).await; } "}
{"_id":"q-en-rust-9bd02be5993ae69dcc6fc8a67da4388fd1f04a3f90abe5543b6da7551fd0a474","text":"E0242, // internal error looking up a definition E0245, // not a trait // E0246, // invalid recursive type // E0247, // E0319, // trait impls for defaulted traits allowed just for structs/enums E0320, // recursive overflow during dropck E0328, // cannot implement Unsize explicitly"}
{"_id":"q-en-rust-9c2a02b70ad762a087fc107d73f3d567496a2772e37f2af11e76a1322ddd462f","text":" #![feature(inherent_associated_types)] #![allow(incomplete_features)] // Check that we don't crash when printing inherent projections in diagnostics. struct Foo(T); impl<'a> Foo { type Assoc = &'a (); } fn main(_: for<'a> fn(Foo::Assoc)) {} //~ ERROR `main` function has wrong type "}
{"_id":"q-en-rust-9c38ffb4f1682791f9e4c52be21beb64a572a3715c82ce3e51fe7dc9539f2a27","text":"{ eprintln!( \" Couldn't find required command: ninja You should install ninja, or set `ninja=false` in config.toml in the `[llvm]` section. Couldn't find required command: ninja (or ninja-build) You should install ninja as described at , or set `ninja = false` in the `[llvm]` section of `config.toml`. Alternatively, set `download-ci-llvm = true` in that `[llvm]` section to download LLVM rather than building it. \" ); std::process::exit(1);"}
{"_id":"q-en-rust-9c3d8dbdf4c94ca9946816f3289f9c8c98efa1a2a0ba3aaa8d41ea330f4a8c0a","text":"} } let inner = (self.inner)(); let prev = unsafe { let prev = self.inner.get(); self.inner.set(t as *const T as *mut T); let prev = inner.get(); inner.set(t as *const T as *mut T); prev }; let _reset = Reset { key: &self.inner, val: prev }; let _reset = Reset { key: inner, val: prev }; cb() }"}
{"_id":"q-en-rust-9c41685c791a54d548dc0cc3b539baa069711c2b6d312d0da5700f30e66785cb","text":" error[E0185]: method `example` has a `&self` declaration in the impl, but not in the trait --> $DIR/argument_number_mismatch_ice.rs:8:5 | LL | fn example(val: ()); | -------------------- trait method declared without `&self` ... LL | fn example(&self, input: &i32) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `&self` used in impl error[E0594]: cannot assign to `*input`, which is behind a `&` reference --> $DIR/argument_number_mismatch_ice.rs:10:9 | LL | *input = self.0; | ^^^^^^^^^^^^^^^ `input` is a `&` reference, so the data it refers to cannot be written error: aborting due to 2 previous errors Some errors have detailed explanations: E0185, E0594. For more information about an error, try `rustc --explain E0185`. "}
{"_id":"q-en-rust-9c7838ddd99d6cbfe697d6943ad5dad9600779f9b66223b84cfb63488ad713ca","text":" // Doc links in `Trait`'s methods are resolved because it has a local impl. // aux-build:issue-103463-aux.rs extern crate issue_103463_aux; use issue_103463_aux::Trait; pub struct LocalType; impl Trait for LocalType { fn method() {} } fn main() {} "}
{"_id":"q-en-rust-9c973633c63d645c0de540c346f0fb7d566b555b01b7ffce3a078ac27910736e","text":" pub trait Bar: Super {} pub trait Super { type SuperAssoc; } pub trait Bound {} "}
{"_id":"q-en-rust-9cb4e06e5de7b1053963f56b583e46b89ca1ac5cd753e9381625087643bfc1f0","text":"fn read_le_u16(r: &mut dyn io::Read) -> io::Result { let mut b = [0; 2]; let mut amt = 0; while amt < b.len() { match r.read(&mut b[amt..])? { 0 => return Err(io::Error::new(io::ErrorKind::Other, \"end of file\")), n => amt += n, } } r.read_exact(&mut b)?; Ok((b[0] as u16) | ((b[1] as u16) << 8)) } fn read_le_u32(r: &mut dyn io::Read) -> io::Result { let mut b = [0; 4]; r.read_exact(&mut b)?; Ok((b[0] as u32) | ((b[1] as u32) << 8) | ((b[2] as u32) << 16) | ((b[3] as u32) << 24)) } fn read_byte(r: &mut dyn io::Read) -> io::Result { match r.bytes().next() { Some(s) => s,"}
{"_id":"q-en-rust-9cf02169926092446c27231c4f3c5b47b8a0683ae82af46a2e9ac1f56bba5d36","text":" // run-rustfix fn main() { for _ in 0..=255 as u8 {} //~ ERROR range endpoint is out of range for _ in 0..=(255 as u8) {} //~ ERROR range endpoint is out of range } "}
{"_id":"q-en-rust-9d221e51cd2a362807ba193adf36eef93ab7adb905f4c53cfb296695da84de41","text":"}, lt_op: |region| { match region { // ignore static regions ty::ReStatic => region, // Skip static and bound regions: they don't // require substitution. ty::ReStatic | ty::ReLateBound(..) => region, _ => { trace!(\"checking {:?}\", region); for (subst, p) in opaque_defn.substs.iter().zip(&generics.params) {"}
{"_id":"q-en-rust-9d2727da2c8464e422c1d1ca75c4404e61071660d0f9c6640c499dfd029d9a37","text":"// ensure struct variants get warning for their fields enum IJK { I, //~ ERROR variant is never used I, //~ ERROR variant is never constructed J { a: String, b: i32, //~ ERROR field is never used c: i32, //~ ERROR field is never used }, K //~ ERROR variant is never used K //~ ERROR variant is never constructed }"}
{"_id":"q-en-rust-9d4d9387ff864fe8cb730a2278b496141e29ce8c5776435a0c79168ff86a952f","text":" // run-rustfix pub enum struct Range { //~^ ERROR `enum` and `struct` are mutually exclusive Valid { begin: u32, len: u32, }, Out, } fn main() { } "}
{"_id":"q-en-rust-9dafe07c40f13e96791b3a04046d97cfd28a1a25152b8adeaf9edfe6e09f6411","text":" Subproject commit d1ddc34c4b23468f6d2bf553084834b104e16dde Subproject commit 8b6b5014fdad3a750f7242a6bfdcad83619498d4 "}
{"_id":"q-en-rust-9db789eb9ce0ad62e91b3e3b6ce649e5337381d0570b1f7163831c4db438eac9","text":"wShowWindow: 0, cbReserved2: 0, lpReserved2: ptr::null_mut(), hStdInput: c::INVALID_HANDLE_VALUE, hStdOutput: c::INVALID_HANDLE_VALUE, hStdError: c::INVALID_HANDLE_VALUE, hStdInput: ptr::null_mut(), hStdOutput: ptr::null_mut(), hStdError: ptr::null_mut(), } }"}
{"_id":"q-en-rust-9dcc9ff277f06ccc2008d1625a654ebe523c73b6526a464826f796ea179f3274","text":"// The first byte is special, only want bottom 5 bits for width 2, 4 bits // for width 3, and 3 bits for width 4 macro_rules! utf8_first_byte( ($byte:expr, $width:expr) => (($byte & (0x7F >> $width)) as uint) ($byte:expr, $width:expr) => (($byte & (0x7F >> $width)) as u32) ) // return the value of $ch updated with continuation byte $byte macro_rules! utf8_acc_cont_byte( ($ch:expr, $byte:expr) => (($ch << 6) | ($byte & 63u8) as uint) ($ch:expr, $byte:expr) => (($ch << 6) | ($byte & 63u8) as u32) ) static TAG_CONT_U8: u8 = 128u8; /// Converts a vector of bytes to a new utf-8 string. /// Any invalid utf-8 sequences are replaced with U+FFFD REPLACEMENT CHARACTER. /// /// # Example /// /// ```rust /// let input = bytes!(\"Hello \", 0xF0, 0x90, 0x80, \"World\"); /// let output = std::str::from_utf8_lossy(input); /// assert_eq!(output, ~\"Hello uFFFDWorld\"); /// ``` pub fn from_utf8_lossy(v: &[u8]) -> ~str { static REPLACEMENT: &'static [u8] = bytes!(0xEF, 0xBF, 0xBD); // U+FFFD in UTF-8 let mut i = 0u; let mut lastgood = 0u; let total = v.len(); fn unsafe_get(xs: &[u8], i: uint) -> u8 { unsafe { *xs.unsafe_ref(i) } } fn safe_get(xs: &[u8], i: uint, total: uint) -> u8 { if i >= total { 0 } else { unsafe_get(xs, i) } } let mut res = with_capacity(total); while i < total { let i_ = i; let byte = unsafe_get(v, i); i += 1; macro_rules! error(() => { unsafe { if lastgood != i_ { raw::push_bytes(&mut res, v.slice(lastgood, i_)); } lastgood = i; raw::push_bytes(&mut res, REPLACEMENT); } }) if byte < 128u8 { // lastgood handles this } else { let w = utf8_char_width(byte); match w { 2 => { if safe_get(v, i, total) & 192u8 != TAG_CONT_U8 { error!(); continue; } i += 1; } 3 => { match (byte, safe_get(v, i, total)) { (0xE0 , 0xA0 .. 0xBF) => (), (0xE1 .. 0xEC, 0x80 .. 0xBF) => (), (0xED , 0x80 .. 0x9F) => (), (0xEE .. 0xEF, 0x80 .. 0xBF) => (), _ => { error!(); continue; } } i += 1; if safe_get(v, i, total) & 192u8 != TAG_CONT_U8 { error!(); continue; } i += 1; } 4 => { match (byte, safe_get(v, i, total)) { (0xF0 , 0x90 .. 0xBF) => (), (0xF1 .. 0xF3, 0x80 .. 0xBF) => (), (0xF4 , 0x80 .. 0x8F) => (), _ => { error!(); continue; } } i += 1; if safe_get(v, i, total) & 192u8 != TAG_CONT_U8 { error!(); continue; } i += 1; if safe_get(v, i, total) & 192u8 != TAG_CONT_U8 { error!(); continue; } i += 1; } _ => { error!(); continue; } } } } unsafe { raw::push_bytes(&mut res, v.slice(lastgood, total)) }; res } /// Unsafe operations pub mod raw { use cast;"}
{"_id":"q-en-rust-9deb1b537161fb32e5ac314f2f8baba9428729c556265e3a50c13618a83dc80c","text":"debug!(\"Checking must_not_suspend for {}\", ty); match *ty.kind() { ty::Adt(..) if ty.is_box() => { let boxed_ty = ty.boxed_ty(); let descr_pre = &format!(\"{}boxed \", data.descr_pre); ty::Adt(_, args) if ty.is_box() => { let boxed_ty = args.type_at(0); let allocator_ty = args.type_at(1); check_must_not_suspend_ty( tcx, boxed_ty, hir_id, param_env, SuspendCheckData { descr_pre, ..data }, SuspendCheckData { descr_pre: &format!(\"{}boxed \", data.descr_pre), ..data }, ) || check_must_not_suspend_ty( tcx, allocator_ty, hir_id, param_env, SuspendCheckData { descr_pre: &format!(\"{}allocator \", data.descr_pre), ..data }, ) } ty::Adt(def, _) => check_must_not_suspend_def(tcx, def.did(), hir_id, data),"}
{"_id":"q-en-rust-9df88eaffe91b521d61220300e1a52154b9993dffab4f01fa30139bf8c1526cf","text":"impl_from!(u32 => f64, #[stable(feature = \"lossless_float_conv\", since = \"1.6.0\")]); // float -> float impl_from!(f16 => f32, #[stable(feature = \"lossless_float_conv\", since = \"1.6.0\")]); impl_from!(f16 => f64, #[stable(feature = \"lossless_float_conv\", since = \"1.6.0\")]); // FIXME(f16_f128): adding additional `From` impls for existing types breaks inference. See // impl_from!(f16 => f128, #[stable(feature = \"lossless_float_conv\", since = \"1.6.0\")]); impl_from!(f32 => f64, #[stable(feature = \"lossless_float_conv\", since = \"1.6.0\")]); impl_from!(f32 => f128, #[stable(feature = \"lossless_float_conv\", since = \"1.6.0\")]);"}
{"_id":"q-en-rust-9e02bfd478cef885fdfb27a53903ed3fafaf91a4c6f6548454ccb39262c540c7","text":"{ let start_len = buf.len(); let mut g = Guard { len: buf.len(), buf }; let ret; loop { if g.len == g.buf.len() { unsafe {"}
{"_id":"q-en-rust-9e0b9f540292e20bad7e5ba704e6ef639832edbe29830cdd82cdd0c2444d331c","text":"lint_improper_ctypes_char_reason = the `char` type has no C equivalent lint_improper_ctypes_dyn = trait objects have no C equivalent lint_improper_ctypes_enum_phantomdata = this enum contains a PhantomData field lint_improper_ctypes_enum_repr_help = consider adding a `#[repr(C)]`, `#[repr(transparent)]`, or integer `#[repr(...)]` attribute to this enum"}
{"_id":"q-en-rust-9e162534e483d8a9ca655cd19b09f3c2f78682a786d205bea9e8d4c1f2b84c87","text":"# riscv targets currently do not need a C compiler, as compiler_builtins # doesn't currently have it enabled, and the riscv gcc compiler is not # installed. ENV CC_mipsel_unknown_linux_musl=mipsel-openwrt-linux-gcc ENV CFLAGS_armv5te_unknown_linux_musleabi=\"-march=armv5te -marm -mfloat-abi=soft\" CFLAGS_arm_unknown_linux_musleabi=\"-march=armv6 -marm\" CFLAGS_arm_unknown_linux_musleabihf=\"-march=armv6 -marm -mfpu=vfp\" CFLAGS_armv7_unknown_linux_musleabihf=\"-march=armv7-a\" CC_mipsel_unknown_linux_musl=mipsel-openwrt-linux-gcc CC_mips_unknown_linux_musl=mips-openwrt-linux-gcc CC_mips64el_unknown_linux_muslabi64=mips64el-linux-gnuabi64-gcc CC_mips64_unknown_linux_muslabi64=mips64-linux-gnuabi64-gcc "}
{"_id":"q-en-rust-9e1d2a2303c81f7073398861f0abde8db72ebbba6b953f8bd2a9e0940764d146","text":"// option. This file may not be copied, modified, or distributed // except according to those terms. // error-pattern:mismatched types: expected `()`, found `bool` extern crate debug; fn main() { let a = if true { true }; //~^ ERROR if may be missing an else clause: expected `()`, found `bool` (expected (), found bool) println!(\"{:?}\", a); }"}
{"_id":"q-en-rust-9e25c16645d7fa93b937e53d96af3f86fcaff1d7f42a23f6d4e9206af25912f9","text":"use rustc_ast as ast; use rustc_ast::expand::allocator::AllocatorKind; use rustc_attr as attr; use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap}; use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap, FxIndexSet}; use rustc_data_structures::steal::Steal; use rustc_data_structures::svh::Svh; use rustc_data_structures::sync::Lrc;"}
{"_id":"q-en-rust-9e3779ba40badfef10340e5a4878404bd118f489f87b3f18b3c8188c14387641","text":" running 1 test test $DIR/test-no_std.rs - f (line 9) ... ok test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out "}
{"_id":"q-en-rust-9e597d288eb14fbc0185e3cab9554952acdf160c23579bcb59f08cd7e6036992","text":"#[stable(feature = \"rust1\", since = \"1.0.0\")] impl fmt::Debug for RangeFull { fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { fmt::Debug::fmt(\"..\", fmt) write!(fmt, \"..\") } }"}
{"_id":"q-en-rust-9e995627b614b1514bc0bcdc62ed1fd83f4912bc8029ef00bda261ab49664b6c","text":"// `PlaceMention` and `AscribeUserType` both evaluate the place, which must not // contain dangling references. PlaceContext::NonMutatingUse(NonMutatingUseContext::PlaceMention) | PlaceContext::NonUse(NonUseContext::AscribeUserTy) | PlaceContext::NonUse(NonUseContext::AscribeUserTy(_)) | PlaceContext::MutatingUse(MutatingUseContext::AddressOf) | PlaceContext::NonMutatingUse(NonMutatingUseContext::AddressOf) |"}
{"_id":"q-en-rust-9ed2e894b2f1a2985970a396be7e2ff4b3804c52b0250cb45c0db472edaeb412","text":"/// static START: Once = ONCE_INIT; /// ``` #[stable(feature = \"rust1\", since = \"1.0.0\")] #[rustc_deprecated( since = \"1.38.0\", reason = \"the `new` function is now preferred\", suggestion = \"Once::new()\", )] pub const ONCE_INIT: Once = Once::new(); // Four states that a Once can be in, encoded into the lower bits of `state` in"}
{"_id":"q-en-rust-9ef16e66879a654ef86eecc14ed9f4d9b998a77e3329b46560ba17bde9758bbe","text":"// are contravariant while return-position lifetimes are // covariant). _marker: PhantomData &'a ()>, // Ensure `Context` is `!Send` and `!Sync` in order to allow // for future `!Send` and / or `!Sync` fields. _marker2: PhantomData<*mut ()>, } impl<'a> Context<'a> {"}
{"_id":"q-en-rust-9ef6fdfa556b1d5716330a69bc5fdc85764b2cee730bd9be3b411d08a531996f","text":"self.check_pat_walk(&field.pat, field_ty, def_bm, true); } let mut unmentioned_fields = variant.fields .iter() .map(|field| field.ident.modern()) .filter(|ident| !used_fields.contains_key(&ident)) .collect::>(); if inexistent_fields.len() > 0 { let (field_names, t, plural) = if inexistent_fields.len() == 1 { (format!(\"a field named `{}`\", inexistent_fields[0].1), \"this\", \"\")"}
{"_id":"q-en-rust-9f0119031c9d620cbcea28fb07b638038f6e3eb7b5ad7dcb5819292030e05dce","text":" // check-fail // edition:2021 // known-bug: #88908 // This should pass, but seems to run into a TAIT bug. #![feature(type_alias_impl_trait)] use std::future::Future; trait Stream { type Item; } struct Empty(T); impl Stream for Empty { type Item = (); } fn empty() -> Empty { todo!() } trait X { type LineStream<'a, Repr>: Stream where Self: 'a; type LineStreamFut<'a,Repr>: Future> where Self: 'a; fn line_stream<'a,Repr>(&'a self) -> Self::LineStreamFut<'a,Repr>; } struct Y; impl X for Y { type LineStream<'a, Repr> = impl Stream; type LineStreamFut<'a, Repr> = impl Future> ; fn line_stream<'a, Repr>(&'a self) -> Self::LineStreamFut<'a, Repr> { async {empty()} } } fn main() {} "}
{"_id":"q-en-rust-9f372f31ec69d526d9fdb12227489f63bf93abe5300f1f97c60a202f2ef7899e","text":"use crate::traits; use rustc_hir as hir; use rustc_hir::lang_items::LangItem; use rustc_middle::ty::{self, Ty, TyCtxt, TypeVisitableExt}; use rustc_middle::ty::{ self, Ty, TyCtxt, TypeSuperVisitable, TypeVisitable, TypeVisitableExt, TypeVisitor, }; use rustc_middle::ty::{GenericArg, GenericArgKind, GenericArgsRef}; use rustc_span::def_id::{DefId, LocalDefId, CRATE_DEF_ID}; use rustc_span::{Span, DUMMY_SP};"}
{"_id":"q-en-rust-9f8657ce201782376359767d0f5e600e1ccca258700562f5e12566c7ff95aa43","text":" // Copyright 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 or the MIT license // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. // Regression test for issue #22655: This test should not lead to // infinite recursion. unsafe impl Send for Unique { } pub struct Unique { pointer: *const T, } pub struct Node { vals: V, edges: Unique>, } fn is_send() {} fn main() { is_send::>(); } "}
{"_id":"q-en-rust-9f8e8ddd3f235f52b25404a9e0c43690a9d6568e5615ec7734ea541cdba34b63","text":"ClosureKind::Coroutine(CoroutineKind::Desugared(_, CoroutineSource::Block)), .. } = move_spans && can_suggest_clone { self.suggest_cloning(err, ty, expr, None, Some(move_spans)); } else if self.suggest_hoisting_call_outside_loop(err, expr) { } else if self.suggest_hoisting_call_outside_loop(err, expr) && can_suggest_clone { // The place where the type moves would be misleading to suggest clone. // #121466 self.suggest_cloning(err, ty, expr, None, Some(move_spans));"}
{"_id":"q-en-rust-9f9cfac09ad524a283bcbccb6f17892aa9c139abd26d35f11be30ca9a74a8cde","text":"} fn write_valid_utf8_to_console(handle: c::HANDLE, utf8: &str) -> io::Result { debug_assert!(!utf8.is_empty()); let mut utf16 = [MaybeUninit::::uninit(); MAX_BUFFER_SIZE / 2]; let mut len_utf16 = 0; for (chr, dest) in utf8.encode_utf16().zip(utf16.iter_mut()) { *dest = MaybeUninit::new(chr); len_utf16 += 1; } // Safety: We've initialized `len_utf16` values. let utf16: &[u16] = unsafe { MaybeUninit::slice_assume_init_ref(&utf16[..len_utf16]) }; let utf8 = &utf8[..utf8.floor_char_boundary(utf16.len())]; let utf16: &[u16] = unsafe { // Note that this theoretically checks validity twice in the (most common) case // where the underlying byte sequence is valid utf-8 (given the check in `write()`). let result = c::MultiByteToWideChar( c::CP_UTF8, // CodePage c::MB_ERR_INVALID_CHARS, // dwFlags utf8.as_ptr() as c::LPCCH, // lpMultiByteStr utf8.len() as c::c_int, // cbMultiByte utf16.as_mut_ptr() as c::LPWSTR, // lpWideCharStr utf16.len() as c::c_int, // cchWideChar ); assert!(result != 0, \"Unexpected error in MultiByteToWideChar\"); // Safety: MultiByteToWideChar initializes `result` values. MaybeUninit::slice_assume_init_ref(&utf16[..result as usize]) }; let mut written = write_u16s(handle, &utf16)?;"}
{"_id":"q-en-rust-9fa6f3fe4415c30270e5b0de6bf1d9a34e99a2cca7882d379bd969ab4c7a14b6","text":" trait Trait { type Type; fn one(&self, val: impl Trait); //~^ ERROR trait takes 1 generic argument but 0 generic arguments were supplied fn two>(&self) -> T; //~^ ERROR trait takes 1 generic argument but 0 generic arguments were supplied fn three(&self) -> T where T: Trait,; //~^ ERROR trait takes 1 generic argument but 0 generic arguments were supplied } fn main() {} "}
{"_id":"q-en-rust-9fb7959aaca6d8886413c002395593625e538149e9dbed7020fc062595436655","text":"/// /// [`to_ascii_lowercase`]: #method.to_ascii_lowercase #[stable(feature = \"ascii_methods_on_intrinsics\", since = \"1.23.0\")] #[rustc_const_unstable(feature = \"const_make_ascii\", issue = \"130698\")] #[rustc_const_stable(feature = \"const_make_ascii\", since = \"CURRENT_RUSTC_VERSION\")] #[inline] #[cfg_attr(bootstrap, rustc_allow_const_fn_unstable(const_mut_refs))] pub const fn make_ascii_lowercase(&mut self) { // FIXME(const-hack): We would like to simply iterate using `for` loops but this isn't currently allowed in constant expressions. let mut i = 0;"}
{"_id":"q-en-rust-9fb7b75c2924864535fc897059b384145df86fb4aec291b115fa8e80c15f56b6","text":" fn main() { super(); //~ ERROR failed to resolve: there are too many leading `super` keywords } "}
{"_id":"q-en-rust-9fc77912db91afbebab269877be6b0626295fc1531b29f91c40e96a8721190d0","text":"safety: Safety::Safe, }), }); let source_info = SourceInfo { span, scope: OUTERMOST_SOURCE_SCOPE }; // Some MIR passes will expect the number of parameters to match the // function declaration. for _ in 0..num_params { local_decls.push(LocalDecl::with_source_info(ty, source_info)); } cfg.terminate(START_BLOCK, source_info, TerminatorKind::Unreachable); let mut body = Body::new( MirSource::item(def.to_def_id()), MirSource::item(def_id.to_def_id()), cfg.basic_blocks, source_scopes, local_decls, IndexVec::new(), num_params, inputs.len(), vec![], span, coroutine_kind, Some(err), Some(guar), ); body.coroutine.as_mut().map(|gen| gen.yield_ty = Some(ty)); body.coroutine.as_mut().map(|gen| gen.yield_ty = yield_ty); body }"}
{"_id":"q-en-rust-a00840a7caacf7682f470ca6b4350c2322113fe752d3a67a2121c208b482ee49","text":"Ok(amount as usize) } #[allow(unused)] fn utf16_to_utf8(utf16: &[u16], utf8: &mut [u8]) -> io::Result { let mut written = 0; for chr in char::decode_utf16(utf16.iter().cloned()) { match chr { Ok(chr) => { chr.encode_utf8(&mut utf8[written..]); written += chr.len_utf8(); } Err(_) => { // We can't really do any better than forget all data and return an error. return Err(io::const_io_error!( io::ErrorKind::InvalidData, \"Windows stdin in console mode does not support non-UTF-16 input; encountered unpaired surrogate\", )); } } debug_assert!(utf16.len() <= c::c_int::MAX as usize); debug_assert!(utf8.len() <= c::c_int::MAX as usize); let result = unsafe { c::WideCharToMultiByte( c::CP_UTF8, // CodePage c::WC_ERR_INVALID_CHARS, // dwFlags utf16.as_ptr(), // lpWideCharStr utf16.len() as c::c_int, // cchWideChar utf8.as_mut_ptr() as c::LPSTR, // lpMultiByteStr utf8.len() as c::c_int, // cbMultiByte ptr::null(), // lpDefaultChar ptr::null_mut(), // lpUsedDefaultChar ) }; if result == 0 { // We can't really do any better than forget all data and return an error. Err(io::const_io_error!( io::ErrorKind::InvalidData, \"Windows stdin in console mode does not support non-UTF-16 input; encountered unpaired surrogate\", )) } else { Ok(result as usize) } Ok(written) } impl IncompleteUtf8 {"}
{"_id":"q-en-rust-a0351748c9cbf73d77aeccbb984243628302e70247d814c6850fe281764deec1","text":" error: expected one of `!` or `::`, found `` --> $DIR/test-compile-fail2.rs:3:1 | 3 | fail | ^^^^ expected one of `!` or `::` error: aborting due to previous error "}
{"_id":"q-en-rust-a04376a1f97b3f4d17a60a41d76f50be034dedd773e47ee7a991ac377c13ff07","text":"assert_eq!(nread, 1); assert_eq!(buf[0], 99); } Err(..) => fail!() Err(..) => fail!(), } } Err(..) => fail!()"}
{"_id":"q-en-rust-a062f7ce3b2b9a7bdac0fb4fef749dd2202138acbf0eade4624a3641b8e67b4c","text":"false } } fn ignore_llvm(config: &Config, line: &str) -> bool { if let Some(ref actual_version) = config.llvm_version { if line.contains(\"min-llvm-version\") { let min_version = line.trim() .split(' ') .last() .expect(\"Malformed llvm version directive\"); // Ignore if actual version is smaller the minimum required // version &actual_version[..] < min_version } else { false } } else { false } } } }"}
{"_id":"q-en-rust-a091d78f815bb06de57744cdfa326e57cfaf6f8c8a33a01a5707afbaea99d807","text":"// resolve Self::Foo, at the moment we can't resolve the former because // we don't have the trait information around, which is just sad. if !base_segments.is_empty() { let id_node = tcx.map.as_local_node_id(id).unwrap(); span_err!(tcx.sess, span, E0247, \"found module name used as a type: {}\", tcx.map.node_to_user_string(id_node)); return this.tcx().types.err; } assert!(base_segments.is_empty()); opt_self_ty.expect(\"missing T in ::a::b::c\") }"}
{"_id":"q-en-rust-a0df95f6c0155d1f330f444e6806b5c0ea06795206b068bd61f0d3707a12ce86","text":"use back::svh::Svh; use session::{config, Session}; use session::search_paths::PathKind; use metadata::common::rustc_version; use metadata::cstore; use metadata::cstore::{CStore, CrateSource, MetadataBlob}; use metadata::decoder;"}
{"_id":"q-en-rust-a0e58996ffd8f8577fa88f608132d77e514da3cb89e702eccb49e1446ebad497","text":"curl -L https://github.com/llvm/llvm-project/archive/$LLVM.tar.gz | tar xzf - --strip-components=1 yum install -y patch patch -Np1 < ../llvm-project-centos.patch mkdir clang-build cd clang-build"}
{"_id":"q-en-rust-a1362e96a8a083fc5b3f54b71abc29c89f21f7fc4965bf129e6fec78aecbe612","text":"/// # } /// ``` #[stable(feature = \"rust1\", since = \"1.0.0\")] #[inline] pub fn from_raw_os_error(code: i32) -> Error { Error { repr: Repr::Os(code) } }"}
{"_id":"q-en-rust-a156ca6ee613c9794abd139882a75ae03bd140a97d632d595ecbbbc440ccdd60","text":"LitKind::Int(_, LitIntType::Unsuffixed) => \"\", _ => bug!(), }; cx.emit_spanned_lint( OVERFLOWING_LITERALS, struct_expr.span, RangeEndpointOutOfRange { ty, suggestion: struct_expr.span, let sub_sugg = if expr.span.lo() == lit_span.lo() { let Ok(start) = cx.sess().source_map().span_to_snippet(eps[0].span) else { return false }; UseInclusiveRange::WithoutParen { sugg: struct_expr.span.shrink_to_lo().to(lit_span.shrink_to_hi()), start, literal: lit_val - 1, suffix, }, } } else { UseInclusiveRange::WithParen { eq_sugg: expr.span.shrink_to_lo(), lit_sugg: lit_span, literal: lit_val - 1, suffix, } }; cx.emit_spanned_lint( OVERFLOWING_LITERALS, struct_expr.span, RangeEndpointOutOfRange { ty, sub: sub_sugg }, ); // We've just emitted a lint, special cased for `(...)..MAX+1` ranges,"}
{"_id":"q-en-rust-a1ad6bfc925b78163dbc90c83afc69899ba8d4f5ed1e48fd9f78997a3598189e","text":"std::env::set_var(\"RUST_BACKTRACE\", \"full\"); } panic::set_hook(Box::new(move |info| { // If the error was caused by a broken pipe then this is not a bug. // Write the error and return immediately. See #98700. #[cfg(windows)] if let Some(msg) = info.payload().downcast_ref::() { if msg.starts_with(\"failed printing to stdout: \") && msg.ends_with(\"(os error 232)\") { // the error code is already going to be reported when the panic unwinds up the stack let handler = EarlyErrorHandler::new(ErrorOutputType::default()); let _ = handler.early_error_no_abort(msg.clone()); return; } }; // Invoke the default handler, which prints the actual panic message and optionally a backtrace // Don't do this for delayed bugs, which already emit their own more useful backtrace. if !info.payload().is::() { std::panic_hook_with_disk_dump(info, ice_path().as_deref()); panic::update_hook(Box::new( move |default_hook: &(dyn Fn(&PanicInfo<'_>) + Send + Sync + 'static), info: &PanicInfo<'_>| { // If the error was caused by a broken pipe then this is not a bug. // Write the error and return immediately. See #98700. #[cfg(windows)] if let Some(msg) = info.payload().downcast_ref::() { if msg.starts_with(\"failed printing to stdout: \") && msg.ends_with(\"(os error 232)\") { // the error code is already going to be reported when the panic unwinds up the stack let handler = EarlyErrorHandler::new(ErrorOutputType::default()); let _ = handler.early_error_no_abort(msg.clone()); return; } }; // Separate the output with an empty line eprintln!(); } // Invoke the default handler, which prints the actual panic message and optionally a backtrace // Don't do this for delayed bugs, which already emit their own more useful backtrace. if !info.payload().is::() { default_hook(info); // Separate the output with an empty line eprintln!(); if let Some(ice_path) = ice_path() && let Ok(mut out) = File::options().create(true).append(true).open(&ice_path) { // The current implementation always returns `Some`. let location = info.location().unwrap(); let msg = match info.payload().downcast_ref::<&'static str>() { Some(s) => *s, None => match info.payload().downcast_ref::() { Some(s) => &s[..], None => \"Box\", }, }; let thread = std::thread::current(); let name = thread.name().unwrap_or(\"\"); let _ = write!( &mut out, \"thread '{name}' panicked at {location}:n {msg}n stack backtrace:n {:#}\", std::backtrace::Backtrace::force_capture() ); } } // Print the ICE message report_ice(info, bug_report_url, extra_info); })); // Print the ICE message report_ice(info, bug_report_url, extra_info); }, )); } /// Prints the ICE message, including query stack, but without backtrace."}
{"_id":"q-en-rust-a1b0fa200d84ba83e99606ef7f40981ddfd4aaa3ad49018c878121957d5eef1b","text":"match expr.kind { hir::ExprKind::Index(ref base_expr, ref index_expr) => { let index_expr_ty = self.node_ty(index_expr.hir_id); // We need to get the final type in case dereferences were needed for the trait // to apply (#72002). let index_expr_ty = self.tables.borrow().expr_ty_adjusted(index_expr); self.convert_place_op_to_mutable( PlaceOp::Index, expr,"}
{"_id":"q-en-rust-a1c625df8c84dbb665cbe7a694ffc00b2ce70665d0e14f4bf290a3542918c55a","text":"/// /// # Safety /// /// The resulting pointer does not need to be in bounds, but it is /// potentially hazardous to dereference (which requires `unsafe`). /// This operation itself is always safe, but using the resulting pointer is not. /// /// The resulting pointer remains attached to the same allocated object that `self` points to. /// It may *not* be used to access a different allocated object. Note that in Rust, every /// (stack-allocated) variable is considered a separate allocated object. /// /// In other words, `let z = x.wrapping_add((y as usize) - (x as usize))` does *not* make `z` /// the same as `y` even if we assume `T` has size `1` and there is no overflow: `z` is still /// attached to the object `x` is attached to, and dereferencing it is Undefined Behavior unless /// `x` and `y` point into the same allocated object. /// /// In particular, the resulting pointer remains attached to the same allocated /// object that `self` points to. It may *not* be used to access a /// different allocated object. Note that in Rust, /// every (stack-allocated) variable is considered a separate allocated object. /// Compared to [`add`], this method basically delays the requirement of staying within the /// same allocated object: [`add`] is immediate Undefined Behavior when crossing object /// boundaries; `wrapping_add` produces a pointer but still leads to Undefined Behavior if a /// pointer is dereferenced when it is out-of-bounds of the object it is attached to. [`add`] /// can be optimized better and is thus preferable in performance-sensitive code. /// /// Compared to [`add`], this method basically delays the requirement of staying /// within the same allocated object: [`add`] is immediate Undefined Behavior when /// crossing object boundaries; `wrapping_add` produces a pointer but still leads /// to Undefined Behavior if that pointer is dereferenced. [`add`] can be optimized /// better and is thus preferable in performance-sensitive code. /// The delayed check only considers the value of the pointer that was dereferenced, not the /// intermediate values used during the computation of the final result. For example, /// `x.wrapping_add(o).wrapping_sub(o)` is always the same as `x`. In other words, leaving the /// allocated object and then re-entering it later is permitted. /// /// If you need to cross object boundaries, cast the pointer to an integer and /// do the arithmetic there."}
{"_id":"q-en-rust-a1c6539819c0f1f94754b5a3eb686e9b97609f45881bc83b20dc50993772bef1","text":"if trait_.def_id() == tcx.lang_items().deref_trait() { super::build_deref_target_impls(cx, &trait_items, ret); } // Return if the trait itself or any types of the generic parameters are doc(hidden). let mut stack: Vec<&Type> = trait_.iter().collect(); stack.push(&for_); while let Some(ty) = stack.pop() { if let Some(did) = ty.def_id() { if cx.tcx.get_attrs(did).lists(sym::doc).has_word(sym::hidden) { return; } } if let Some(generics) = ty.generics() { stack.extend(generics); } } if let Some(trait_did) = trait_.def_id() { record_extern_trait(cx, trait_did); }"}
{"_id":"q-en-rust-a202f8e24f8e25c61374d279d035679124a1fb6b954935bb0b64706eea015826","text":"}, }; let mut prev = eraser.fold_ty(ty); let mut prev_span = None; let mut prev_span: Option = None; for binding in expr_finder.uses { // In every expression where the binding is referenced, we will look at that"}
{"_id":"q-en-rust-a20e428af82974c83f78bc77be7d3742355f82d8e1b5e272ac1a9a76d2299ca6","text":"sp } fn ensure_filemap_source_present(&self, file_map: Rc) -> bool { let src = self.file_loader.read_file(Path::new(&file_map.name)).ok(); return file_map.add_external_src(src) file_map.add_external_src( || self.file_loader.read_file(Path::new(&file_map.name)).ok() ) } }"}
{"_id":"q-en-rust-a21b3b2d7da3c6ac1a55eb64b0948da421e3f1d35ced17110c2299866f1b1c3e","text":" error[E0015]: calls in constant functions are limited to constant functions, tuple structs and tuple variants --> $DIR/unstable-const-fn-in-libcore.rs:24:26 | LL | Opt::None => f(), | ^^^ error[E0493]: destructors cannot be evaluated at compile-time --> $DIR/unstable-const-fn-in-libcore.rs:19:53 | LL | const fn unwrap_or_else T>(self, f: F) -> T { | ^ constant functions cannot evaluate destructors error[E0493]: destructors cannot be evaluated at compile-time --> $DIR/unstable-const-fn-in-libcore.rs:19:47 | LL | const fn unwrap_or_else T>(self, f: F) -> T { | ^^^^ constant functions cannot evaluate destructors error: aborting due to 3 previous errors Some errors have detailed explanations: E0015, E0493. For more information about an error, try `rustc --explain E0015`. "}
{"_id":"q-en-rust-a24efe13733f807c953f2ae13733f92aa4a5c44a888fbec83cdf3ad2346b5982","text":"return noop_visit_attribute(at, self); } let filename = self.cx.resolve_path(&*file.as_str(), it.span()); let filename = match self.cx.resolve_path(&*file.as_str(), it.span()) { Ok(filename) => filename, Err(mut err) => { err.emit(); continue; } }; match self.cx.source_map().load_file(&filename) { Ok(source_file) => { let src = source_file.src.as_ref()"}
{"_id":"q-en-rust-a25e8ba0316bf14b24c0f114cd5cddfe4a2a25708fc2210c9c4c2820a4ff6279","text":"14 | println!(\"Hello, World!\"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: expands to `println! { \"Hello, World!\" }` = note: expands to `print! { concat ! ( \"Hello, World!\" , \"/n\" ) }` = note: expanding `println! { \"Hello, World!\" }` = note: to `print ! ( concat ! ( \"Hello, World!\" , \"/n\" ) )` = note: expanding `print! { concat ! ( \"Hello, World!\" , \"/n\" ) }` = note: to `$crate :: io :: _print ( format_args ! ( concat ! ( \"Hello, World!\" , \"/n\" ) ) )` "}
{"_id":"q-en-rust-a2758b9b1e22620c729fe6690090f83f342f595604fa09e3d46d6773f68ed07e","text":"ulimit -c unlimited fi # There was a bad interaction between \"old\" 32-bit binaries on current 64-bit # kernels with selinux enabled, where ASLR mmap would sometimes choose a low # address and then block it for being below `vm.mmap_min_addr` -> `EACCES`. # This is probably a kernel bug, but setting `ulimit -Hs` works around it. # See also `dist-i686-linux` where this setting is enabled. if [ \"$SET_HARD_RLIMIT_STACK\" = \"1\" ]; then rlimit_stack=$(ulimit -Ss) if [ \"$rlimit_stack\" != \"\" ]; then ulimit -Hs \"$rlimit_stack\" fi fi ci_dir=`cd $(dirname $0) && pwd` source \"$ci_dir/shared.sh\""}
{"_id":"q-en-rust-a2d8a07a286c14fc71dae175038c828db4b391b45d3cb9a878cfe685114c7d2e","text":"checksum = \"d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd\" [[package]] name = \"semver\" version = \"1.0.17\" source = \"registry+https://github.com/rust-lang/crates.io-index\" checksum = \"bebd363326d05ec3e2f532ab7660680f3b02130d780c299bca73469d521bc0ed\" [[package]] name = \"serde\" version = \"1.0.137\" source = \"registry+https://github.com/rust-lang/crates.io-index\""}
{"_id":"q-en-rust-a311852b364fe2dac282a4d1f8036a3fcda72dbef374dd374ab3caa364470496","text":" error[E0026]: variant `A::A` does not have a field named `fob` --> $DIR/issue-52717.rs:19:12 | LL | A::A { fob } => { println!(\"{}\", fob); } | ^^^ | | | variant `A::A` does not have this field | help: did you mean: `foo` error: aborting due to previous error For more information about this error, try `rustc --explain E0026`. "}
{"_id":"q-en-rust-a336b5a22fcac3c36893dfabf8f6280f322a414d3b5d00078fe562a5f3f5d818","text":"} }; let yielded = opt_expr.as_ref().map(|x| self.lower_expr(x)).unwrap_or_else(|| self.expr_unit(span)); if is_async_gen { // `yield $expr` is transformed into `task_context = yield async_gen_ready($expr)`. // This ensures that we store our resumed `ResumeContext` correctly, and also that"}
{"_id":"q-en-rust-a34b1dfbe4301ed4092cc4baaf5dcaff2e179fc99332d7e1cbb45b31e3745f98","text":"ty::Dynamic(ref data, ..) if data.principal_def_id().is_some() => { self.check_def_id(item, data.principal_def_id().unwrap()); } ty::Dynamic(..) => { struct_span_err!( self.tcx.sess, ty.span, E0785, \"cannot define inherent `impl` for a dyn auto trait\" ) .span_label(ty.span, \"impl requires at least one non-auto trait\") .note(\"define and implement a new trait or type instead\") .emit(); } ty::Bool => { self.check_primitive_impl( item.def_id,"}
{"_id":"q-en-rust-a34c9a4ac6e1de46093ac365a471622d84df5cb6b25d9839c4f0e9b4058cff30","text":"Some((destination, success)) }, from_hir_call, fn_span fn_span, }, ); success.unit()"}
{"_id":"q-en-rust-a34d2c0d6a763fb3fc97c408518257707d5152e95c9c53a3fd3d95e161890260","text":"/// # Example /// /// ```rust /// # #![allow(deprecated)] /// use url::encode; /// /// let url = encode(\"https://example.com/Rust (programming language)\");"}
{"_id":"q-en-rust-a4122a8f311d07af58ab34f8cbb37adc19bd4e7abce959975f7b868a0039f465","text":"} } fn int_ty_bits(int_ty: ast::IntTy) -> u64 { match int_ty { ast::TyI => int::BITS as u64, ast::TyI8 => i8::BITS as u64, ast::TyI16 => i16::BITS as u64, ast::TyI32 => i32::BITS as u64, ast::TyI64 => i64::BITS as u64 } } fn uint_ty_bits(uint_ty: ast::UintTy) -> u64 { match uint_ty { ast::TyU => uint::BITS as u64, ast::TyU8 => u8::BITS as u64, ast::TyU16 => u16::BITS as u64, ast::TyU32 => u32::BITS as u64, ast::TyU64 => u64::BITS as u64 } } fn check_limits(tcx: &ty::ctxt, binop: ast::BinOp, l: &ast::Expr, r: &ast::Expr) -> bool { let (lit, expr, swap) = match (&l.node, &r.node) {"}
{"_id":"q-en-rust-a4183c9880daa283f11bda1ba84ce9adcd47d8dfc53f9012549f5ee9e84da5d0","text":"/// # Example /// /// ```rust /// # #![allow(deprecated)] /// let query = vec![(\"title\".to_string(), \"The Village\".to_string()), /// (\"north\".to_string(), \"52.91\".to_string()), /// (\"west\".to_string(), \"4.10\".to_string())];"}
{"_id":"q-en-rust-a425ff874269111b610557605c028df4befcde41f3fbcd9ed7d5daa683605032","text":"synth_provided, } } else { let num_missing_args = expected_max - provided; // Check if associated type bounds are incorrectly written in impl block header like: // ``` // trait Foo {} // impl Foo for u8 {} // ``` let parent_is_impl_block = cx .tcx() .hir() .parent_owner_iter(seg.hir_id) .next() .is_some_and(|(_, owner_node)| owner_node.is_impl_block()); if parent_is_impl_block { let constraint_names: Vec<_> = gen_args.constraints.iter().map(|b| b.ident.name).collect(); let param_names: Vec<_> = gen_params .own_params .iter() .filter(|param| !has_self || param.index != 0) // Assumes `Self` will always be the first parameter .map(|param| param.name) .collect(); if constraint_names == param_names { // We set this to true and delay emitting `WrongNumberOfGenericArgs` // to provide a succinct error for cases like issue #113073 all_params_are_binded = true; }; } let constraint_names: Vec<_> = gen_args.constraints.iter().map(|b| b.ident.name).collect(); let param_names: Vec<_> = gen_params .own_params .iter() .filter(|param| !has_self || param.index != 0) // Assumes `Self` will always be the first parameter .map(|param| param.name) .collect(); if constraint_names == param_names { // We set this to true and delay emitting `WrongNumberOfGenericArgs` // to provide a succinct error for cases like issue #113073 all_params_are_binded = true; }; let num_missing_args = expected_max - provided; GenericArgsInfo::MissingTypesOrConsts { num_missing_args,"}
{"_id":"q-en-rust-a467c84f6561ef952ebed0664b51aa7186171d4cb7f1efc2f9c57508f272323b","text":"//@aux-build:proc_macro_attr.rs:proc-macro // Flaky test, see https://github.com/rust-lang/rust/issues/113585. //@ignore-32bit //@ignore-64bit #![warn(clippy::needless_arbitrary_self_type)]"}
{"_id":"q-en-rust-a46b547357d3d5565e8b68008765a8692161e3e371a8e25b99f855c695403eff","text":" error[E0308]: mismatched types --> $DIR/issue-117669.rs:2:20 | LL | let abs: i32 = 3i32.checked_abs(); | --- ^^^^^^^^^^^^^^^^^^ expected `i32`, found `Option` | | | expected due to this | = note: expected type `i32` found enum `Option` help: consider using `Option::expect` to unwrap the `Option` value, panicking if the value is an `Option::None` | LL | let abs: i32 = 3i32.checked_abs().expect(\"REASON\"); | +++++++++++++++++ error: aborting due to previous error For more information about this error, try `rustc --explain E0308`. "}
{"_id":"q-en-rust-a47ad4e589120bd32b7bd3f7ddb0980ee482ec66ef6a1652390f2bad3f4fb853","text":"/// # Examples /// /// ```no_run /// # #![feature(bufreader_buffer)] /// use std::io::{BufReader, BufRead}; /// use std::fs::File; ///"}
{"_id":"q-en-rust-a497242f111f376b5d82038348f459aebf21277bb68683b74471fbaaff1e129a","text":"traits::RepeatVec => { tcx.sess.span_note( obligation.cause.span, format!( \"the `Copy` trait is required because the repeated element will be copied\").as_slice()); \"the `Copy` trait is required because the repeated element will be copied\"); } traits::VariableType(_) => { tcx.sess.span_note( obligation.cause.span, \"all local variables must have a statically known size\"); } traits::ReturnType => { tcx.sess.span_note( obligation.cause.span, \"the return type of a function must have a statically known size\"); } traits::AssignmentLhsSized => { tcx.sess.span_note( obligation.cause.span,"}
{"_id":"q-en-rust-a4b62f2358e76a720fb1dd618135492f69bd3e5c06065130b921396d7c45c8f9","text":"let f1: f32 = FromStrRadix::from_str_radix(\"1p-123\", 16).unwrap(); let f2: f32 = FromStrRadix::from_str_radix(\"1p-111\", 16).unwrap(); let f3: f32 = FromStrRadix::from_str_radix(\"1.Cp-12\", 16).unwrap(); assert_eq!(Float::ldexp(1f32, -123), f1); assert_eq!(Float::ldexp(1f32, -111), f2); assert_eq!(1f32.ldexp(-123), f1); assert_eq!(1f32.ldexp(-111), f2); assert_eq!(Float::ldexp(1.75f32, -12), f3); assert_eq!(Float::ldexp(0f32, -123), 0f32);"}
{"_id":"q-en-rust-a4e8dc88c78e407d670fe28e937b4afb373df6532700562b27f721282c08b0b7","text":" error: an inner attribute is not permitted in this context --> $DIR/issue-89971-outer-attr-following-inner-attr-ice.rs:11:1 | LL | #![deny(missing_docs)] | ^^^^^^^^^^^^^^^^^^^^^^ ... LL | struct Mew(); | ------------- the inner attribute doesn't annotate this struct | = note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files help: to annotate the struct, change the attribute from inner to outer style | LL - #![deny(missing_docs)] LL + #[deny(missing_docs)] | error: aborting due to previous error "}
{"_id":"q-en-rust-a5261fce819135d2e62386b006710dc10c88fb761e13852cd7a21c4da565b082","text":" // run-rustfix // Regression test for changes introduced while fixing #54505 // This test uses non-literals for Ranges // (expecting no parens with borrow suggestion) use std::ops::RangeBounds; // take a reference to any built-in range fn take_range(_r: &impl RangeBounds) {} fn main() { take_range(&std::ops::Range { start: 0, end: 1 }); //~^ ERROR mismatched types [E0308] //~| HELP consider borrowing here //~| SUGGESTION &std::ops::Range { start: 0, end: 1 } take_range(&::std::ops::Range { start: 0, end: 1 }); //~^ ERROR mismatched types [E0308] //~| HELP consider borrowing here //~| SUGGESTION &::std::ops::Range { start: 0, end: 1 } take_range(&std::ops::RangeFrom { start: 1 }); //~^ ERROR mismatched types [E0308] //~| HELP consider borrowing here //~| SUGGESTION &std::ops::RangeFrom { start: 1 } take_range(&::std::ops::RangeFrom { start: 1 }); //~^ ERROR mismatched types [E0308] //~| HELP consider borrowing here //~| SUGGESTION &::std::ops::RangeFrom { start: 1 } take_range(&std::ops::RangeFull {}); //~^ ERROR mismatched types [E0308] //~| HELP consider borrowing here //~| SUGGESTION &std::ops::RangeFull {} take_range(&::std::ops::RangeFull {}); //~^ ERROR mismatched types [E0308] //~| HELP consider borrowing here //~| SUGGESTION &::std::ops::RangeFull {} take_range(&std::ops::RangeInclusive::new(0, 1)); //~^ ERROR mismatched types [E0308] //~| HELP consider borrowing here //~| SUGGESTION &std::ops::RangeInclusive::new(0, 1) take_range(&::std::ops::RangeInclusive::new(0, 1)); //~^ ERROR mismatched types [E0308] //~| HELP consider borrowing here //~| SUGGESTION &::std::ops::RangeInclusive::new(0, 1) take_range(&std::ops::RangeTo { end: 5 }); //~^ ERROR mismatched types [E0308] //~| HELP consider borrowing here //~| SUGGESTION &std::ops::RangeTo { end: 5 } take_range(&::std::ops::RangeTo { end: 5 }); //~^ ERROR mismatched types [E0308] //~| HELP consider borrowing here //~| SUGGESTION &::std::ops::RangeTo { end: 5 } take_range(&std::ops::RangeToInclusive { end: 5 }); //~^ ERROR mismatched types [E0308] //~| HELP consider borrowing here //~| SUGGESTION &std::ops::RangeToInclusive { end: 5 } take_range(&::std::ops::RangeToInclusive { end: 5 }); //~^ ERROR mismatched types [E0308] //~| HELP consider borrowing here //~| SUGGESTION &::std::ops::RangeToInclusive { end: 5 } } "}
{"_id":"q-en-rust-a59b55158a5dc95af18830535c9a5b67b71ebc36b21683f3a0abd8ccd90dff66","text":" error[E0107]: trait takes 1 generic argument but 0 generic arguments were supplied --> $DIR/name-same-as-generic-type-issue-128249.rs:4:30 | LL | fn one(&self, val: impl Trait); | ^^^^^ expected 1 generic argument | note: trait defined here, with 1 generic parameter: `Type` --> $DIR/name-same-as-generic-type-issue-128249.rs:1:7 | LL | trait Trait { | ^^^^^ ---- help: add missing generic argument | LL | fn one(&self, val: impl Trait); | +++++ error[E0107]: trait takes 1 generic argument but 0 generic arguments were supplied --> $DIR/name-same-as-generic-type-issue-128249.rs:7:15 | LL | fn two>(&self) -> T; | ^^^^^ expected 1 generic argument | note: trait defined here, with 1 generic parameter: `Type` --> $DIR/name-same-as-generic-type-issue-128249.rs:1:7 | LL | trait Trait { | ^^^^^ ---- help: add missing generic argument | LL | fn two>(&self) -> T; | +++++ error[E0107]: trait takes 1 generic argument but 0 generic arguments were supplied --> $DIR/name-same-as-generic-type-issue-128249.rs:11:12 | LL | T: Trait,; | ^^^^^ expected 1 generic argument | note: trait defined here, with 1 generic parameter: `Type` --> $DIR/name-same-as-generic-type-issue-128249.rs:1:7 | LL | trait Trait { | ^^^^^ ---- help: add missing generic argument | LL | T: Trait,; | +++++ error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0107`. "}
{"_id":"q-en-rust-a5b01cc1350dd90d729b4df8d842cd3fe0a568cb45ae72dee075af8602658761","text":".emit(); } EscapeError::MoreThanOneChar => { let msg = if mode.is_bytes() { \"if you meant to write a byte string literal, use double quotes\" } else { \"if you meant to write a `str` literal, use double quotes\" }; handler .struct_span_err( span_with_quotes,"}
{"_id":"q-en-rust-a5b534aecad274f798d8c37383a0bb35eba267e6b48b2d0b9df28b7745288e9b","text":"#[stable(feature = \"ip_u32\", since = \"1.1.0\")] impl From for u32 { /// It performs the conversion in network order (big-endian). fn from(ip: Ipv4Addr) -> u32 { let ip = ip.octets(); ((ip[0] as u32) << 24) + ((ip[1] as u32) << 16) + ((ip[2] as u32) << 8) + (ip[3] as u32)"}
{"_id":"q-en-rust-a5be1f5f338d7407f11783dd269bc2d0937f2ae62b22f12a1ea33b6a961d3aa3","text":"// it. We do not write to `self` nor reborrow to a mutable reference. // Hence the raw pointer we created above, for `deque`, remains valid. let ring = self.buffer_as_slice(); let iter = Iter::new(ring, drain_tail, drain_head); Drain::new(drain_head, head, iter, deque) Drain::new(drain_head, head, ring, drain_tail, drain_head, deque) } }"}
{"_id":"q-en-rust-a641f4fc59fccff35daff2ae299ead667d74991b740c6c53db940648d7ea4397","text":".map(|v| v.parse().expect(\"failed to parse rust.llvm-libunwind\")); if let Some(ref backends) = rust.codegen_backends { config.rust_codegen_backends = backends.iter().map(|s| INTERNER.intern_str(s)).collect(); let available_backends = vec![\"llvm\", \"cranelift\", \"gcc\"]; config.rust_codegen_backends = backends.iter().map(|s| { if let Some(backend) = s.strip_prefix(CODEGEN_BACKEND_PREFIX) { if available_backends.contains(&backend) { panic!(\"Invalid value '{s}' for 'rust.codegen-backends'. Instead, please use '{backend}'.\"); } else { println!(\"help: '{s}' for 'rust.codegen-backends' might fail. Codegen backends are mostly defined without the '{CODEGEN_BACKEND_PREFIX}' prefix. In this case, it would be referred to as '{backend}'.\"); } } INTERNER.intern_str(s) }).collect(); } config.rust_codegen_units = rust.codegen_units.map(threads_from_config);"}
{"_id":"q-en-rust-a6695d432205e8cc61092c1778722c67b744bc1cc35c142a733f14d57cca7010","text":"[[package]] name = \"backtrace\" version = \"0.3.25\" version = \"0.3.29\" source = \"registry+https://github.com/rust-lang/crates.io-index\" dependencies = [ \"autocfg 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)\","}
{"_id":"q-en-rust-a66c4a786fbd89b1e7522a77fefd0c8f58f47b611a4fed29ef1fae21cf179499","text":"// Private support modules mod panicking; #[unstable(feature = \"ice_to_disk\", issue = \"none\")] pub use panicking::panic_hook_with_disk_dump; #[path = \"../../backtrace/src/lib.rs\"] #[allow(dead_code, unused_attributes, fuzzy_provenance_casts)] mod backtrace_rs;"}
{"_id":"q-en-rust-a6899b34f310834c2ab7c29a421ce77e0e53837f059afdf8a41aea6ce2de669d","text":"b, index: 0, // unused len: 0, // unused a_len: 0, // unused } }"}
{"_id":"q-en-rust-a6a5a26251df1cd5f28925023780f503ae1ad1119392bf0ae439f58f1f25abc6","text":"let codegen_options = CodegenOptions::build(early_dcx, matches); let unstable_opts = UnstableOptions::build(early_dcx, matches); let force_unstable_if_unmarked = unstable_opts.force_unstable_if_unmarked; let dcx = new_dcx(error_format, None, diagnostic_width, &unstable_opts);"}
{"_id":"q-en-rust-a6a7fc8c47a0b6d30a2c080967fe5cf7900d031a436b2048a4a8be21516eeae3","text":"// This zip may have several times the same lifetime in `substs` paired with a different // lifetime from `id_substs`. Simply `collect`ing the iterator is the correct behaviour: // it will pick the last one, which is the one we introduced in the impl-trait desugaring. let map = substs.iter().zip(id_substs); let map: FxHashMap, GenericArg<'tcx>> = match origin { // HACK: The HIR lowering for async fn does not generate // any `+ Captures<'x>` bounds for the `impl Future<...>`, so all async fns with lifetimes // would now fail to compile. We should probably just make hir lowering fill this in properly. OpaqueTyOrigin::AsyncFn(_) => map.collect(), OpaqueTyOrigin::FnReturn(_) | OpaqueTyOrigin::TyAlias => { // Opaque types may only use regions that are bound. So for // ```rust // type Foo<'a, 'b, 'c> = impl Trait<'a> + 'b; // ``` // we may not use `'c` in the hidden type. let variances = tcx.variances_of(def_id); debug!(?variances); map.filter(|(_, v)| { let ty::GenericArgKind::Lifetime(lt) = v.unpack() else { return true }; let ty::ReEarlyBound(ebr) = lt.kind() else { bug!() }; variances[ebr.index as usize] == ty::Variance::Invariant }) .collect() } }; let map = substs.iter().zip(id_substs).collect(); debug!(\"map = {:#?}\", map); // Convert the type from the function into a type valid outside"}
{"_id":"q-en-rust-a6ad57d02fb54f58efc21ba60f89dbfc0e2e77bcba44faad4f53dd9a243895f4","text":"} #[test] fn test_line_buffer_fail_flush() { // Issue #32085 struct FailFlushWriter<'a>(&'a mut Vec); impl<'a> Write for FailFlushWriter<'a> { fn write(&mut self, buf: &[u8]) -> io::Result { self.0.extend_from_slice(buf); Ok(buf.len()) } fn flush(&mut self) -> io::Result<()> { Err(io::Error::new(io::ErrorKind::Other, \"flush failed\")) } } let mut buf = Vec::new(); { let mut writer = LineWriter::new(FailFlushWriter(&mut buf)); let to_write = b\"abcndef\"; if let Ok(written) = writer.write(to_write) { assert!(written < to_write.len(), \"didn't flush on new line\"); // PASS return; } } assert!(buf.is_empty(), \"write returned an error but wrote data\"); } #[test] fn test_line_buffer() { let mut writer = LineWriter::new(Vec::new()); writer.write(&[0]).unwrap();"}
{"_id":"q-en-rust-a6b47e44c72f8ac1c20c09a095ad68eb29f899635579d088c0a8aeb6eb3fed2a","text":"} #[test] #[allow(deprecated)] fn stream_smoke_test_ip4() { let server_ip = next_test_ip4(); let client_ip = next_test_ip4(); let dummy_ip = next_test_ip4(); let (tx1, rx1) = channel(); let (tx2, rx2) = channel(); spawn(proc() { match UdpSocket::bind(client_ip) { Ok(client) => { let client = box client; let mut stream = client.connect(server_ip); rx1.recv(); stream.write([99]).unwrap(); let send_as = |ip, val: &[u8]| { match UdpSocket::bind(ip) { Ok(client) => { let client = box client; let mut stream = client.connect(server_ip); stream.write(val).unwrap(); } Err(..) => fail!() } Err(..) => fail!() } }; rx1.recv(); send_as(dummy_ip, [98]); send_as(client_ip, [99]); tx2.send(()); });"}
{"_id":"q-en-rust-a6c7853d1847da828602f36304f5a58f058cda1ac8faa52c55874f6f26ae9a64","text":"} } // This is only used by a test which asserts that the initialization-tracking is correct. #[cfg(test)] impl BufReader { pub fn initialized(&self) -> usize { self.buf.initialized() } } impl BufReader { /// Seeks relative to the current position. If the new position lies within the buffer, /// the buffer will not be flushed, allowing for more efficient seeks."}
{"_id":"q-en-rust-a6ca8761a61f277d2f2ef4b5a2b0537700d74007d41f12d2f3c382b157a95b88","text":" //@ run-rustfix #![allow(unused_mut)] use std::borrow::{Borrow, BorrowMut}; use std::convert::{AsMut, AsRef}; struct Bar; impl AsRef for Bar { fn as_ref(&self) -> &Bar { self } } impl AsMut for Bar { fn as_mut(&mut self) -> &mut Bar { self } } fn foo>(_: T) {} fn qux>(_: T) {} fn bat>(_: T) {} fn baz>(_: T) {} pub fn main() { let bar = Bar; foo(bar); let _baa = bar; //~ ERROR use of moved value let mut bar = Bar; qux(bar); let _baa = bar; //~ ERROR use of moved value let bar = Bar; bat(bar); let _baa = bar; //~ ERROR use of moved value let mut bar = Bar; baz(bar); let _baa = bar; //~ ERROR use of moved value } "}
{"_id":"q-en-rust-a6e8e45403841d1ed285102c9d40a9be25c34289ade7c46e4216edd0e8484902","text":"/// consolidate multiple unresolved import errors into a single diagnostic. fn finalize_import(&mut self, import: &'b Import<'b>) -> Option { let orig_vis = import.vis.replace(ty::Visibility::Invisible); let orig_unusable_binding = match &import.kind { ImportKind::Single { target_bindings, .. } => { Some(mem::replace(&mut self.r.unusable_binding, target_bindings[TypeNS].get())) } _ => None, }; let prev_ambiguity_errors_len = self.r.ambiguity_errors.len(); let path_res = self.r.resolve_path( &import.module_path,"}
{"_id":"q-en-rust-a6ec901edd2543d49f483c15447b28d14c4244dda8e8bdb0e1a4b72cd20e92c9","text":" #![allow(unused)] fn main() { let arr = &[0,1,2,3]; for _i in 0..arr.len().rev() { //~ERROR not an iterator // The above error used to say “the method `rev` exists for type `usize`”. // This regression test ensures it doesn't say that any more. } let arr = &[0, 1, 2, 3]; for _i in 0..arr.len().rev() { //~^ ERROR can't call method //~| surround the range in parentheses // The above error used to say “the method `rev` exists for type `usize`”. // This regression test ensures it doesn't say that any more. } // Test for #102396 for i in 1..11.rev() { //~^ ERROR can't call method //~| HELP surround the range in parentheses } let end: usize = 10; for i in 1..end.rev() { //~^ ERROR can't call method //~| HELP surround the range in parentheses } for i in 1..(end + 1).rev() { //~^ ERROR can't call method //~| HELP surround the range in parentheses } if 1..(end + 1).is_empty() { //~^ ERROR can't call method //~| ERROR mismatched types [E0308] //~| HELP surround the range in parentheses } if 1..(end + 1).is_sorted() { //~^ ERROR mismatched types [E0308] //~| ERROR can't call method //~| HELP surround the range in parentheses } let _res: i32 = 3..6.take(2).sum(); //~^ ERROR can't call method //~| ERROR mismatched types [E0308] //~| HELP surround the range in parentheses let _sum: i32 = 3..6.sum(); //~^ ERROR can't call method //~| ERROR mismatched types [E0308] //~| HELP surround the range in parentheses let a = 1 as usize; let b = 10 as usize; for _a in a..=b.rev() { //~^ ERROR can't call method //~| HELP surround the range in parentheses } let _res = ..10.contains(3); //~^ ERROR can't call method //~| HELP surround the range in parentheses if 1..end.error_method() { //~^ ERROR no method named `error_method` //~| ERROR mismatched types [E0308] // Won't suggest } let _res = b.take(1)..a; //~^ ERROR `usize` is not an iterator let _res: i32 = ..6.take(2).sum(); //~^ can't call method `take` on ambiguous numeric type //~| ERROR mismatched types [E0308] //~| HELP you must specify a concrete type for this numeric value // Won't suggest because `RangeTo` dest not implemented `take` }"}
{"_id":"q-en-rust-a6fea38aec291864f55cae4a4acd7a80176bb348738d48645824b9508951c00e","text":"crate emit: Vec, /// If `true`, HTML source pages will generate links for items to their definition. crate generate_link_to_definition: bool, /// Set of function-call locations to include as examples crate call_locations: AllCallLocations, /// If `true`, Context::init will not emit shared files. crate no_emit_shared: bool, } #[derive(Copy, Clone, Debug, PartialEq, Eq)]"}
{"_id":"q-en-rust-a74bad89483bd7e8e73cb77f8b98cc73eb0a7c71ad19f50c25bc60a1dfd282f7","text":" // revisions: cfail #![feature(const_generics, const_evaluatable_checked)] #![allow(incomplete_features)] // regression test for #77650 fn c() where [T; N.get()]: Sized, { use std::convert::TryFrom; <[T; N.get()]>::try_from(()) //~^ error: the trait bound //~^^ error: mismatched types } fn main() {} "}
{"_id":"q-en-rust-a756100aa1e091872d689f5e4b3f7174080537d2a4f831541a16b996bb9dcd2a","text":"use polonius_engine::Atom; pub use rustc_ast::ast::Mutability; use rustc_ast::ast::{InlineAsmOptions, InlineAsmTemplatePiece}; use rustc_data_structures::fx::FxHashSet; use rustc_data_structures::graph::dominators::{dominators, Dominators}; use rustc_data_structures::graph::{self, GraphSuccessors};"}
{"_id":"q-en-rust-a7967a88c4d0098cfeaaeb5e5f767c9bc002f67274e5694dc6a1efced5dad39a","text":"pub enum TrailingToken { None, Semi, Gt, /// If the trailing token is a comma, then capture it /// Otherwise, ignore the trailing token MaybeComma,"}
{"_id":"q-en-rust-a7adfb1c7c056c78fa7da54ff57485a8ba2191f3f40ea3daf26a9d5b40e20a19","text":"/// Builds the whole `assert!` expression. For example, `let elem = 1; assert!(elem == 1);` expands to: /// /// ```rust /// #![feature(generic_assert_internals)] /// let elem = 1; /// { /// #[allow(unused_imports)]"}
{"_id":"q-en-rust-a7b148cc86dcaeeebda9e04db9087e776f1ecbb6119e31d5b6ba7ef6c6e12f4a","text":"\"only the last field of a struct or enum variant may have a dynamically sized type\") } traits::ObjectSized => { span_note!(tcx.sess, obligation.cause.span, \"only sized types can be made into objects\"); } } }"}
{"_id":"q-en-rust-a7b8dbaba928493572c6cc88c9613e1b7ed610519428dd696a0452d44828351a","text":" error[E0371]: the object type `(dyn Object + Marker2 + 'static)` automatically implements the trait `Marker1` --> $DIR/coherence-impl-trait-for-marker-trait-negative.rs:14:1 | LL | impl !Marker1 for dyn Object + Marker2 { } //~ ERROR E0371 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `(dyn Object + Marker2 + 'static)` automatically implements trait `Marker1` error[E0371]: the object type `(dyn Object + Marker2 + 'static)` automatically implements the trait `Marker2` --> $DIR/coherence-impl-trait-for-marker-trait-negative.rs:16:1 | LL | impl !Marker2 for dyn Object + Marker2 { } //~ ERROR E0371 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `(dyn Object + Marker2 + 'static)` automatically implements trait `Marker2` error[E0117]: only traits defined in the current crate can be implemented for arbitrary types --> $DIR/coherence-impl-trait-for-marker-trait-negative.rs:22:1 | LL | impl !Send for dyn Marker2 {} //~ ERROR E0117 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate | = note: the impl does not reference only types defined in this crate = note: define and implement a trait or new type instead error[E0321]: cross-crate traits with a default impl, like `std::marker::Send`, can only be implemented for a struct/enum type, not `(dyn Object + 'static)` --> $DIR/coherence-impl-trait-for-marker-trait-negative.rs:26:1 | LL | impl !Send for dyn Object {} //~ ERROR E0321 | ^^^^^^^^^^^^^^^^^^^^^^^^^ can't implement cross-crate trait with a default impl for non-struct/enum type error[E0321]: cross-crate traits with a default impl, like `std::marker::Send`, can only be implemented for a struct/enum type, not `(dyn Object + Marker2 + 'static)` --> $DIR/coherence-impl-trait-for-marker-trait-negative.rs:27:1 | LL | impl !Send for dyn Object + Marker2 {} //~ ERROR E0321 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't implement cross-crate trait with a default impl for non-struct/enum type error: aborting due to 5 previous errors Some errors occurred: E0117, E0321, E0371. For more information about an error, try `rustc --explain E0117`. "}
{"_id":"q-en-rust-a7c5c149d4abfd8cc06e29e0493f1564eb52271e79596d5b850db0501195c316","text":"let prefix = default_path(&builder.config.prefix, \"/usr/local\"); let sysconfdir = prefix.join(default_path(&builder.config.sysconfdir, \"/etc\")); let destdir_env = env::var_os(\"DESTDIR\").map(PathBuf::from); // Sanity check for the user write access on prefix and sysconfdir assert!( is_dir_writable_for_user(&prefix), \"User doesn't have write access on `install.prefix` path in the `config.toml`.\", ); assert!( is_dir_writable_for_user(&sysconfdir), \"User doesn't have write access on `install.sysconfdir` path in `config.toml`.\" ); // Sanity checks on the write access of user. // // When the `DESTDIR` environment variable is present, there is no point to // check write access for `prefix` and `sysconfdir` individually, as they // are combined with the path from the `DESTDIR` environment variable. In // this case, we only need to check the `DESTDIR` path, disregarding the // `prefix` and `sysconfdir` paths. if let Some(destdir) = &destdir_env { assert!(is_dir_writable_for_user(destdir), \"User doesn't have write access on DESTDIR.\"); } else { assert!( is_dir_writable_for_user(&prefix), \"User doesn't have write access on `install.prefix` path in the `config.toml`.\", ); assert!( is_dir_writable_for_user(&sysconfdir), \"User doesn't have write access on `install.sysconfdir` path in `config.toml`.\" ); } let datadir = prefix.join(default_path(&builder.config.datadir, \"share\")); let docdir = prefix.join(default_path(&builder.config.docdir, \"share/doc/rust\"));"}
{"_id":"q-en-rust-a7d302e34dae77f0621458222fc96c8a97e5e25c0a01273f05673f5775cc27ea","text":"issued_borrow.borrowed_place, &issued_spans, ); self.explain_iterator_advancement_in_for_loop_if_applicable( &mut err, span, &issued_spans, ); err }"}
{"_id":"q-en-rust-a8266228840571877ce67d129f0d314203375893e6ae50dfb6373aab737469d1","text":" // This test certify that we can mix attribute macros from Rust and external proc-macros. // For instance, `#[derive(Default)]` uses `#[default]` and `#[derive(SmartPointer)]` uses // `#[pointee]`. // The scoping rule should allow the use of the said two attributes when external proc-macros // are in scope. //@ check-pass //@ aux-build: another-proc-macro.rs //@ compile-flags: -Zunpretty=expanded #![feature(derive_smart_pointer)] #[macro_use] extern crate another_proc_macro; #[pointee] fn f() {} #[default] fn g() {} "}
{"_id":"q-en-rust-a848de6c518c74dfdaef72e3c8b059fd5ddd43f8819fb633f48fd741a8f933ca","text":"/// This function should maybe change to /// `new_const(kind: ErrorKind)` /// in the future, when const generics allow that. #[inline] pub(crate) const fn new_const(kind: ErrorKind, message: &'static &'static str) -> Error { Self { repr: Repr::SimpleMessage(kind, message) } }"}
{"_id":"q-en-rust-a860c6134cbd2b7ca24c2c4c586d9812b6bc90925e53e3fa4af42feb06fb72a4","text":"} } pub mod signal { use libc::types::os::arch::c95::c_int; use libc::types::os::common::posix01::sighandler_t; #[cfg(not(target_os = \"android\"))] extern { pub fn signal(signum: c_int, handler: sighandler_t) -> sighandler_t; } #[cfg(target_os = \"android\")] extern { #[link_name = \"bsd_signal\"] pub fn signal(signum: c_int, handler: sighandler_t) -> sighandler_t; } } pub mod wait { use libc::types::os::arch::c95::{c_int}; use libc::types::os::arch::posix88::{pid_t};"}
{"_id":"q-en-rust-a872fb42ffe43eb21cf16d7db6b9638ee0f2925b6dba6969fcb7a4d4c19a1bc1","text":" // Regression test for #54779, checks if the diagnostics are confusing. #![feature(nll)] trait DebugWith { fn debug_with<'me>(&'me self, cx: &'me Cx) -> DebugCxPair<'me, Self, Cx> { DebugCxPair { value: self, cx } } fn fmt_with(&self, cx: &Cx, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result; } struct DebugCxPair<'me, Value: ?Sized, Cx: ?Sized> where Value: DebugWith, { value: &'me Value, cx: &'me Cx, } trait DebugContext {} struct Foo { bar: Bar, } impl DebugWith for Foo { fn fmt_with( &self, cx: &dyn DebugContext, fmt: &mut std::fmt::Formatter<'_>, ) -> std::fmt::Result { let Foo { bar } = self; bar.debug_with(cx); //~ ERROR: lifetime may not live long enough Ok(()) } } struct Bar {} impl DebugWith for Bar { fn fmt_with( &self, cx: &dyn DebugContext, fmt: &mut std::fmt::Formatter<'_>, ) -> std::fmt::Result { Ok(()) } } fn main() {} "}
{"_id":"q-en-rust-a87b5dc9864ec0603961abd3192588722a6c0f1b0ccf1243988b63c863dd3a21","text":" // aux-build:issue-99221-aux.rs // build-aux-docs // ignore-cross-compile #![crate_name = \"foo\"] #[macro_use] extern crate issue_99221_aux; pub use issue_99221_aux::*; // @count foo/index.html '//a[@class=\"macro\"]' 1 mod inner { #[macro_export] macro_rules! print { () => () } } "}
{"_id":"q-en-rust-a883e47e5ac4d9174aa323358f5fd6b6d651f3a83593a026970f424506e48f2d","text":"map.insert(\"required-associated-consts\".into(), 1); map.insert(\"required-methods\".into(), 1); map.insert(\"provided-methods\".into(), 1); map.insert(\"object-safety\".into(), 1); map.insert(\"implementors\".into(), 1); map.insert(\"synthetic-implementors\".into(), 1); map.insert(\"implementations-list\".into(), 1);"}
{"_id":"q-en-rust-a895643a2276eb7400ca7779c6c8de14acf00ab72007b9735d6c3b5cf08c89d1","text":"}) { let (child_field_idx, child_capture) = child_captures.next().unwrap(); // This analysis only makes sense if the parent capture is a // prefix of the child capture. assert!( child_capture.place.projections.len() >= parent_capture.place.projections.len(), \"parent capture ({parent_capture:#?}) expected to be prefix of child capture ({child_capture:#?})\" ); // Store this set of additional projections (fields and derefs). // We need to re-apply them later. let child_precise_captures ="}
{"_id":"q-en-rust-a8b80d969187c47a560980fd8c57f81132695ae314daf2a2c044f58e2169fd41","text":"/// } /// ``` #[inline] #[unstable(feature = \"needs_drop\", issue = \"41890\")] #[stable(feature = \"needs_drop\", since = \"1.22.0\")] pub fn needs_drop() -> bool { unsafe { intrinsics::needs_drop::() } }"}
{"_id":"q-en-rust-a8dac9e526f96da062429e057607ef6c880cb8bb91a85d99a29d47df5408b89a","text":"let tcx = self.infcx.tcx; let generics = tcx.generics_of(self.mir_def_id); let param = generics.type_param(¶m_ty, tcx); if let Some(generics) = tcx.hir().get_generics(self.mir_def_id) { if let Some(generics) = tcx.hir().get_generics(tcx.closure_base_def_id(self.mir_def_id)) { suggest_constraining_type_param( generics, &mut err,"}
{"_id":"q-en-rust-a919ec585ebe6224098f2026de45a856f6002fb1acaab3f1fff29d4bcffae705","text":"//////////////////////////////////////////////////////////////////////////////// #[macro_use] mod local; #[macro_use] mod scoped; #[macro_use] mod scoped_tls; #[stable(feature = \"rust1\", since = \"1.0.0\")] pub use self::local::{LocalKey, LocalKeyState};"}
{"_id":"q-en-rust-a92641155e779c079e0d3cbe6eb1c3423533440673db4deef99c6bfe858c980e","text":" error[E0277]: expected a `FnOnce<(&mut UIView<'_, T>,)>` closure, found `F` --> $DIR/issue-100690.rs:37:23 | LL | real_dispatch(f) | ------------- ^ expected an `FnOnce<(&mut UIView<'_, T>,)>` closure, found `F` | | | required by a bound introduced by this call | = note: expected a closure with arguments `(&mut UIView<'a, T>,)` found a closure with arguments `(&mut UIView<'_, T>,)` note: required by a bound in `real_dispatch` --> $DIR/issue-100690.rs:9:8 | LL | fn real_dispatch(f: F) -> Result<(), io::Error> | ------------- required by a bound in this ... LL | F: FnOnce(&mut UIView) -> Result<(), io::Error> + Send + 'static, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `real_dispatch` error: aborting due to previous error For more information about this error, try `rustc --explain E0277`. "}
{"_id":"q-en-rust-a94cc2406c728317c04a8433d955d2cce5cc3cfc17521d8cceec2faf03e33b81","text":" error: unexpected closing delimiter: `}` --> $DIR/issue-98601-delimiter-error-1.rs:7:1 | LL | fn foo() { | - this delimiter might not be properly closed... LL | match 0 { LL | _ => {} | -- block is empty, you might have not meant to close it ... LL | } | - ...as it matches this but it has different indentation LL | } | ^ unexpected closing delimiter error: aborting due to previous error "}
{"_id":"q-en-rust-a95916736b6952835bc751d521231c339e1fa221b89acc9e5a687e459b5e4370","text":"// compile-flags: -O // min-llvm-version: 15.0 #![crate_type=\"lib\"] #![crate_type = \"lib\"] use std::mem::MaybeUninit;"}
{"_id":"q-en-rust-a9a535b96910ace0612d9b3f3be766525dbc2257295de46d1b159ef3ea79a83f","text":"println!(\"`x.py` will now use the configuration at {}\", include_path.display()); let build = TargetSelection::from_user(&env!(\"BUILD_TRIPLE\")); let stage_path = [\"build\", build.rustc_target_arg(), \"stage1\"].join(\"/\"); let stage_path = [\"build\", build.rustc_target_arg(), \"stage1\"].join(&MAIN_SEPARATOR.to_string()); println!();"}
{"_id":"q-en-rust-a9a9086cff5c19af200060c23a275d5c6ffe346e13b0272b4d581953280a504b","text":"let result_subst = CanonicalVarValues { var_values: self.tcx.mk_args_from_iter( query_response.variables.iter().enumerate().map(|(index, info)| { if info.is_existential() { if info.universe() != ty::UniverseIndex::ROOT { // A variable from inside a binder of the query. While ideally these shouldn't // exist at all, we have to deal with them for now. self.instantiate_canonical_var(cause.span, info, |u| { universe_map[u.as_usize()] }) } else if info.is_existential() { match opt_values[BoundVar::new(index)] { Some(k) => k, None => self.instantiate_canonical_var(cause.span, info, |u| {"}
{"_id":"q-en-rust-a9acced614468e7a414888121ccd85e5be9deb168ee45bed4d9e8c264afe1269","text":"/// ```rust /// # use std::fmt::Write; /// # let mut buf = String::new(); /// /// // Bad /// writeln!(buf, \"\"); /// /// // Good /// writeln!(buf); /// ``` pub WRITELN_EMPTY_STRING, style,"}
{"_id":"q-en-rust-a9b1c088366f84feee45d9b557079a97b1437cd930e93f0c149eb84d08137550","text":"assert!(plan.iter().any(|s| s.name.contains(\"-ui\"))); assert!(plan.iter().any(|s| s.name.contains(\"cfail\"))); assert!(plan.iter().any(|s| s.name.contains(\"cfail\"))); assert!(plan.iter().any(|s| s.name.contains(\"cfail-full\"))); assert!(plan.iter().any(|s| s.name.contains(\"codegen-units\"))); assert!(plan.iter().any(|s| s.name.contains(\"debuginfo\")));"}
{"_id":"q-en-rust-a9ba99f6c62d1c70b69db07480947fd301cae9b901b4920531c51f18875f345f","text":" // 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 or the MIT license // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. #![crate_type=\"lib\"] pub enum Foo { FooV { data: () } } "}
{"_id":"q-en-rust-a9ca8411b09add0d0d3d0b8691d417026186cfaff2dfd8853324f016ae64ed8d","text":" // Regression test of #43913. // run-rustfix #![feature(trait_alias)] #![allow(bare_trait_objects, dead_code)] trait Strings = Iterator; struct Struct(S); //~^ ERROR: expected trait, found type alias `Strings` fn main() {} "}
{"_id":"q-en-rust-aa224cdaaea961464ddbdbea21d6a62317446716a7519ccd098f28b0b3e92d0a","text":"i -= 1u; } let mut val = s[i] as uint; let mut val = s[i] as u32; let w = UTF8_CHAR_WIDTH[val] as uint; assert!((w != 0));"}
{"_id":"q-en-rust-aa4701f5bbb64fdc4345002998c0ca2700a7c6f990bcc0e91265b368826afb29","text":" #![feature(inherent_associated_types)] #![allow(dead_code, incomplete_features)] #![crate_type = \"lib\"] #![deny(unused_attributes)] // run-rustfix pub trait Trait { type It; const IT: (); fn it0(); fn it1(); fn it2(); } pub struct Implementor; impl Implementor { #[doc(hidden)] // no error type Inh = (); #[doc(hidden)] // no error const INH: () = (); #[doc(hidden)] // no error fn inh() {} } impl Trait for Implementor { #[doc(hidden)] type It = (); //~^^ ERROR `#[doc(hidden)]` is ignored //~| WARNING this was previously accepted #[doc(hidden)] const IT: () = (); //~^^ ERROR `#[doc(hidden)]` is ignored //~| WARNING this was previously accepted #[doc(hidden, alias = \"aka\")] fn it0() {} //~^^ ERROR `#[doc(hidden)]` is ignored //~| WARNING this was previously accepted #[doc(alias = \"this\", hidden,)] fn it1() {} //~^^ ERROR `#[doc(hidden)]` is ignored //~| WARNING this was previously accepted #[doc(hidden, hidden)] fn it2() {} //~^^ ERROR `#[doc(hidden)]` is ignored //~| WARNING this was previously accepted //~| ERROR `#[doc(hidden)]` is ignored //~| WARNING this was previously accepted } "}
{"_id":"q-en-rust-aa4c6961c19014ed2a38940a5bedb539f1dd112924fa30083603817356be1b29","text":"debug!(\"ty_generics_for_trait(trait_id={:?}, substs={:?})\", ccx.tcx.map.local_def_id(trait_id), substs); let mut generics = ty_generics_for_type_or_impl(ccx, ast_generics); let mut generics = ty_generics_for_type(ccx, ast_generics); // Add in the self type parameter. //"}
{"_id":"q-en-rust-aa4e55b7dfbe54b9ebe12d0bba980fcbaddf40e96294fc5404b53d297c301565","text":"self.verbose > 0 } pub fn symlink_file, Q: AsRef>(&self, src: P, link: Q) -> io::Result<()> { #[cfg(unix)] use std::os::unix::fs::symlink as symlink_file; #[cfg(windows)] use std::os::windows::fs::symlink_file; if !self.dry_run() { symlink_file(src.as_ref(), link.as_ref()) } else { Ok(()) } } pub(crate) fn create(&self, path: &Path, s: &str) { if self.dry_run() { return;"}
{"_id":"q-en-rust-aa60999b60ef951cb0d27cfc4163727739ff5398f4b0c4d39e837d7a4b2c475a","text":" error: using function pointers as const generic parameters is forbidden --> $DIR/issue-71381.rs:13:61 | LL | pub fn call_me(&self) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: using function pointers as const generic parameters is forbidden --> $DIR/issue-71381.rs:21:19 | LL | const FN: unsafe extern \"C\" fn(Args), | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 2 previous errors "}
{"_id":"q-en-rust-aa64e440a391a92ca020c79f3eeb86df0632c36eb8ad35ebb8db167497e09b52","text":"dependencies = [ \"lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)\", \"new_debug_unreachable 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)\", \"phf_shared 0.7.22 (registry+https://github.com/rust-lang/crates.io-index)\", \"phf_shared 0.7.24 (registry+https://github.com/rust-lang/crates.io-index)\", \"precomputed-hash 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)\", \"serde 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)\", \"string_cache_codegen 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)\","}
{"_id":"q-en-rust-aa87b23809c31e14e4964918d5a00bbbac1433b335c0fd8fd50ff215a1d48b28","text":"impl DoubleEndedIterator for Drain<'_, T, A> { #[inline] fn next_back(&mut self) -> Option { self.iter.next_back().map(|elt| unsafe { ptr::read(elt) }) if self.tail == self.head { return None; } self.head = wrap_index(self.head.wrapping_sub(1), self.ring.len()); // Safety: // - `self.head` in a ring buffer is always a valid index. // - `self.head` and `self.tail` equality is checked above. unsafe { Some(ptr::read(self.ring.as_ptr().get_unchecked_mut(self.head))) } } }"}
{"_id":"q-en-rust-aaaf6e28f391e78c55f198a21d1174913aa4e2111b6b48cb6d5d6889c905f882","text":" // Copyright 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 or the MIT license // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. // Test transitive analysis for associated types. Collected types // should be normalized and new obligations generated. use std::borrow::{ToOwned, Cow}; fn assert_send(_: T) {} fn main() { assert_send(Cow::Borrowed(\"foo\")); } "}
{"_id":"q-en-rust-aaeb17f85c2bd5a21dffe682286ce0eb2288bfb3ee8d2eb9c9dae2f47478ca69","text":"} } if !unnormalized_trait_sig.output().references_error() { debug_assert!( !collector.types.is_empty(), \"expect >0 RPITITs in call to `collect_return_position_impl_trait_in_trait_tys`\" ); } // FIXME: This has the same issue as #108544, but since this isn't breaking // existing code, I'm not particularly inclined to do the same hack as above // where we process wf obligations manually. This can be fixed in a forward-"}
{"_id":"q-en-rust-ab11b5a6ce34573d28c19791712b66abc54994e7857eece002e2f593f7b8bfe8","text":".param_env .and(type_op::implied_outlives_bounds::ImpliedOutlivesBounds { ty }) .fully_perform(self.infcx, DUMMY_SP) .unwrap_or_else(|_| bug!(\"failed to compute implied bounds {:?}\", ty)); .map_err(|_: ErrorGuaranteed| debug!(\"failed to compute implied bounds {:?}\", ty)) .ok()?; debug!(?bounds, ?constraints); self.add_outlives_bounds(bounds); constraints"}
{"_id":"q-en-rust-ab1428a392980dbbd29baeafd894776229fc82df3ab286349129af27e298149f","text":"} // We probe again, taking all traits into account (not only those in scope). let candidates = match self.lookup_probe( let mut candidates = match self.lookup_probe( span, segment.ident, self_ty,"}
{"_id":"q-en-rust-ab15e233b2f649e48de2920cebe535d878d98410fd6a506cb014fde623306da2","text":"if instance.def.is_inline(tcx) { attributes::inline(llfn, attributes::InlineAttr::Hint); } attributes::from_fn_attrs(cx, llfn, instance.def.def_id()); attributes::from_fn_attrs(cx, llfn, Some(instance.def.def_id())); let instance_def_id = instance.def_id();"}
{"_id":"q-en-rust-abab567c97db0886c94d52f73e3fb4b3fbfbb2f02e122a14d4e5e8f45765c510","text":"..(ori_link.range.start + before_second_backtick_group) } /// Returns true if we should ignore `link` due to it being unlikely /// that it is an intra-doc link. `link` should still have disambiguators /// if there were any. /// /// The difference between this and [`should_ignore_link()`] is that this /// check should only be used on links that still have disambiguators. fn should_ignore_link_with_disambiguators(link: &str) -> bool { link.contains(|ch: char| !(ch.is_alphanumeric() || \":_<>, !*&;@()\".contains(ch))) } /// Returns true if we should ignore `path_str` due to it being unlikely /// that it is an intra-doc link. fn should_ignore_link(path_str: &str) -> bool { path_str.contains(|ch: char| !(ch.is_alphanumeric() || \":_<>, !*&;\".contains(ch))) } #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)] /// Disambiguators for a link. crate enum Disambiguator {"}
{"_id":"q-en-rust-abbb3c48aa40d5e584e25c8b8418d96bad1986ba9c0ed12096a61f6b704aec52","text":"use rustc_hir::{HirId, HirIdSet, Node}; use rustc_middle::lint::LintDiagnosticBuilder; use rustc_middle::ty::subst::{GenericArgKind, Subst}; use rustc_middle::ty::{self, Ty, TyCtxt}; use rustc_middle::ty::{self, layout::LayoutError, Ty, TyCtxt}; use rustc_session::lint::FutureIncompatibleInfo; use rustc_session::Session; use rustc_span::edition::Edition;"}
{"_id":"q-en-rust-abd225d65ad91846b08db70c6b6f3bec87fab06e91fa6f38f63274faf7bbeba0","text":"} #[test] fn wtf8_show() { let mut string = Wtf8Buf::from_str(\"aé 💩\"); string.push(CodePoint::from_u32(0xD800).unwrap()); assert_eq!(format!(\"{:?}\", string), r#\"\"aé 💩u{D800}\"\"#); fn wtf8buf_show_str() { let text = \"até 💩r\"; let mut string = Wtf8Buf::from_str(text); assert_eq!(format!(\"{:?}\", text), format!(\"{:?}\", string)); } #[test]"}
{"_id":"q-en-rust-ac1083511a9ab52da4e865d9302c9ddd7310bf2236040782d04c5fe89c359a65","text":"extern crate issue_76736_2; // @has foo/struct.Foo.html // @has - '//*[@class=\"impl\"]//h3[@class=\"code-header\"]' 'MaybeResult' // @!has - '//*[@class=\"impl\"]//h3[@class=\"code-header\"]' 'MaybeResult' pub struct Foo; // @has foo/struct.Bar.html // @has - '//*[@class=\"impl\"]//h3[@class=\"code-header\"]' 'MaybeResult' // @!has - '//*[@class=\"impl\"]//h3[@class=\"code-header\"]' 'MaybeResult' pub use issue_76736_2::Bar;"}
{"_id":"q-en-rust-ac1448df037274683b65793a53cf343d7593325341bc8fb51fe8748635051174","text":"size: (1100, 800) // We check that \".item-info\" is bigger than its content. assert-css: (\".item-info\", {\"width\": \"807px\"}) assert-css: (\".item-info .stab\", {\"width\": \"343px\"}) assert-css: (\".item-info .stab\", {\"width\": \"341px\"}) "}
{"_id":"q-en-rust-ac3e034f30e0ff6561018f81c05b742363b2ff21a6576eb91b66d7674722726f","text":"}); debug!(\"instantiate_method_substs: user_type_annotation={:?}\", user_type_annotation); self.fcx.write_user_type_annotation(self.call_expr.hir_id, user_type_annotation); if !self.skip_record_for_diagnostics { self.fcx.write_user_type_annotation(self.call_expr.hir_id, user_type_annotation); } } self.normalize(self.span, substs)"}
{"_id":"q-en-rust-ac596ed5080e8a31917294b363e6ab7428eb6a438d7920ca6d6c64a39c7d4b37","text":" fn main() { extern { static symbol: [usize]; //~ ERROR: the size for values of type } println!(\"{}\", symbol[0]); } "}
{"_id":"q-en-rust-ad0a48a9ea6517408dd6d366f76ef6aad13f8150fdf6b42fa42dcd5deaa41e68","text":"stabilizing its interface\")] impl ScopedKey { #[doc(hidden)] pub const fn new() -> ScopedKey { ScopedKey { inner: imp::KeyInner::new() } pub const fn new(inner: fn() -> &'static imp::KeyInner) -> ScopedKey { ScopedKey { inner: inner } } /// Inserts a value into this scoped thread local storage slot for a"}
{"_id":"q-en-rust-ad10fa8ded0f1018f7017240d50ea8db8549f193f4fd4a5b2f0874bcca145229","text":"/// Pushes all the predicates needed to validate that `ty` is WF into `out`. #[instrument(level = \"debug\", skip(self))] fn compute(&mut self, arg: GenericArg<'tcx>) { let mut walker = arg.walk(); let param_env = self.param_env; let depth = self.recursion_depth; while let Some(arg) = walker.next() { debug!(?arg, ?self.out); let ty = match arg.unpack() { GenericArgKind::Type(ty) => ty, // No WF constraints for lifetimes being present, any outlives // obligations are handled by the parent (e.g. `ty::Ref`). GenericArgKind::Lifetime(_) => continue, GenericArgKind::Const(ct) => { match ct.kind() { ty::ConstKind::Unevaluated(uv) => { if !ct.has_escaping_bound_vars() { let obligations = self.nominal_obligations(uv.def, uv.args); self.out.extend(obligations); let predicate = ty::Binder::dummy(ty::PredicateKind::Clause( ty::ClauseKind::ConstEvaluatable(ct), )); let cause = self.cause(traits::WellFormed(None)); self.out.push(traits::Obligation::with_depth( self.tcx(), cause, self.recursion_depth, self.param_env, predicate, )); } } ty::ConstKind::Infer(_) => { let cause = self.cause(traits::WellFormed(None)); self.out.push(traits::Obligation::with_depth( self.tcx(), cause, self.recursion_depth, self.param_env, ty::Binder::dummy(ty::PredicateKind::Clause( ty::ClauseKind::WellFormed(ct.into()), )), )); } ty::ConstKind::Expr(_) => { // FIXME(generic_const_exprs): this doesn't verify that given `Expr(N + 1)` the // trait bound `typeof(N): Add` holds. This is currently unnecessary // as `ConstKind::Expr` is only produced via normalization of `ConstKind::Unevaluated` // which means that the `DefId` would have been typeck'd elsewhere. However in // the future we may allow directly lowering to `ConstKind::Expr` in which case // we would not be proving bounds we should. let predicate = ty::Binder::dummy(ty::PredicateKind::Clause( ty::ClauseKind::ConstEvaluatable(ct), )); let cause = self.cause(traits::WellFormed(None)); self.out.push(traits::Obligation::with_depth( self.tcx(), cause, self.recursion_depth, self.param_env, predicate, )); } ty::ConstKind::Error(_) | ty::ConstKind::Param(_) | ty::ConstKind::Bound(..) | ty::ConstKind::Placeholder(..) => { // These variants are trivially WF, so nothing to do here. } ty::ConstKind::Value(..) => { // FIXME: Enforce that values are structurally-matchable. } } continue; } }; debug!(\"wf bounds for ty={:?} ty.kind={:#?}\", ty, ty.kind()); match *ty.kind() { ty::Bool | ty::Char | ty::Int(..) | ty::Uint(..) | ty::Float(..) | ty::Error(_) | ty::Str | ty::CoroutineWitness(..) | ty::Never | ty::Param(_) | ty::Bound(..) | ty::Placeholder(..) | ty::Foreign(..) => { // WfScalar, WfParameter, etc } // Can only infer to `ty::Int(_) | ty::Uint(_)`. ty::Infer(ty::IntVar(_)) => {} // Can only infer to `ty::Float(_)`. ty::Infer(ty::FloatVar(_)) => {} ty::Slice(subty) => { self.require_sized(subty, traits::SliceOrArrayElem); } ty::Array(subty, _) => { self.require_sized(subty, traits::SliceOrArrayElem); // Note that we handle the len is implicitly checked while walking `arg`. } ty::Tuple(tys) => { if let Some((_last, rest)) = tys.split_last() { for &elem in rest { self.require_sized(elem, traits::TupleElem); } } } ty::RawPtr(_) => { // Simple cases that are WF if their type args are WF. } ty::Alias(ty::Projection, data) => { walker.skip_current_subtree(); // Subtree handled by compute_projection. self.compute_projection(data); } ty::Alias(ty::Inherent, data) => { walker.skip_current_subtree(); // Subtree handled by compute_inherent_projection. self.compute_inherent_projection(data); } ty::Adt(def, args) => { // WfNominalType let obligations = self.nominal_obligations(def.did(), args); self.out.extend(obligations); } ty::FnDef(did, args) => { let obligations = self.nominal_obligations(did, args); self.out.extend(obligations); } ty::Ref(r, rty, _) => { // WfReference if !r.has_escaping_bound_vars() && !rty.has_escaping_bound_vars() { let cause = self.cause(traits::ReferenceOutlivesReferent(ty)); self.out.push(traits::Obligation::with_depth( self.tcx(), cause, depth, param_env, ty::Binder::dummy(ty::PredicateKind::Clause( ty::ClauseKind::TypeOutlives(ty::OutlivesPredicate(rty, r)), )), )); } } ty::Coroutine(did, args, ..) => { // Walk ALL the types in the coroutine: this will // include the upvar types as well as the yield // type. Note that this is mildly distinct from // the closure case, where we have to be careful // about the signature of the closure. We don't // have the problem of implied bounds here since // coroutines don't take arguments. let obligations = self.nominal_obligations(did, args); self.out.extend(obligations); } ty::Closure(did, args) => { // Only check the upvar types for WF, not the rest // of the types within. This is needed because we // capture the signature and it may not be WF // without the implied bounds. Consider a closure // like `|x: &'a T|` -- it may be that `T: 'a` is // not known to hold in the creator's context (and // indeed the closure may not be invoked by its // creator, but rather turned to someone who *can* // verify that). // // The special treatment of closures here really // ought not to be necessary either; the problem // is related to #25860 -- there is no way for us // to express a fn type complete with the implied // bounds that it is assuming. I think in reality // the WF rules around fn are a bit messed up, and // that is the rot problem: `fn(&'a T)` should // probably always be WF, because it should be // shorthand for something like `where(T: 'a) { // fn(&'a T) }`, as discussed in #25860. walker.skip_current_subtree(); // subtree handled below // FIXME(eddyb) add the type to `walker` instead of recursing. self.compute(args.as_closure().tupled_upvars_ty().into()); // Note that we cannot skip the generic types // types. Normally, within the fn // body where they are created, the generics will // always be WF, and outside of that fn body we // are not directly inspecting closure types // anyway, except via auto trait matching (which // only inspects the upvar types). // But when a closure is part of a type-alias-impl-trait // then the function that created the defining site may // have had more bounds available than the type alias // specifies. This may cause us to have a closure in the // hidden type that is not actually well formed and // can cause compiler crashes when the user abuses unsafe // code to procure such a closure. // See tests/ui/type-alias-impl-trait/wf_check_closures.rs let obligations = self.nominal_obligations(did, args); self.out.extend(obligations); } ty::CoroutineClosure(did, args) => { // See the above comments. The same apply to coroutine-closures. walker.skip_current_subtree(); self.compute(args.as_coroutine_closure().tupled_upvars_ty().into()); let obligations = self.nominal_obligations(did, args); self.out.extend(obligations); } ty::FnPtr(_) => { // let the loop iterate into the argument/return // types appearing in the fn signature } ty::Alias(ty::Opaque, ty::AliasTy { def_id, args, .. }) => { // All of the requirements on type parameters // have already been checked for `impl Trait` in // return position. We do need to check type-alias-impl-trait though. if self.tcx().is_type_alias_impl_trait(def_id) { let obligations = self.nominal_obligations(def_id, args); self.out.extend(obligations); } } ty::Alias(ty::Weak, ty::AliasTy { def_id, args, .. }) => { let obligations = self.nominal_obligations(def_id, args); self.out.extend(obligations); } ty::Dynamic(data, r, _) => { // WfObject // // Here, we defer WF checking due to higher-ranked // regions. This is perhaps not ideal. self.from_object_ty(ty, data, r); // FIXME(#27579) RFC also considers adding trait // obligations that don't refer to Self and // checking those let defer_to_coercion = self.tcx().features().object_safe_for_dispatch; if !defer_to_coercion { if let Some(principal) = data.principal_def_id() { self.out.push(traits::Obligation::with_depth( self.tcx(), self.cause(traits::WellFormed(None)), depth, param_env, ty::Binder::dummy(ty::PredicateKind::ObjectSafe(principal)), )); } } } // Inference variables are the complicated case, since we don't // know what type they are. We do two things: // // 1. Check if they have been resolved, and if so proceed with // THAT type. // 2. If not, we've at least simplified things (e.g., we went // from `Vec<$0>: WF` to `$0: WF`), so we can // register a pending obligation and keep // moving. (Goal is that an \"inductive hypothesis\" // is satisfied to ensure termination.) // See also the comment on `fn obligations`, describing \"livelock\" // prevention, which happens before this can be reached. ty::Infer(_) => { let cause = self.cause(traits::WellFormed(None)); self.out.push(traits::Obligation::with_depth( self.tcx(), cause, self.recursion_depth, param_env, ty::Binder::dummy(ty::PredicateKind::Clause(ty::ClauseKind::WellFormed( ty.into(), ))), )); } } debug!(?self.out); } arg.visit_with(self); debug!(?self.out); } #[instrument(level = \"debug\", skip(self))]"}
{"_id":"q-en-rust-ad8daa086d15069c90da1107d8141ba7e025a003745d12aaeff128188e8f6f8f","text":"CHECK: [[DEFINE_INTERNAL]] { {{.*}} } @_R{{[a-zA-Z0-9_]+}}testprog14will_be_called() unnamed_addr #{{[0-9]+}} { CHECK-NEXT: start: CHECK-NOT: [[DEFINE_INTERNAL]] CHECK: %pgocount = load i64, {{i64*|ptr}} CHECK: atomicrmw add ptr CHECK-SAME: @__profc__R{{[a-zA-Z0-9_]+}}testprog14will_be_called, CHECK: declare void @llvm.instrprof.increment({{i8*|ptr}}, i64, i32, i32) #[[LLVM_INSTRPROF_INCREMENT_ATTR:[0-9]+]]"}
{"_id":"q-en-rust-adafee5d15302c6d91732c092dc936e3abc2d92fc40890dfecd7da9618540936","text":"ty::Closure(..) => Abi::RustCall, ty::CoroutineClosure(..) => Abi::RustCall, ty::Coroutine(..) => Abi::Rust, // No need to do MIR validation on error bodies ty::Error(_) => return, _ => { span_bug!(body.span, \"unexpected body ty: {:?} phase {:?}\", body_ty, mir_phase) }"}
{"_id":"q-en-rust-addb0786d00f90c34220aaffadff1d1e722622543e04e64c0adbc23fb6a51c18","text":"target_option_val!(limit_rdylib_exports); target_option_val!(override_export_symbols); target_option_val!(merge_functions); target_option_val!(mcount, \"target_mcount\"); target_option_val!(mcount, \"target-mcount\"); target_option_val!(llvm_abiname); target_option_val!(relax_elf_relocations); target_option_val!(llvm_args);"}
{"_id":"q-en-rust-adff4a978196666cc4e8dfdc46f9eec1c6f577f5a5920158a6f88d7f7c435c3e","text":"} impl Attribute { #[inline] pub fn has_name(&self, name: Symbol) -> bool { match self.kind { AttrKind::Normal(ref item, _) => item.path == name,"}
{"_id":"q-en-rust-ae099a772cef77390ad53c2308b1ad96b7304e727cc1f2da1675830d5aaeb72d","text":"let s = str::from_utf8(&out.stderr).unwrap(); // loosened the following from double::h to double:: due to // spurious failures on mac, 32bit, optimized assert!(s.contains(\"stack backtrace\") && s.contains(\"double::\"), assert!(s.contains(\"stack backtrace\") && s.contains(\" - double\"), \"bad output3: {}\", s); // Make sure a stack trace isn't printed too many times"}
{"_id":"q-en-rust-ae2783b6086fd68ad38af95fc6a95d5c03d7c4b66c171703540a729594d4abd4","text":" fn main() { x::<#[a]y::> //~^ ERROR invalid const generic expression //~| ERROR cannot find value `x` in this scope } "}
{"_id":"q-en-rust-ae8509aecb74e3615f125737f7c8789c7194ae01c9c30221b67079955361fb4e","text":"/// ``` #[unstable(feature = \"std_misc\", reason = \"pending integer conventions\")] fn ldexp(x: Self, exp: isize) -> Self; fn ldexp(self, exp: isize) -> Self; /// Breaks the number into a normalized fraction and a base-2 exponent, /// satisfying: ///"}
{"_id":"q-en-rust-ae8614c41503837e835e06016c8fa623cad131bc8cf17315746ee7067770fa41","text":" // Copyright 2018 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 or the MIT license // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. // https://github.com/rust-lang/rust/issues/49181 #[derive(Eq, PartialEq)] #[repr(i8)] pub enum A { B = -1, C = 1, } pub const D: A = A::B; fn main() { match A::C { D => {}, _ => {} } } "}
{"_id":"q-en-rust-aeab86e28d63c18f894d03636ab43225a59bb79c3bc1c8d2a6278dab36453233","text":"cx.stats.borrow_mut().n_closures += 1; // The `uwtable` attribute according to LLVM is: // // This attribute indicates that the ABI being targeted requires that an // unwind table entry be produced for this function even if we can show // that no exceptions passes by it. This is normally the case for the // ELF x86-64 abi, but it can be disabled for some compilation units. // // Typically when we're compiling with `-C panic=abort` (which implies this // `no_landing_pads` check) we don't need `uwtable` because we can't // generate any exceptions! On Windows, however, exceptions include other // events such as illegal instructions, segfaults, etc. This means that on // Windows we end up still needing the `uwtable` attribute even if the `-C // panic=abort` flag is passed. // // You can also find more info on why Windows is whitelisted here in: // https://bugzilla.mozilla.org/show_bug.cgi?id=1302078 if !cx.sess().no_landing_pads() || cx.sess().target.target.options.requires_uwtable { attributes::emit_uwtable(lldecl, true); } let mir = cx.tcx.instance_mir(instance.def); mir::codegen_mir(cx, lldecl, &mir, instance, sig); }"}
{"_id":"q-en-rust-aeaf9350318a4bb3663bf6f1cc32436b9ac77bf894497db0416c3d8a83d46eed","text":"// there's no need to do dep-graph tracking for any of it. tcx.dep_graph.assert_ignored(); join( || encode_metadata_impl(tcx, path), || { if tcx.sess.threads() == 1 { return; } // Prefetch some queries used by metadata encoding. // This is not necessary for correctness, but is only done for performance reasons. // It can be removed if it turns out to cause trouble or be detrimental to performance. join(|| prefetch_mir(tcx), || tcx.exported_symbols(LOCAL_CRATE)); }, ); } if tcx.sess.threads() != 1 { // Prefetch some queries used by metadata encoding. // This is not necessary for correctness, but is only done for performance reasons. // It can be removed if it turns out to cause trouble or be detrimental to performance. join(|| prefetch_mir(tcx), || tcx.exported_symbols(LOCAL_CRATE)); } fn encode_metadata_impl(tcx: TyCtxt<'_>, path: &Path) { let mut encoder = opaque::FileEncoder::new(path) .unwrap_or_else(|err| tcx.sess.emit_fatal(FailCreateFileEncoder { err })); encoder.emit_raw_bytes(METADATA_HEADER);"}
{"_id":"q-en-rust-aeb18219a96ac9199eb7c49527670516788cf7d286a7bbdd340ce719ca5618db","text":"pub struct Zip { a: A, b: B, // index and len are only used by the specialized version of zip // index, len and a_len are only used by the specialized version of zip index: usize, len: usize, a_len: usize, } impl Zip { pub(in crate::iter) fn new(a: A, b: B) -> Zip {"}
{"_id":"q-en-rust-aeb8d49cf132fd72786da5dd8ccb9823dfd8094ffa65643cc5c55915ffa5914e","text":" // run-pass // compile-flags: -C opt-level=1 // Make sure LLVM does not miscompile this match. fn main() { enum Bits { None = 0x00, Low = 0x40, High = 0x80, Both = 0xC0, } let value = Box::new(0x40u8); let mut out = Box::new(0u8); let bits = match *value { 0x00 => Bits::None, 0x40 => Bits::Low, 0x80 => Bits::High, 0xC0 => Bits::Both, _ => return, }; match bits { Bits::None | Bits::Low => { *out = 1; } _ => (), } assert_eq!(*out, 1); } "}
{"_id":"q-en-rust-aebccc02f91188fb85b1298f4e892a5f5fe778b59079b0aad21e11120ad90f28","text":" // check-pass use std::ops::Deref; struct Data { boxed: Box<&'static i32> } impl Data { fn use_data(&self, user: impl for <'a> FnOnce( as Deref>::Target)) { user(*self.boxed) } } fn main() {} "}
{"_id":"q-en-rust-aec02db580e94011cfa1c7319e85d114038a23fc699d0ab84d389212af9fe804","text":"#[cfg(target_os = \"macos\")] pub mod sysconf { use types::os::arch::c95::c_int; pub static _SC_ARG_MAX : c_int = 1; pub static _SC_CHILD_MAX : c_int = 2; pub static _SC_CLK_TCK : c_int = 3; pub static _SC_NGROUPS_MAX : c_int = 4; pub static _SC_OPEN_MAX : c_int = 5; pub static _SC_JOB_CONTROL : c_int = 6; pub static _SC_SAVED_IDS : c_int = 7; pub static _SC_VERSION : c_int = 8; pub static _SC_BC_BASE_MAX : c_int = 9; pub static _SC_BC_DIM_MAX : c_int = 10; pub static _SC_BC_SCALE_MAX : c_int = 11; pub static _SC_BC_STRING_MAX : c_int = 12; pub static _SC_COLL_WEIGHTS_MAX : c_int = 13; pub static _SC_EXPR_NEST_MAX : c_int = 14; pub static _SC_LINE_MAX : c_int = 15; pub static _SC_RE_DUP_MAX : c_int = 16; pub static _SC_2_VERSION : c_int = 17; pub static _SC_2_C_BIND : c_int = 18; pub static _SC_2_C_DEV : c_int = 19; pub static _SC_2_CHAR_TERM : c_int = 20; pub static _SC_2_FORT_DEV : c_int = 21; pub static _SC_2_FORT_RUN : c_int = 22; pub static _SC_2_LOCALEDEF : c_int = 23; pub static _SC_2_SW_DEV : c_int = 24; pub static _SC_2_UPE : c_int = 25; pub static _SC_STREAM_MAX : c_int = 26; pub static _SC_TZNAME_MAX : c_int = 27; pub static _SC_ASYNCHRONOUS_IO : c_int = 28; pub static _SC_PAGESIZE : c_int = 29; pub static _SC_MEMLOCK : c_int = 30; pub static _SC_MEMLOCK_RANGE : c_int = 31; pub static _SC_MEMORY_PROTECTION : c_int = 32; pub static _SC_MESSAGE_PASSING : c_int = 33; pub static _SC_PRIORITIZED_IO : c_int = 34; pub static _SC_PRIORITY_SCHEDULING : c_int = 35; pub static _SC_REALTIME_SIGNALS : c_int = 36; pub static _SC_SEMAPHORES : c_int = 37; pub static _SC_FSYNC : c_int = 38; pub static _SC_SHARED_MEMORY_OBJECTS : c_int = 39; pub static _SC_SYNCHRONIZED_IO : c_int = 40; pub static _SC_TIMERS : c_int = 41; pub static _SC_AIO_LISTIO_MAX : c_int = 42; pub static _SC_AIO_MAX : c_int = 43; pub static _SC_AIO_PRIO_DELTA_MAX : c_int = 44; pub static _SC_DELAYTIMER_MAX : c_int = 45; pub static _SC_MQ_OPEN_MAX : c_int = 46; pub static _SC_MAPPED_FILES : c_int = 47; pub static _SC_RTSIG_MAX : c_int = 48; pub static _SC_SEM_NSEMS_MAX : c_int = 49; pub static _SC_SEM_VALUE_MAX : c_int =50; pub static _SC_SIGQUEUE_MAX : c_int = 51; pub static _SC_TIMER_MAX : c_int = 52; pub static _SC_NPROCESSORS_CONF : c_int = 57; pub static _SC_NPROCESSORS_ONLN : c_int = 58; pub static _SC_2_PBS : c_int = 59; pub static _SC_2_PBS_ACCOUNTING : c_int = 60; pub static _SC_2_PBS_CHECKPOINT : c_int = 61; pub static _SC_2_PBS_LOCATE : c_int = 62; pub static _SC_2_PBS_MESSAGE : c_int = 63; pub static _SC_2_PBS_TRACK : c_int = 64; pub static _SC_ADVISORY_INFO : c_int = 65; pub static _SC_BARRIERS : c_int = 66; pub static _SC_CLOCK_SELECTION : c_int = 67; pub static _SC_CPUTIME : c_int = 68; pub static _SC_FILE_LOCKING : c_int = 69; pub static _SC_GETGR_R_SIZE_MAX : c_int = 70; pub static _SC_GETPW_R_SIZE_MAX : c_int = 71; pub static _SC_HOST_NAME_MAX : c_int = 72; pub static _SC_LOGIN_NAME_MAX : c_int = 73; pub static _SC_MONOTONIC_CLOCK : c_int = 74; pub static _SC_MQ_PRIO_MAX : c_int = 75; pub static _SC_READER_WRITER_LOCKS : c_int = 76; pub static _SC_REGEXP : c_int = 77; pub static _SC_SHELL : c_int = 78; pub static _SC_SPAWN : c_int = 79; pub static _SC_SPIN_LOCKS : c_int = 80; pub static _SC_SPORADIC_SERVER : c_int = 81; pub static _SC_THREAD_ATTR_STACKADDR : c_int = 82; pub static _SC_THREAD_ATTR_STACKSIZE : c_int = 83; pub static _SC_THREAD_CPUTIME : c_int = 84; pub static _SC_THREAD_DESTRUCTOR_ITERATIONS : c_int = 85; pub static _SC_THREAD_KEYS_MAX : c_int = 86; pub static _SC_THREAD_PRIO_INHERIT : c_int = 87; pub static _SC_THREAD_PRIO_PROTECT : c_int = 88; pub static _SC_THREAD_PRIORITY_SCHEDULING : c_int = 89; pub static _SC_THREAD_PROCESS_SHARED : c_int = 90; pub static _SC_THREAD_SAFE_FUNCTIONS : c_int = 91; pub static _SC_THREAD_SPORADIC_SERVER : c_int = 92; pub static _SC_THREAD_STACK_MIN : c_int = 93; pub static _SC_THREAD_THREADS_MAX : c_int = 94; pub static _SC_TIMEOUTS : c_int = 95; pub static _SC_THREADS : c_int = 96; pub static _SC_TRACE : c_int = 97; pub static _SC_TRACE_EVENT_FILTER: c_int = 98; pub static _SC_TRACE_INHERIT: c_int = 99; pub static _SC_TRACE_LOG: c_int = 100; pub static _SC_TTY_NAME_MAX: c_int = 101; pub static _SC_TYPED_MEMORY_OBJECTS: c_int = 102; pub static _SC_V6_ILP32_OFF32: c_int = 103; pub static _SC_V6_ILP32_OFFBIG: c_int = 104; pub static _SC_V6_LP64_OFF64: c_int = 105; pub static _SC_V6_LPBIG_OFFBIG: c_int = 106; pub static _SC_IPV6: c_int = 118; pub static _SC_RAW_SOCKETS: c_int = 119; pub static _SC_SYMLOOP_MAX: c_int = 120; pub static _SC_ATEXIT_MAX: c_int = 107; pub static _SC_IOV_MAX: c_int = 56; pub static _SC_PAGE_SIZE: cint = _SC_PAGESIZE; pub static _SC_XOPEN_CRYPT: c_int = 108; pub static _SC_XOPEN_ENH_I18N: c_int = 109; pub static _SC_XOPEN_LEGACY: c_int = 110; pub static _SC_XOPEN_REALTIME: c_int = 111; pub static _SC_XOPEN_REALTIME_THREADS: c_int = 112; pub static _SC_XOPEN_SHM: c_int = 113; pub static _SC_XOPEN_STREAMS: c_int = 114; pub static _SC_XOPEN_UNIX: c_int = 115; pub static _SC_XOPEN_VERSION: c_int = 116; pub static _SC_XOPEN_XCU_VERSION: c_int = 121; pub static _SC_XBS5_ILP32_OFF32: c_int = 122; pub static _SC_XBS5_ILP32_OFFBIG: c_int = 123; pub static _SC_XBS5_LP64_OFF64: c_int = 124; pub static _SC_XBS5_LPBIG_OFFBIG: c_int = 125; pub static _SC_SS_REPL_MAX: c_int = 126; pub static _SC_TRACE_EVENT_NAME_MAX: c_int = 127; pub static _SC_TRACE_NAME_MAX: c_int = 128; pub static _SC_TRACE_SYS_MAX: c_int = 129; pub static _SC_TRACE_USER_EVENT_MAX: c_int = 130; pub static _SC_PASS_MAX: c_int = 131; } #[cfg(target_os = \"android\")]"}
{"_id":"q-en-rust-aec32b56935ec4a496586113e95d6d4c264fb6fc6d2e00f0dd2efc512fa7f8c1","text":"type Wub = !; //~ ERROR type is experimental } fn look_ma_no_feature_gate !>() {} //~ ERROR type is experimental fn tadam(f: &dyn Fn() -> !) {} //~ ERROR type is experimental fn panic() -> ! { panic!(); } fn toudoum() -> impl Fn() -> ! { //~ ERROR type is experimental panic } fn main() { }"}
{"_id":"q-en-rust-aec89039b787258708cc5d0e6a17f70af6178f65c1112e440ec1a21d3d078fff","text":"//! are elements, and once they've all been exhausted, will return `None` to //! indicate that iteration is finished. Individual iterators may choose to //! resume iteration, and so calling [`next`] again may or may not eventually //! start returning `Some(Item)` again at some point. //! start returning `Some(Item)` again at some point (for example, see [`TryIter`]). //! //! [`Iterator`]'s full definition includes a number of other methods as well, //! but they are default methods, built on top of [`next`], and so you get"}
{"_id":"q-en-rust-af014605f378b124084b3168c7fa1ef9df82bf2bc2cf50e25d3839aed2d45d6f","text":" goto: file://|DOC_PATH|/test_docs/type.SomeType.html assert-all: (\".top-block .docblock p\", {\"font-weight\": \"400\"}) "}
{"_id":"q-en-rust-af025ac3ad1b6f759c7902f979dd0f7e006857456e8675299784f169b003f359","text":"use crate::cache::{Interned, INTERNER}; use crate::cc_detect::{ndk_compiler, Language}; use crate::channel::{self, GitInfo}; use crate::compile::CODEGEN_BACKEND_PREFIX; pub use crate::flags::Subcommand; use crate::flags::{Color, Flags, Warnings}; use crate::util::{exe, output, t};"}
{"_id":"q-en-rust-af5f579ea69006f99d8e78fed2af8e3601746a4b21963d1c5a9ccfd0e7afeb90","text":"// Ignore the notification. None } else { print!( \"failed to decode compiler output as json: line: {}noutput: {}\", line, output ); panic!() // This function is called for both compiler and non-compiler output, // so if the line isn't recognized as JSON from the compiler then // just print it as-is. Some(format!(\"{line}n\")) } } else { // preserve non-JSON lines, such as ICEs"}
{"_id":"q-en-rust-af717099e7487e13ce07320ebea014721043b90534f9823af568e42a9374f47c","text":"// 'Deprecated$' #[deprecated] pub struct W; // @matches deprecated/struct.X.html '//*[@class=\"stab deprecated\"]' // 'Deprecated: shorthand reason$' #[deprecated = \"shorthand reason\"] pub struct X; "}
{"_id":"q-en-rust-af858c9f28c560a3919af8b5991b63455c8f25c08acdfaf192a26a960ce582f3","text":" error[E0277]: the trait bound `*mut (): Trait<'_>` is not satisfied --> $DIR/issue-101623.rs:21:21 | LL | Trait::do_stuff({ fun(&mut *inner) }); | --------------- ^^----------------^^ | | | | | the trait `Trait<'_>` is not implemented for `*mut ()` | required by a bound introduced by this call | = help: the trait `Trait<'a>` is implemented for `()` error: aborting due to previous error For more information about this error, try `rustc --explain E0277`. "}
{"_id":"q-en-rust-af8cb0dfa16a8ad9dc6a6d7cbdeb35deb7857eaa9dc1722e397a0ba96050de95","text":"} } } // Visit everything, but enum variants have their own levels. hir::ItemKind::Enum(ref def, _) => { if item_level.is_some() { self.reach(item.def_id, item_level).generics().predicates(); } let enum_level = self.get(item.def_id); for variant in def.variants { let variant_level = self.update_with_hir_id(variant.id, enum_level); let variant_level = self.get(self.tcx.hir().local_def_id(variant.id)); if variant_level.is_some() { if let Some(ctor_id) = variant.data.ctor_hir_id() { self.update_with_hir_id(ctor_id, variant_level); } for field in variant.data.fields() { self.reach(self.tcx.hir().local_def_id(field.hir_id), variant_level) .ty();"}
{"_id":"q-en-rust-afd7b6544685e0bf4dfb517a21a7c66085f6f602ac3102ba4269706a2044ff0d","text":"tcx: TyCtxt<'tcx>, // typeck errors have subpar spans for opaque types, so delay error reporting until borrowck. ignore_errors: bool, origin: OpaqueTyOrigin, ) -> Self { let OpaqueTypeKey { def_id, substs } = opaque_type_key;"}
{"_id":"q-en-rust-b0a4fc36f2d2163a9b0cccaf614f538b3a8e828825e08a1606290e5ab2eb7200","text":"//! in this case, if one uses the format string `{:.*}`, then the `` part refers //! to the *value* to print, and the `precision` must come in the input preceding ``. //! //! For example, these: //! For example, the following calls all print the same thing `Hello x is 0.01000`: //! //! ``` //! // Hello {arg 0 (x)} is {arg 1 (0.01) with precision specified inline (5)} //! // Hello {arg 0 (\"x\")} is {arg 1 (0.01) with precision specified inline (5)} //! println!(\"Hello {0} is {1:.5}\", \"x\", 0.01); //! //! // Hello {arg 1 (x)} is {arg 2 (0.01) with precision specified in arg 0 (5)} //! // Hello {arg 1 (\"x\")} is {arg 2 (0.01) with precision specified in arg 0 (5)} //! println!(\"Hello {1} is {2:.0$}\", 5, \"x\", 0.01); //! //! // Hello {arg 0 (x)} is {arg 2 (0.01) with precision specified in arg 1 (5)} //! // Hello {arg 0 (\"x\")} is {arg 2 (0.01) with precision specified in arg 1 (5)} //! println!(\"Hello {0} is {2:.1$}\", \"x\", 5, 0.01); //! //! // Hello {next arg (x)} is {second of next two args (0.01) with precision //! // Hello {next arg (\"x\")} is {second of next two args (0.01) with precision //! // specified in first of next two args (5)} //! println!(\"Hello {} is {:.*}\", \"x\", 5, 0.01); //! //! // Hello {next arg (x)} is {arg 2 (0.01) with precision //! // Hello {next arg (\"x\")} is {arg 2 (0.01) with precision //! // specified in its predecessor (5)} //! println!(\"Hello {} is {2:.*}\", \"x\", 5, 0.01); //! //! // Hello {next arg (x)} is {arg \"number\" (0.01) with precision specified //! // Hello {next arg (\"x\")} is {arg \"number\" (0.01) with precision specified //! // in arg \"prec\" (5)} //! println!(\"Hello {} is {number:.prec$}\", \"x\", prec = 5, number = 0.01); //! ``` //! //! All print the same thing: //! //! ```text //! Hello x is 0.01000 //! ``` //! //! While these: //! //! ```"}
{"_id":"q-en-rust-b0b4fbc9f696dbd65e5a131221802669b695a84809d872a0e7b24109b46d008c","text":"pub use idx::Idx; pub use rustc_index_macros::newtype_index; pub use slice::IndexSlice; #[doc(no_inline)] pub use vec::IndexVec; /// Type size assertion. The first argument is a type and the second argument is its expected size."}
{"_id":"q-en-rust-b0bf09e7e8cb60dad83632b61102d5b1c43ae7ba04d38cb09e3930a2797c1e7b","text":" fn foo(t: T) { || { t; t; }; //~ ERROR: use of moved value } fn main() {} "}
{"_id":"q-en-rust-b10b6ef5edbfb1e73e112bf8f5fa49cf5699c698bbbdbc8086a67d78d7fed805","text":"placeholder_type_error(tcx, None, &[], visitor.0, false); } hir::TraitItemKind::Type(_, None) => {} hir::TraitItemKind::Type(_, None) => { // #74612: Visit and try to find bad placeholders // even if there is no concrete type. let mut visitor = PlaceholderHirTyCollector::default(); visitor.visit_trait_item(trait_item); placeholder_type_error(tcx, None, &[], visitor.0, false); } }; tcx.ensure().predicates_of(def_id);"}
{"_id":"q-en-rust-b111cee88113aab44e0e7a620b5688b5e609d8d74eabb1430ecdb1a13081dc57","text":" // check-pass // ignore-emscripten no llvm_asm! support #![feature(llvm_asm)] pub fn boot(addr: Option) { unsafe { llvm_asm!(\"mov sp, $0\"::\"r\" (addr)); } } fn main() {} "}
{"_id":"q-en-rust-b150561dce4936de3f9b2917ae2d470e867c109fb77d83add17d145cb221d65b","text":" error[E0658]: attributes on expressions are experimental --> $DIR/issue-88476.rs:20:13 | LL | let x = #[rustc_capture_analysis] move || { | ^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: see issue #15701 for more information = help: add `#![feature(stmt_expr_attributes)]` to the crate attributes to enable error[E0658]: attributes on expressions are experimental --> $DIR/issue-88476.rs:47:13 | LL | let c = #[rustc_capture_analysis] move || { | ^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: see issue #15701 for more information = help: add `#![feature(stmt_expr_attributes)]` to the crate attributes to enable error: First Pass analysis includes: --> $DIR/issue-88476.rs:20:39 | LL | let x = #[rustc_capture_analysis] move || { | _______________________________________^ LL | | LL | | LL | | ... | LL | | LL | | }; | |_____^ | note: Capturing f[(0, 0)] -> ImmBorrow --> $DIR/issue-88476.rs:25:26 | LL | println!(\"{:?}\", f.0); | ^^^ error: Min Capture analysis includes: --> $DIR/issue-88476.rs:20:39 | LL | let x = #[rustc_capture_analysis] move || { | _______________________________________^ LL | | LL | | LL | | ... | LL | | LL | | }; | |_____^ | note: Min Capture f[] -> ByValue --> $DIR/issue-88476.rs:25:26 | LL | println!(\"{:?}\", f.0); | ^^^ error: First Pass analysis includes: --> $DIR/issue-88476.rs:47:39 | LL | let c = #[rustc_capture_analysis] move || { | _______________________________________^ LL | | LL | | LL | | ... | LL | | LL | | }; | |_____^ | note: Capturing character[(0, 0)] -> ImmBorrow --> $DIR/issue-88476.rs:52:24 | LL | println!(\"{}\", character.hp) | ^^^^^^^^^^^^ error: Min Capture analysis includes: --> $DIR/issue-88476.rs:47:39 | LL | let c = #[rustc_capture_analysis] move || { | _______________________________________^ LL | | LL | | LL | | ... | LL | | LL | | }; | |_____^ | note: Min Capture character[(0, 0)] -> ByValue --> $DIR/issue-88476.rs:52:24 | LL | println!(\"{}\", character.hp) | ^^^^^^^^^^^^ error: aborting due to 6 previous errors For more information about this error, try `rustc --explain E0658`. "}
{"_id":"q-en-rust-b15d9a86303e4228816f3fdf91c20ab0a22b4314015bcbf15925ebba1bc682d4","text":"build::CondBr(bcx, cond.immediate(), lltrue, llfalse, DebugLoc::None); } mir::Terminator::Switch { .. } => { unimplemented!() mir::Terminator::Switch { ref discr, ref adt_def, ref targets } => { let adt_ty = bcx.tcx().lookup_item_type(adt_def.did).ty; let represented_ty = adt::represent_type(bcx.ccx(), adt_ty); let discr_lvalue = self.trans_lvalue(bcx, discr); let discr = adt::trans_get_discr(bcx, &represented_ty, discr_lvalue.llval, None); // The else branch of the Switch can't be hit, so branch to an unreachable // instruction so LLVM knows that // FIXME it might be nice to have just one such block (created lazilly), we could // store it in the \"MIR trans\" state. let unreachable_blk = bcx.fcx.new_temp_block(\"enum-variant-unreachable\"); build::Unreachable(unreachable_blk); let switch = build::Switch(bcx, discr, unreachable_blk.llbb, targets.len()); assert_eq!(adt_def.variants.len(), targets.len()); for (adt_variant, target) in adt_def.variants.iter().zip(targets) { let llval = adt::trans_case(bcx, &*represented_ty, adt_variant.disr_val); let llbb = self.llblock(*target); build::AddCase(switch, llval, llbb) } } mir::Terminator::SwitchInt { ref discr, switch_ty, ref values, ref targets } => {"}
{"_id":"q-en-rust-b16257fbc770c45eec8f10d6d2c4a71bf60d4db5ac1f737e8320d3cd0fae3bd7","text":" // Copyright 2017 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 or the MIT license // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. #![feature(rustc_attrs)] use std::fmt; // CoerceUnsized is not implemented for tuples. You can still create // an unsized tuple by transmuting a trait object. fn any() -> T { unreachable!() } #[rustc_error] fn main() { //~ ERROR compilation successful let t: &(u8, fmt::Debug) = any(); println!(\"{:?}\", &t.1); } "}
{"_id":"q-en-rust-b16296d0a68eed85009cffa1d376aa88987cf5379552ab91a4bc6f42c97efc75","text":"None } Err(ErrorHandled::TooGeneric) => { span_bug!(tcx.def_span(expr_did), \"enum discriminant depends on generic arguments\",) tcx.sess.delay_span_bug( tcx.def_span(expr_did), \"enum discriminant depends on generic arguments\", ); None } } }"}
{"_id":"q-en-rust-b1b095e85bf1b3308a31f36d6f7ced4c1a54ecc7462fa110dc0cb6652f293963","text":"unsafe { Some((self.a.__iterator_get_unchecked(i), self.b.__iterator_get_unchecked(i))) } } else if A::MAY_HAVE_SIDE_EFFECT && self.index < self.a.size() { } else if A::MAY_HAVE_SIDE_EFFECT && self.index < self.a_len { let i = self.index; self.index += 1; self.len += 1;"}
{"_id":"q-en-rust-b1b14bc488a8c4bff9e3e5dd145163c0f1c24ddf33f8250c77daf55bfe79ec27","text":" // check that we don't forget to drop the Box if we early return before // initializing it // ignore-tidy-linelength // ignore-wasm32-bare compiled with panic=abort by default #![feature(box_syntax)] fn test() -> Option> { Some(box (None?)) } fn main() { test(); } // END RUST SOURCE // START rustc.test.ElaborateDrops.before.mir // fn test() -> std::option::Option> { // ... // bb0: { // StorageLive(_1); // StorageLive(_2); // _2 = Box(u32); // StorageLive(_3); // StorageLive(_4); // _4 = std::option::Option::::None; // _3 = const as std::ops::Try>::into_result(move _4) -> [return: bb2, unwind: bb3]; // } // bb1 (cleanup): { // resume; // } // bb2: { // StorageDead(_4); // _5 = discriminant(_3); // switchInt(move _5) -> [0isize: bb10, 1isize: bb5, otherwise: bb4]; // } // bb3 (cleanup): { // drop(_2) -> bb1; // } // bb4: { // unreachable; // } // bb5: { // StorageLive(_6); // _6 = ((_3 as Err).0: std::option::NoneError); // StorageLive(_8); // StorageLive(_9); // _9 = _6; // _8 = const >::from(move _9) -> [return: bb7, unwind: bb3]; // } // bb6: { // return; // } // bb7: { // StorageDead(_9); // _0 = const > as std::ops::Try>::from_error(move _8) -> [return: bb8, unwind: bb3]; // } // bb8: { // StorageDead(_8); // StorageDead(_6); // drop(_2) -> bb9; // } // bb9: { // StorageDead(_2); // StorageDead(_1); // StorageDead(_3); // goto -> bb6; // } // bb10: { // StorageLive(_10); // _10 = ((_3 as Ok).0: u32); // (*_2) = _10; // StorageDead(_10); // _1 = move _2; // drop(_2) -> [return: bb12, unwind: bb11]; // } // bb11 (cleanup): { // drop(_1) -> bb1; // } // bb12: { // StorageDead(_2); // _0 = std::option::Option::>::Some(move _1,); // drop(_1) -> bb13; // } // bb13: { // StorageDead(_1); // StorageDead(_3); // goto -> bb6; // } // } // END rustc.test.ElaborateDrops.before.mir "}
{"_id":"q-en-rust-b1d860b4cb49a04447681ff7432a5ab91887dab094170c2dd40bd98b5b5e71e5","text":"} } /// Constructs a new locked handle to the standard output of the current /// process. /// /// Each handle returned is a guard granting locked access to a shared /// global buffer whose access is synchronized via a mutex. If you need /// more explicit control over locking, for example, in a multi-threaded /// program, use the [`io::stdout`] function to obtain an unlocked handle, /// along with the [`Stdout::lock`] method. /// /// The lock is released when the returned guard goes out of scope. The /// returned guard also implements the [`Write`] trait for writing data. /// /// ### Note: Windows Portability Consideration /// When operating in a console, the Windows implementation of this stream does not support /// non-UTF-8 byte sequences. Attempting to write bytes that are not valid UTF-8 will return /// an error. /// /// # Examples /// /// ```no_run /// #![feature(stdio_locked)] /// use std::io::{self, Write}; /// /// fn main() -> io::Result<()> { /// let mut handle = io::stdout_locked(); /// /// handle.write_all(b\"hello world\")?; /// /// Ok(()) /// } /// ``` #[unstable(feature = \"stdio_locked\", issue = \"none\")] pub fn stdout_locked() -> StdoutLock<'static> { stdout().into_locked() } pub fn cleanup() { if let Some(instance) = STDOUT.get() { // Flush the data and disable buffering during shutdown"}
{"_id":"q-en-rust-b1f61d197db48232fc35fb1848b361c2e24073056936683e7d15d35c11259016","text":"#![feature(inherent_associated_types)] #![allow(incomplete_features)] #![deny(single_use_lifetimes)] struct Foo(T);"}
{"_id":"q-en-rust-b21eaad0d9b587eda69f4d3819fdce4ea65545a15f2fb7d0aa43c5b4012da202","text":"| help: try using `=` instead | LL - let x == 2; LL + let x = 2; | LL | let x = 2; | ~ error: aborting due to 1 previous error"}
{"_id":"q-en-rust-b251542ee486f9a814240c9cfc82a335e62dd1662ae3ef59a4153cdf1502e2e9","text":"use rustc::hir; use rustc::hir::itemlikevisit::ItemLikeVisitor; use rustc::hir::def_id::DefId; use rustc::ty::{self, TyCtxt}; use rustc::ty::{self, TyCtxt, TypeFoldable}; use rustc::ty::query::Providers; use rustc::util::nodemap::{FxHashMap, FxHashSet}; use std::collections::hash_map::Entry::{Occupied, Vacant};"}
{"_id":"q-en-rust-b25a2f9e9e87ef57d63f2de2a695e16e63e0e6c77f1cd42e075dc7586478859e","text":"match *seq_tt { TokenTree::MetaVarDecl(_, _, id) => id.name == \"vis\", TokenTree::Sequence(_, ref sub_seq) => sub_seq.op == quoted::KleeneOp::ZeroOrMore, sub_seq.op == quoted::KleeneOp::ZeroOrMore || sub_seq.op == quoted::KleeneOp::ZeroOrOne, _ => false, } }) {"}
{"_id":"q-en-rust-b261837cd593a472d8892a52cfdb6ab070dff316a68adca710e797d7a6ed0184","text":"{{- layout.external_html.before_content | safe -}} {#- -#} {{- sidebar | safe -}} {#- -#} {#- -#}