{"_id":"doc-en-rust-7056667870caa5c4389e2132ba66549631ab02685b24cbf766c50c4b7f4912ca","title":"","text":"// MACRO_RULES ITEM self.parse_item_macro_rules(vis, has_bang)? } else if self.isnt_macro_invocation() && (self.token.is_ident_named(sym::import) || self.token.is_ident_named(sym::using)) && (self.token.is_ident_named(sym::import) || self.token.is_ident_named(sym::using) || self.token.is_ident_named(sym::include) || self.token.is_ident_named(sym::require)) { return self.recover_import_as_use(); } else if self.isnt_macro_invocation() && vis.kind.is_pub() {"}
{"_id":"doc-en-rust-2090e57d0624a1568785c284618483d213821ec3385063743ba70736df9c22f8","title":"","text":"repr_packed, repr_simd, repr_transparent, require, residual, result, rhs,"}
{"_id":"doc-en-rust-3937befccddb58fa4371176614abea8e7a98d3b3e724af484a168849f34a4552","title":"","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":"doc-en-rust-2d160c63e6053f1422eb434106ecea94f5004727466568380059d3de309db222","title":"","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":"doc-en-rust-fd29f124f5f6d13bdfde292b1855d240b3e6d73dcca6558fe433fd27f477a5a2","title":"","text":"LL | import std::{ | ^^^^^^ help: items are imported using the `use` keyword error: expected item, found `require` --> $DIR/use_instead_of_import.rs:9:1 | LL | require std::time::Duration; | ^^^^^^^ help: items are imported using the `use` keyword error: expected item, found `include` --> $DIR/use_instead_of_import.rs:12:1 | LL | include std::time::Instant; | ^^^^^^^ help: items are imported using the `use` keyword error: expected item, found `using` --> $DIR/use_instead_of_import.rs:9:5 --> $DIR/use_instead_of_import.rs:15:5 | LL | pub using std::io; | ^^^^^ help: items are imported using the `use` keyword error: aborting due to 2 previous errors error: aborting due to 4 previous errors "}
{"_id":"doc-en-rust-c6b37c06a0fc1d4f666438c70792297baddee9f0dc3f75dbd46c5d205321aa3b","title":"","text":"evaluation_cache: self.evaluation_cache.clone(), reported_trait_errors: self.reported_trait_errors.clone(), reported_closure_mismatch: self.reported_closure_mismatch.clone(), tainted_by_errors_flag: self.tainted_by_errors_flag.clone(), tainted_by_errors: self.tainted_by_errors.clone(), err_count_on_creation: self.err_count_on_creation, in_snapshot: self.in_snapshot.clone(), universe: self.universe.clone(),"}
{"_id":"doc-en-rust-3bf783b08325d9235213c336bd399a49cc8ebfc3d43f5ae374e85ea4264cb855","title":"","text":"use rustc_middle::ty::{self, GenericParamDefKind, InferConst, Ty, TyCtxt}; use rustc_middle::ty::{ConstVid, FloatVid, IntVid, TyVid}; use rustc_span::symbol::Symbol; use rustc_span::Span; use rustc_span::{Span, DUMMY_SP}; use std::cell::{Cell, Ref, RefCell}; use std::fmt;"}
{"_id":"doc-en-rust-c34ff36c5819853993b0ba0b8c9e7541b4720bc72be278b801d9497722981b24","title":"","text":"/// /// Don't read this flag directly, call `is_tainted_by_errors()` /// and `set_tainted_by_errors()`. tainted_by_errors_flag: Cell, tainted_by_errors: Cell /// Track how many errors were reported when this infcx is created. /// If the number of errors increases, that's also a sign (line /// `tainted_by_errors`) to avoid reporting certain kinds of errors. // FIXME(matthewjasper) Merge into `tainted_by_errors_flag` // FIXME(matthewjasper) Merge into `tainted_by_errors` err_count_on_creation: usize, /// This flag is true while there is an active snapshot."}
{"_id":"doc-en-rust-0a306832aa6a000b833284314c28c8451cd42f0ec85f49f6c97d77ccb9a86b54","title":"","text":"evaluation_cache: Default::default(), reported_trait_errors: Default::default(), reported_closure_mismatch: Default::default(), tainted_by_errors_flag: Cell::new(false), tainted_by_errors: Cell::new(None), err_count_on_creation: tcx.sess.err_count(), in_snapshot: Cell::new(false), skip_leak_check: Cell::new(false),"}
{"_id":"doc-en-rust-4257c97358de787c6649111b827e92c9916beb60830e911a33d925523ca5e5b8","title":"","text":"pub fn is_tainted_by_errors(&self) -> bool { debug!( \"is_tainted_by_errors(err_count={}, err_count_on_creation={}, tainted_by_errors_flag={})\", tainted_by_errors={})\", self.tcx.sess.err_count(), self.err_count_on_creation, self.tainted_by_errors_flag.get() self.tainted_by_errors.get().is_some() ); if self.tcx.sess.err_count() > self.err_count_on_creation { return true; // errors reported since this infcx was made } self.tainted_by_errors_flag.get() self.tainted_by_errors.get().is_some() } /// Set the \"tainted by errors\" flag to true. We call this when we /// observe an error from a prior pass. pub fn set_tainted_by_errors(&self) { debug!(\"set_tainted_by_errors()\"); self.tainted_by_errors_flag.set(true) self.tainted_by_errors.set(Some( self.tcx.sess.delay_span_bug(DUMMY_SP, \"`InferCtxt` incorrectly tainted by errors\"), )); } pub fn skip_region_resolution(&self) {"}
{"_id":"doc-en-rust-2ba17c1a3a62b6ad460d48d265c3512dbdada175b91cdd5b67d86f177c17f3f8","title":"","text":"debug!(\"impossible_predicates(predicates={:?})\", predicates); let result = tcx.infer_ctxt().enter(|infcx| { // HACK: Set tainted by errors to gracefully exit in case of overflow. infcx.set_tainted_by_errors(); let param_env = ty::ParamEnv::reveal_all(); let ocx = ObligationCtxt::new(&infcx); let predicates = ocx.normalize(ObligationCause::dummy(), param_env, predicates);"}
{"_id":"doc-en-rust-54d344af229ce5bc15c53b3cacf0604457cbbc8368c57cc58f67974baa6fa4c3","title":"","text":") -> io::Result<(Process, StdioPipes)> { let maybe_env = self.env.capture_if_changed(); let mut si = zeroed_startupinfo(); si.cb = mem::size_of::() as c::DWORD; si.dwFlags = c::STARTF_USESTDHANDLES; let child_paths = if let Some(env) = maybe_env.as_ref() { env.get(&EnvKey::new(\"PATH\")).map(|s| s.as_os_str()) } else {"}
{"_id":"doc-en-rust-ecaf766429da3cb39a24662faf2fba601016acd17963794365ed16d77add8e14","title":"","text":"let stdin = stdin.to_handle(c::STD_INPUT_HANDLE, &mut pipes.stdin)?; let stdout = stdout.to_handle(c::STD_OUTPUT_HANDLE, &mut pipes.stdout)?; let stderr = stderr.to_handle(c::STD_ERROR_HANDLE, &mut pipes.stderr)?; si.hStdInput = stdin.as_raw_handle(); si.hStdOutput = stdout.as_raw_handle(); si.hStdError = stderr.as_raw_handle(); let mut si = zeroed_startupinfo(); si.cb = mem::size_of::() as c::DWORD; // If at least one of stdin, stdout or stderr are set (i.e. are non null) // then set the `hStd` fields in `STARTUPINFO`. // Otherwise skip this and allow the OS to apply its default behaviour. // This provides more consistent behaviour between Win7 and Win8+. let is_set = |stdio: &Handle| !stdio.as_raw_handle().is_null(); if is_set(&stderr) || is_set(&stdout) || is_set(&stdin) { si.dwFlags |= c::STARTF_USESTDHANDLES; si.hStdInput = stdin.as_raw_handle(); si.hStdOutput = stdout.as_raw_handle(); si.hStdError = stderr.as_raw_handle(); } unsafe { cvt(c::CreateProcessW("}
{"_id":"doc-en-rust-6af0fa357d87249fcbdcb679bb77bef51807ac4a63f9bfb14e129e24cfdb105d","title":"","text":"impl Stdio { fn to_handle(&self, stdio_id: c::DWORD, pipe: &mut Option) -> io::Result { match *self { // If no stdio handle is available, then inherit means that it // should still be unavailable so propagate the // INVALID_HANDLE_VALUE. Stdio::Inherit => match stdio::get_handle(stdio_id) { Ok(io) => unsafe { let io = Handle::from_raw_handle(io);"}
{"_id":"doc-en-rust-cd2229b39040254922f5a71432e893609b54c849643880396f46f9976e3f4ada","title":"","text":"io.into_raw_handle(); ret }, Err(..) => unsafe { Ok(Handle::from_raw_handle(c::INVALID_HANDLE_VALUE)) }, // If no stdio handle is available, then propagate the null value. Err(..) => unsafe { Ok(Handle::from_raw_handle(ptr::null_mut())) }, }, Stdio::MakePipe => {"}
{"_id":"doc-en-rust-9db789eb9ce0ad62e91b3e3b6ce649e5337381d0570b1f7163831c4db438eac9","title":"","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":"doc-en-rust-05645dbc1cbb823f58a73250d2b17eb9dac19efbe05da71700edf033e3ac3193","title":"","text":" #![feature(type_alias_impl_trait)] // check-pass trait Trait {} type TAIT = impl Trait; struct Concrete; impl Trait for Concrete {} fn tait() -> TAIT { Concrete } trait OuterTrait { type Item; } struct Dummy { t: T, } impl OuterTrait for Dummy { type Item = T; } fn tait_and_impl_trait() -> impl OuterTrait { Dummy { t: (tait(), Concrete), } } fn tait_and_dyn_trait() -> impl OuterTrait)> { let b: Box = Box::new(Concrete); Dummy { t: (tait(), b) } } fn main() {} "}
{"_id":"doc-en-rust-44633bfd8f6c39a40e9abfe980c14386621afa388b76d9f091bafcfbd3fe8e84","title":"","text":"/// For more, see [this pull request](https://github.com/rust-lang/rust/pull/100591). pub const VERSION_\": &str = \"CURRENT_RUSTC_VERSION\"; pub fn rust_version_symbol() -> Symbol { let version = option_env!(\"CFG_VERSION\").unwrap_or(\"\"); let version = version.split(' ').next().unwrap(); Symbol::intern(&version) } pub fn is_builtin_attr(attr: &Attribute) -> bool { attr.is_doc_comment() || attr.ident().filter(|ident| is_builtin_attr_name(ident.name)).is_some() }"}
{"_id":"doc-en-rust-b7647d6b2ced098605b8fc4bccfc9b21bfe930f6ecda0c352201711711570744","title":"","text":"} if let Some(s) = since && s.as_str() == VERSION_\" { let version = option_env!(\"CFG_VERSION\").unwrap_or(\"\"); let version = version.split(' ').next().unwrap(); since = Some(Symbol::intern(&version)); since = Some(rust_version_symbol()); } match (feature, since) {"}
{"_id":"doc-en-rust-2976d489441441226a188893de77650f51659ed992e3fa78d9ba3b4ebce2c4ba","title":"","text":"//! collect them instead. use rustc_ast::{Attribute, MetaItemKind}; use rustc_attr::VERSION_\"; use rustc_attr::{rust_version_symbol, VERSION_\"}; use rustc_errors::struct_span_err; use rustc_hir::intravisit::Visitor; use rustc_middle::hir::nested_filter;"}
{"_id":"doc-en-rust-9d8f89a9adf9bf975aaeff9b44f46ce9868086d88da01a33e9414795e655fa4b","title":"","text":"} if let Some(s) = since && s.as_str() == VERSION_\" { let version = option_env!(\"CFG_VERSION\").unwrap_or(\"\"); let version = version.split(' ').next().unwrap(); since = Some(Symbol::intern(&version)); since = Some(rust_version_symbol()); } if let Some(feature) = feature {"}
{"_id":"doc-en-rust-85a4b4a59ea49777c3b80cf80a90c4b7b1465824ff51535c94626de4efa02ea4","title":"","text":"//! propagating default levels lexically from parent to children ast nodes. use rustc_attr::{ self as attr, ConstStability, Stability, StabilityLevel, Unstable, UnstableReason, self as attr, rust_version_symbol, ConstStability, Stability, StabilityLevel, Unstable, UnstableReason, VERSION_\", }; use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap}; use rustc_errors::{struct_span_err, Applicability};"}
{"_id":"doc-en-rust-441a9cf30e741a15f9a0a737c65293235af8ee3b3ae271ea8b20d472ea2d811d","title":"","text":"}); } fn unnecessary_stable_feature_lint(tcx: TyCtxt<'_>, span: Span, feature: Symbol, since: Symbol) { fn unnecessary_stable_feature_lint( tcx: TyCtxt<'_>, span: Span, feature: Symbol, mut since: Symbol, ) { if since.as_str() == VERSION_\" { since = rust_version_symbol(); } tcx.struct_span_lint_hir(lint::builtin::STABLE_FEATURES, hir::CRATE_HIR_ID, span, |lint| { lint.build(&format!( \"the feature `{feature}` has been stable since {since} and no longer requires an "}
{"_id":"doc-en-rust-0182e7b02ee886a9103ad63d5d10a5dbf305eb563bcde7ff26999f74b07c8142","title":"","text":"use rustc_middle::ty::layout::{LayoutError, LayoutOf}; use rustc_middle::ty::print::with_no_trimmed_paths; use rustc_middle::ty::GenericArgKind; use rustc_middle::ty::ToPredicate; use rustc_middle::ty::TypeVisitableExt; use rustc_middle::ty::{self, Instance, Ty, TyCtxt, VariantDef}; use rustc_session::config::ExpectedValues;"}
{"_id":"doc-en-rust-db3496e111c9f26cefa2d189071bab94ef0e8f092c608a0ae1eb25be2b0138dd","title":"","text":"use rustc_span::{BytePos, InnerSpan, Span}; use rustc_target::abi::{Abi, FIRST_VARIANT}; use rustc_trait_selection::infer::{InferCtxtExt, TyCtxtInferExt}; use rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt as _; use rustc_trait_selection::traits::{self, misc::type_allowed_to_implement_copy}; use crate::nonstandard_style::{method_context, MethodLateContext};"}
{"_id":"doc-en-rust-f9b49c64a5dd752173a312fc981fa90f666d649e95698e2751d64cf2aa87e9e9","title":"","text":"if ty.is_copy_modulo_regions(cx.tcx, param_env) { return; } if type_implements_negative_copy_modulo_regions(cx.tcx, ty, param_env) { return; } // We shouldn't recommend implementing `Copy` on stateful things, // such as iterators."}
{"_id":"doc-en-rust-56c820a632968938e0b04f79fcf45c273660c28612d677c71ac328679bb66568","title":"","text":"} } /// Check whether a `ty` has a negative `Copy` implementation, ignoring outlives constraints. fn type_implements_negative_copy_modulo_regions<'tcx>( tcx: TyCtxt<'tcx>, ty: Ty<'tcx>, param_env: ty::ParamEnv<'tcx>, ) -> bool { let trait_ref = ty::TraitRef::new(tcx, tcx.require_lang_item(hir::LangItem::Copy, None), [ty]); let pred = ty::TraitPredicate { trait_ref, polarity: ty::ImplPolarity::Negative }; let obligation = traits::Obligation { cause: traits::ObligationCause::dummy(), param_env, recursion_depth: 0, predicate: ty::Binder::dummy(pred).to_predicate(tcx), }; tcx.infer_ctxt().build().predicate_must_hold_modulo_regions(&obligation) } declare_lint! { /// The `missing_debug_implementations` lint detects missing /// implementations of [`fmt::Debug`] for public types."}
{"_id":"doc-en-rust-24892396c291ca234c5fcddbc1ebaa73e7c2768b65a8d1b89aec8d9929935f2d","title":"","text":" // Regression test for issue #101980. // Ensure that we don't suggest impl'ing `Copy` for a type if it already impl's `!Copy`. // check-pass #![feature(negative_impls)] #![deny(missing_copy_implementations)] pub struct Struct { pub field: i32, } impl !Copy for Struct {} fn main() {} "}
{"_id":"doc-en-rust-02e3a766dff3bf66db915472ba62a57c8e018d242df50cb51cd72e1b481a2a34","title":"","text":"sig.decl.has_self(), sig.decl.inputs.iter().map(|Param { ty, .. }| (None, &**ty)), &sig.decl.output, ) ); this.record_lifetime_params_for_async( fn_id, sig.header.asyncness.opt_return_id(), ); }, ); return;"}
{"_id":"doc-en-rust-a8e21958f0ec6610380c4129acbb2817b2ea7b217afb9563e4e9fb14b3843957","title":"","text":"}, ); // Construct the list of in-scope lifetime parameters for async lowering. // We include all lifetime parameters, either named or \"Fresh\". // The order of those parameters does not matter, as long as it is // deterministic. if let Some((async_node_id, _)) = async_node_id { let mut extra_lifetime_params = this .r .extra_lifetime_params_map .get(&fn_id) .cloned() .unwrap_or_default(); for rib in this.lifetime_ribs.iter().rev() { extra_lifetime_params.extend( rib.bindings .iter() .map(|(&ident, &(node_id, res))| (ident, node_id, res)), ); match rib.kind { LifetimeRibKind::Item => break, LifetimeRibKind::AnonymousCreateParameter { binder, .. } => { if let Some(earlier_fresh) = this.r.extra_lifetime_params_map.get(&binder) { extra_lifetime_params.extend(earlier_fresh); } } _ => {} } } this.r .extra_lifetime_params_map .insert(async_node_id, extra_lifetime_params); } this.record_lifetime_params_for_async(fn_id, async_node_id); if let Some(body) = body { // Ignore errors in function bodies if this is rustdoc"}
{"_id":"doc-en-rust-9fb0599d05137dd818c9e4b2c1e86f8ff2902c9f05836ff418a3af713785d9ea","title":"","text":"Some((ident.name, ns)), ) } /// Construct the list of in-scope lifetime parameters for async lowering. /// We include all lifetime parameters, either named or \"Fresh\". /// The order of those parameters does not matter, as long as it is /// deterministic. fn record_lifetime_params_for_async( &mut self, fn_id: NodeId, async_node_id: Option<(NodeId, Span)>, ) { if let Some((async_node_id, _)) = async_node_id { let mut extra_lifetime_params = self.r.extra_lifetime_params_map.get(&fn_id).cloned().unwrap_or_default(); for rib in self.lifetime_ribs.iter().rev() { extra_lifetime_params.extend( rib.bindings.iter().map(|(&ident, &(node_id, res))| (ident, node_id, res)), ); match rib.kind { LifetimeRibKind::Item => break, LifetimeRibKind::AnonymousCreateParameter { binder, .. } => { if let Some(earlier_fresh) = self.r.extra_lifetime_params_map.get(&binder) { extra_lifetime_params.extend(earlier_fresh); } } _ => {} } } self.r.extra_lifetime_params_map.insert(async_node_id, extra_lifetime_params); } } } struct LifetimeCountVisitor<'a, 'b> {"}
{"_id":"doc-en-rust-da1a6bed0f4116fac10eaaacba8e8642205cdfb824d58d4339339f2e45b9f222","title":"","text":" // check-pass // edition:2021 #![feature(async_fn_in_trait)] #![allow(incomplete_features)] use std::future::Future; async fn yield_now() {} trait AsyncIterator { type Item; async fn next(&mut self) -> Option; } struct YieldingRange { counter: u32, stop: u32, } impl AsyncIterator for YieldingRange { type Item = u32; async fn next(&mut self) -> Option { if self.counter == self.stop { None } else { let c = self.counter; self.counter += 1; yield_now().await; Some(c) } } } async fn async_main() { let mut x = YieldingRange { counter: 0, stop: 10 }; while let Some(v) = x.next().await { println!(\"Hi: {v}\"); } } fn main() { let _ = async_main(); } "}
{"_id":"doc-en-rust-77734f58fb8629179652a8a9d0a77c01c314c1309a90a82c4ac9425542a88265","title":"","text":" // check-pass // This is currently stable behavior, which was almost accidentally made an // error in #102161 since there is no test exercising it. I am not sure if // this _should_ be the desired behavior, but at least we should know if it // changes. fn main() {} trait Foo { fn fn_with_type_named_same_as_local_in_param(b: i32, b: i32); } "}
{"_id":"doc-en-rust-92afa4c517d574ea738d12ce891ab5dda486a706939b9b6862f9c5fb70ee3f1d","title":"","text":"ObligationCauseCode::BinOp { rhs_span: Some(span), is_lit, .. } if *is_lit => span, _ => return, }; match ( trait_ref.skip_binder().self_ty().kind(), trait_ref.skip_binder().substs.type_at(1).kind(), ) { (ty::Float(_), ty::Infer(InferTy::IntVar(_))) => { err.span_suggestion_verbose( rhs_span.shrink_to_hi(), \"consider using a floating-point literal by writing it with `.0`\", \".0\", Applicability::MaybeIncorrect, ); } _ => {} if let ty::Float(_) = trait_ref.skip_binder().self_ty().kind() && let ty::Infer(InferTy::IntVar(_)) = trait_ref.skip_binder().substs.type_at(1).kind() { err.span_suggestion_verbose( rhs_span.shrink_to_hi(), \"consider using a floating-point literal by writing it with `.0`\", \".0\", Applicability::MaybeIncorrect, ); } }"}
{"_id":"doc-en-rust-fda898e805a955831d4473dde614d16dcebde74e7ee066da515af713ceff86d0","title":"","text":" // normalize-stderr-test \"loaded from .*libcore-.*.rlib\" -> \"loaded from SYSROOT/libcore-*.rlib\" #![feature(lang_items)] #[lang=\"sized\"] trait Sized { } //~ ERROR found duplicate lang item `sized` fn ref_Struct(self: &Struct, f: &u32) -> &u32 { //~^ ERROR `self` parameter is only allowed in associated functions //~| ERROR cannot find type `Struct` in this scope //~| ERROR mismatched types let x = x << 1; //~^ ERROR the size for values of type `{integer}` cannot be known at compilation time //~| ERROR cannot find value `x` in this scope } fn main() {} "}
{"_id":"doc-en-rust-47144db209e1940cb25db3df84cb41043230e6bbfc1ec86596306b61d4330788","title":"","text":" error: `self` parameter is only allowed in associated functions --> $DIR/issue-102989.rs:7:15 | LL | fn ref_Struct(self: &Struct, f: &u32) -> &u32 { | ^^^^ not semantically valid as function parameter | = note: associated functions are those in `impl` or `trait` definitions error[E0412]: cannot find type `Struct` in this scope --> $DIR/issue-102989.rs:7:22 | LL | fn ref_Struct(self: &Struct, f: &u32) -> &u32 { | ^^^^^^ not found in this scope error[E0425]: cannot find value `x` in this scope --> $DIR/issue-102989.rs:11:13 | LL | let x = x << 1; | ^ help: a local variable with a similar name exists: `f` error[E0152]: found duplicate lang item `sized` --> $DIR/issue-102989.rs:5:1 | LL | trait Sized { } | ^^^^^^^^^^^ | = note: the lang item is first defined in crate `core` (which `std` depends on) = note: first definition in `core` loaded from SYSROOT/libcore-*.rlib = note: second definition in the local crate (`issue_102989`) error[E0277]: the size for values of type `{integer}` cannot be known at compilation time --> $DIR/issue-102989.rs:11:15 | LL | let x = x << 1; | ^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `{integer}` error[E0308]: mismatched types --> $DIR/issue-102989.rs:7:42 | LL | fn ref_Struct(self: &Struct, f: &u32) -> &u32 { | ---------- ^^^^ expected `&u32`, found `()` | | | implicitly returns `()` as its body has no tail or `return` expression | note: consider returning one of these bindings --> $DIR/issue-102989.rs:7:30 | LL | fn ref_Struct(self: &Struct, f: &u32) -> &u32 { | ^ ... LL | let x = x << 1; | ^ error: aborting due to 6 previous errors Some errors have detailed explanations: E0152, E0277, E0308, E0412, E0425. For more information about an error, try `rustc --explain E0152`. "}
{"_id":"doc-en-rust-a9c6233e752f9fb8cb0e7282740f64cf89ab6f060a66c16bc4dabea907ce7d03","title":"","text":"if self.eat(&token::ModSep) { self.parse_use_tree_glob_or_nested()? } else { // Recover from using a colon as path separator. while self.eat_noexpect(&token::Colon) { self.struct_span_err(self.prev_token.span, \"expected `::`, found `:`\") .span_suggestion_short( self.prev_token.span, \"use double colon\", \"::\", Applicability::MachineApplicable, ) .note_once(\"import paths are delimited using `::`\") .emit(); // We parse the rest of the path and append it to the original prefix. self.parse_path_segments(&mut prefix.segments, PathStyle::Mod, None)?; prefix.span = lo.to(self.prev_token.span); } UseTreeKind::Simple(self.parse_rename()?, DUMMY_NODE_ID, DUMMY_NODE_ID) } };"}
{"_id":"doc-en-rust-fa5b03ec9710e45f391403c90b13846340e9993e03218ee5f434be34949992a6","title":"","text":" // Recover from using a colon as a path separator. use std::process:Command; //~^ ERROR expected `::`, found `:` use std:fs::File; //~^ ERROR expected `::`, found `:` use std:collections:HashMap; //~^ ERROR expected `::`, found `:` //~| ERROR expected `::`, found `:` fn main() { } "}
{"_id":"doc-en-rust-df889ba31afc3a50434345e10a55e3c7659c210560e588d2096ca81c05e504b1","title":"","text":" error: expected `::`, found `:` --> $DIR/use-colon-as-mod-sep.rs:3:17 | LL | use std::process:Command; | ^ help: use double colon | = note: import paths are delimited using `::` error: expected `::`, found `:` --> $DIR/use-colon-as-mod-sep.rs:5:8 | LL | use std:fs::File; | ^ help: use double colon error: expected `::`, found `:` --> $DIR/use-colon-as-mod-sep.rs:7:8 | LL | use std:collections:HashMap; | ^ help: use double colon error: expected `::`, found `:` --> $DIR/use-colon-as-mod-sep.rs:7:20 | LL | use std:collections:HashMap; | ^ help: use double colon error: aborting due to 4 previous errors "}
{"_id":"doc-en-rust-58e9ff172c034e4991db0bcc12b7e9048afa66bde5bc5b560f93f53a1b93d50a","title":"","text":"#include_next // mingw 4.0.x has broken headers (#9246) but mingw-w64 does not. #if defined(__MINGW_MAJOR_VERSION) && __MINGW_MAJOR_VERSION == 4 typedef struct pollfd { SOCKET fd; short events;"}
{"_id":"doc-en-rust-9e89ecf45186ab847f40849727c621b7a719d62a9429c54490cff10fc0ba0a71","title":"","text":"} WSAPOLLFD, *PWSAPOLLFD, *LPWSAPOLLFD; #endif #endif // _FIX_WINSOCK2_H "}
{"_id":"doc-en-rust-837eeb911501a35af3d3c2cac8b9dc5eb77d393cb1e24e916b69cbce45a4b1f8","title":"","text":"use smallvec::{smallvec, SmallVec}; use rustc_span::source_map::{respan, Spanned}; use std::assert_matches::debug_assert_matches; use std::collections::{hash_map::Entry, BTreeSet}; use std::mem::{replace, take};"}
{"_id":"doc-en-rust-4fbf3e80629176effa7581f4a0f3d57e82e6f697ef0423f0de619c38d63cbf3e","title":"","text":"/// They will be used to determine the correct lifetime for the fn return type. /// The `LifetimeElisionCandidate` is used for diagnostics, to suggest introducing named /// lifetimes. lifetime_elision_candidates: Option>, lifetime_elision_candidates: Option>, /// The trait that the current context can refer to. current_trait_ref: Option<(Module<'a>, TraitRef)>,"}
{"_id":"doc-en-rust-9b1328d7b3a6cba5c7fa35efd8b23e6f7c749f653154697886a4ecedaf382f5b","title":"","text":"match res { LifetimeRes::Param { .. } | LifetimeRes::Fresh { .. } | LifetimeRes::Static => { if let Some(ref mut candidates) = self.lifetime_elision_candidates { candidates.insert(res, candidate); candidates.push((res, candidate)); } } LifetimeRes::Infer | LifetimeRes::Error | LifetimeRes::ElidedAnchor { .. } => {}"}
{"_id":"doc-en-rust-fa0f8312b9ad0beff90fd9077d1f9bfeff45aaf7aec38cc7af940920851565a4","title":"","text":"has_self: bool, inputs: impl Iterator, &'ast Ty)>, ) -> Result, Vec)> { let outer_candidates = replace(&mut self.lifetime_elision_candidates, Some(Default::default())); enum Elision { /// We have not found any candidate. None, /// We have a candidate bound to `self`. Self_(LifetimeRes), /// We have a candidate bound to a parameter. Param(LifetimeRes), /// We failed elision. Err, } let mut elision_lifetime = None; let mut lifetime_count = 0; // Save elision state to reinstate it later. let outer_candidates = self.lifetime_elision_candidates.take(); // Result of elision. let mut elision_lifetime = Elision::None; // Information for diagnostics. let mut parameter_info = Vec::new(); let mut all_candidates = Vec::new(); let mut bindings = smallvec![(PatBoundCtx::Product, Default::default())]; for (index, (pat, ty)) in inputs.enumerate() {"}
{"_id":"doc-en-rust-189261a499bb08681b9183b981e66e8bde9cb3111e2695c6a972222b68383b08","title":"","text":"this.resolve_pattern(pat, PatternSource::FnParam, &mut bindings); } }); // Record elision candidates only for this parameter. debug_assert_matches!(self.lifetime_elision_candidates, None); self.lifetime_elision_candidates = Some(Default::default()); self.visit_ty(ty); let local_candidates = self.lifetime_elision_candidates.take(); if let Some(ref candidates) = self.lifetime_elision_candidates { let new_count = candidates.len(); let local_count = new_count - lifetime_count; if local_count != 0 { if let Some(candidates) = local_candidates { let distinct: FxHashSet<_> = candidates.iter().map(|(res, _)| *res).collect(); let lifetime_count = distinct.len(); if lifetime_count != 0 { parameter_info.push(ElisionFnParameter { index, ident: if let Some(pat) = pat && let PatKind::Ident(_, ident, _) = pat.kind {"}
{"_id":"doc-en-rust-6c449252388b9c1801c7e335801bcfec3bbd9412ca05e481c24f75e38aa91054","title":"","text":"} else { None }, lifetime_count: local_count, lifetime_count, span: ty.span, }); all_candidates.extend(candidates.into_iter().filter_map(|(_, candidate)| { match candidate { LifetimeElisionCandidate::Ignore | LifetimeElisionCandidate::Named => { None } LifetimeElisionCandidate::Missing(missing) => Some(missing), } })); } let mut distinct_iter = distinct.into_iter(); if let Some(res) = distinct_iter.next() { match elision_lifetime { // We are the first parameter to bind lifetimes. Elision::None => { if distinct_iter.next().is_none() { // We have a single lifetime => success. elision_lifetime = Elision::Param(res) } else { // We have have multiple lifetimes => error. elision_lifetime = Elision::Err; } } // We have 2 parameters that bind lifetimes => error. Elision::Param(_) => elision_lifetime = Elision::Err, // `self` elision takes precedence over everything else. Elision::Self_(_) | Elision::Err => {} } } lifetime_count = new_count; } // Handle `self` specially. if index == 0 && has_self { let self_lifetime = self.find_lifetime_for_self(ty); if let Set1::One(lifetime) = self_lifetime { elision_lifetime = Some(lifetime); self.lifetime_elision_candidates = None; // We found `self` elision. elision_lifetime = Elision::Self_(lifetime); } else { self.lifetime_elision_candidates = Some(Default::default()); lifetime_count = 0; // We do not have `self` elision: disregard the `Elision::Param` that we may // have found. elision_lifetime = Elision::None; } } debug!(\"(resolving function / closure) recorded parameter\"); } let all_candidates = replace(&mut self.lifetime_elision_candidates, outer_candidates); debug!(?all_candidates); // Reinstate elision state. debug_assert_matches!(self.lifetime_elision_candidates, None); self.lifetime_elision_candidates = outer_candidates; if let Some(res) = elision_lifetime { if let Elision::Param(res) | Elision::Self_(res) = elision_lifetime { return Ok(res); } // We do not have a `self` candidate, look at the full list. let all_candidates = all_candidates.unwrap(); if all_candidates.len() == 1 { Ok(*all_candidates.first().unwrap().0) } else { let all_candidates = all_candidates .into_iter() .filter_map(|(_, candidate)| match candidate { LifetimeElisionCandidate::Ignore | LifetimeElisionCandidate::Named => None, LifetimeElisionCandidate::Missing(missing) => Some(missing), }) .collect(); Err((all_candidates, parameter_info)) } // We do not have a candidate. Err((all_candidates, parameter_info)) } /// List all the lifetimes that appear in the provided type."}
{"_id":"doc-en-rust-4d395f6c0c9e5bccc7cde6c602a6be43fbe9fe7fb958dffaf6ffa5799c06a707","title":"","text":"// Do not account for the parameters we just bound for function lifetime elision. if let Some(ref mut candidates) = self.lifetime_elision_candidates { for (_, res) in function_lifetime_rib.bindings.values() { candidates.remove(res); candidates.retain(|(r, _)| r != res); } }"}
{"_id":"doc-en-rust-fe57bb6977b9fc0c261f90e7f63aa99b75e2faf69723f81d747f9eb2d0510874","title":"","text":"//! Type-relative name resolution (methods, fields, associated items) happens in `rustc_hir_analysis`. #![doc(html_root_url = \"https://doc.rust-lang.org/nightly/nightly-rustc/\")] #![feature(assert_matches)] #![feature(box_patterns)] #![feature(drain_filter)] #![feature(if_let_guard)]"}
{"_id":"doc-en-rust-b6121ff6258fa2a1cab677cd83456d4e8eb9aa5a3dfb766e909d334b6d4b8c61","title":"","text":"panic!() } fn l<'a>(_: &'a str, _: &'a str) -> &str { \"\" } //~^ ERROR missing lifetime specifier // This is ok because both `'a` are for the same parameter. fn m<'a>(_: &'a Foo<'a>) -> &str { \"\" } fn main() {}"}
{"_id":"doc-en-rust-af6146891cf519acdecd15708dc0a1eccd9fde4de714be1fa2bb414b830bfed9","title":"","text":"LL | fn k<'a, T: WithLifetime<'a>>(_x: T::Output) -> &'a isize { | ++ error: aborting due to 6 previous errors error[E0106]: missing lifetime specifier --> $DIR/lifetime-elision-return-type-requires-explicit-lifetime.rs:45:37 | LL | fn l<'a>(_: &'a str, _: &'a str) -> &str { \"\" } | ------- ------- ^ expected named lifetime parameter | = help: this function's return type contains a borrowed value with an elided lifetime, but the lifetime cannot be derived from the arguments help: consider using the `'a` lifetime | LL | fn l<'a>(_: &'a str, _: &'a str) -> &'a str { \"\" } | ++ error: aborting due to 7 previous errors For more information about this error, try `rustc --explain E0106`."}
{"_id":"doc-en-rust-b61f4d4b794d49b9cc3c6f043867c4ae93b1ca9a020a32bd11707036750f2bef","title":"","text":"// FIXME(#75598): Direct use of these intrinsics improves codegen significantly at opt-level <= // 1, where the method versions of these operations are not inlined. use intrinsics::{ cttz_nonzero, exact_div, unchecked_rem, unchecked_shl, unchecked_shr, unchecked_sub, wrapping_add, wrapping_mul, wrapping_sub, cttz_nonzero, exact_div, mul_with_overflow, unchecked_rem, unchecked_shl, unchecked_shr, unchecked_sub, wrapping_add, wrapping_mul, wrapping_sub, }; /// Calculate multiplicative modular inverse of `x` modulo `m`."}
{"_id":"doc-en-rust-7e92a16472b175cdf275debbb8f28c131923b7bd0804e0e3b35593e73a3c77fb","title":"","text":"const INV_TABLE_MOD_16: [u8; 8] = [1, 11, 13, 7, 9, 3, 5, 15]; /// Modulo for which the `INV_TABLE_MOD_16` is intended. const INV_TABLE_MOD: usize = 16; /// INV_TABLE_MOD² const INV_TABLE_MOD_SQUARED: usize = INV_TABLE_MOD * INV_TABLE_MOD; let table_inverse = INV_TABLE_MOD_16[(x & (INV_TABLE_MOD - 1)) >> 1] as usize; // SAFETY: `m` is required to be a power-of-two, hence non-zero. let m_minus_one = unsafe { unchecked_sub(m, 1) }; if m <= INV_TABLE_MOD { table_inverse & m_minus_one } else { // We iterate \"up\" using the following formula: // // $$ xy ≡ 1 (mod 2ⁿ) → xy (2 - xy) ≡ 1 (mod 2²ⁿ) $$ let mut inverse = INV_TABLE_MOD_16[(x & (INV_TABLE_MOD - 1)) >> 1] as usize; let mut mod_gate = INV_TABLE_MOD; // We iterate \"up\" using the following formula: // // $$ xy ≡ 1 (mod 2ⁿ) → xy (2 - xy) ≡ 1 (mod 2²ⁿ) $$ // // This application needs to be applied at least until `2²ⁿ ≥ m`, at which point we can // finally reduce the computation to our desired `m` by taking `inverse mod m`. // // This computation is `O(log log m)`, which is to say, that on 64-bit machines this loop // will always finish in at most 4 iterations. loop { // y = y * (2 - xy) mod n // // until 2²ⁿ ≥ m. Then we can reduce to our desired `m` by taking the result `mod m`. let mut inverse = table_inverse; let mut going_mod = INV_TABLE_MOD_SQUARED; loop { // y = y * (2 - xy) mod n // // Note, that we use wrapping operations here intentionally – the original formula // uses e.g., subtraction `mod n`. It is entirely fine to do them `mod // usize::MAX` instead, because we take the result `mod n` at the end // anyway. inverse = wrapping_mul(inverse, wrapping_sub(2usize, wrapping_mul(x, inverse))); if going_mod >= m { return inverse & m_minus_one; } going_mod = wrapping_mul(going_mod, going_mod); // Note, that we use wrapping operations here intentionally – the original formula // uses e.g., subtraction `mod n`. It is entirely fine to do them `mod // usize::MAX` instead, because we take the result `mod n` at the end // anyway. if mod_gate >= m { break; } inverse = wrapping_mul(inverse, wrapping_sub(2usize, wrapping_mul(x, inverse))); let (new_gate, overflow) = mul_with_overflow(mod_gate, mod_gate); if overflow { break; } mod_gate = new_gate; } inverse & m_minus_one } let addr = p.addr();"}
{"_id":"doc-en-rust-cfd2b472a1aa37b156c4d75892890f70d9522e782e8fd815d3d0a530658959fb","title":"","text":"} #[test] fn align_offset_issue_103361() { #[cfg(target_pointer_width = \"64\")] const SIZE: usize = 1 << 47; #[cfg(target_pointer_width = \"32\")] const SIZE: usize = 1 << 30; #[cfg(target_pointer_width = \"16\")] const SIZE: usize = 1 << 13; struct HugeSize([u8; SIZE - 1]); let _ = (SIZE as *const HugeSize).align_offset(SIZE); } #[test] fn offset_from() { let mut a = [0; 5]; let ptr1: *mut i32 = &mut a[1];"}
{"_id":"doc-en-rust-a02db5cb0c5862407fa3cad72dacc7d9cc16c640206d9dad7cfcd8bbd746a4d5","title":"","text":"add_constraints(&infcx, region_bound_pairs); infcx.process_registered_region_obligations( outlives_environment.region_bound_pairs(), param_env, ); let errors = infcx.resolve_regions(&outlives_environment); debug!(?errors, \"errors\");"}
{"_id":"doc-en-rust-8f3f755e0adf34f4068994b7c1d3c6f2048992ed82320af639256093a62f79c9","title":"","text":" trait TraitA { type TypeA; } trait TraitD { type TypeD; } pub trait TraitB { type TypeB: TraitD; fn f(_: &::TypeD); } pub trait TraitC { type TypeC<'a>: TraitB; fn g<'a>(_: &< as TraitB>::TypeB as TraitA>::TypeA); //~^ ERROR the trait bound `<>::TypeC<'a> as TraitB>::TypeB: TraitA` is not satisfied } fn main() {} "}
{"_id":"doc-en-rust-d6d48d86ce7d3d39944d489bf261342b568eb08e17d3bee711a8aee371f63c1c","title":"","text":" error[E0277]: the trait bound `<>::TypeC<'a> as TraitB>::TypeB: TraitA` is not satisfied --> $DIR/issue-103573.rs:18:5 | LL | fn g<'a>(_: &< as TraitB>::TypeB as TraitA>::TypeA); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `TraitA` is not implemented for `<>::TypeC<'a> as TraitB>::TypeB` | help: consider further restricting the associated type | LL | fn g<'a>(_: &< as TraitB>::TypeB as TraitA>::TypeA) where <>::TypeC<'a> as TraitB>::TypeB: TraitA; | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ error: aborting due to previous error For more information about this error, try `rustc --explain E0277`. "}
{"_id":"doc-en-rust-f92517481c39cce4c818af4d9a5c196dcc3900cb2866b062e2e2ff6c8e6ff0aa","title":"","text":"}); if check_params && let Some(args) = path.segments.last().unwrap().args { let params_in_repr = tcx.params_in_repr(def_id); for (i, arg) in args.args.iter().enumerate() { // the domain size check is needed because the HIR may not be well-formed at this point for (i, arg) in args.args.iter().enumerate().take(params_in_repr.domain_size()) { if let hir::GenericArg::Type(ty) = arg && params_in_repr.contains(i as u32) { find_item_ty_spans(tcx, ty, needle, spans, seen_representable); }"}
{"_id":"doc-en-rust-4b78a8edf4917c34202be60ba8343b377be5ce2c3368263a863bd7c0c1fe039a","title":"","text":" #![crate_type = \"lib\"] struct Apple((Apple, Option(Banana ? Citron))); //~^ ERROR invalid `?` in type //~| ERROR expected one of `)` or `,`, found `Citron` //~| ERROR cannot find type `Citron` in this scope [E0412] //~| ERROR parenthesized type parameters may only be used with a `Fn` trait [E0214] //~| ERROR recursive type `Apple` has infinite size [E0072] "}
{"_id":"doc-en-rust-214e132c49b265cedd29b99033be89db0bddf44e3ba013806046b6f06b09995d","title":"","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":"doc-en-rust-b9a5644be7969802135a608b20cb1c6f74015dd483e136bb26929cba6a40a2d3","title":"","text":"[submodule \"src/llvm-project\"] path = src/llvm-project url = https://github.com/rust-lang/llvm-project.git branch = rustc/15.0-2022-08-09 branch = rustc/15.0-2022-12-07 [submodule \"src/doc/embedded-book\"] path = src/doc/embedded-book url = https://github.com/rust-embedded/book.git"}
{"_id":"doc-en-rust-017f997a7430e643d73dc38a0754e5c799d6b5b9b8fd5d2420559c9c1117e8b5","title":"","text":" Subproject commit a1232c451fc27173f8718e05d174b2503ca0b607 Subproject commit 3dfd4d93fa013e1c0578d3ceac5c8f4ebba4b6ec "}
{"_id":"doc-en-rust-b0ba11d306adc9de6450acc368f432a7ff1985019abc4fef6e963b28e5d98133","title":"","text":" Subproject commit 3dfd4d93fa013e1c0578d3ceac5c8f4ebba4b6ec Subproject commit 9ad24035fea8d309753f5e39e6eb53d1d0eb39ce "}
{"_id":"doc-en-rust-05acab0984f3fb697017dd8f06193a02ac9cd3abe3b8a71a79dd098e22ae42d1","title":"","text":"assert!(self_ty.is_some()); } } else { assert!(self_ty.is_none() && parent_substs.is_empty()); assert!(self_ty.is_none()); } let arg_count = Self::check_generic_arg_count("}
{"_id":"doc-en-rust-7e6d7197e05ced1834aa5f04c986c38beff9078a34938b08d6dd037dad26106b","title":"","text":"// Check if we have an enum variant. let mut variant_resolution = None; if let ty::Adt(adt_def, _) = qself_ty.kind() { if let ty::Adt(adt_def, adt_substs) = qself_ty.kind() { if adt_def.is_enum() { let variant_def = adt_def .variants()"}
{"_id":"doc-en-rust-3f94dcdc7615435c26d892b5dae1e889f15aa7e2c5ef2f3d0d3253002aa88c79","title":"","text":"let Some(assoc_ty_did) = self.lookup_assoc_ty(assoc_ident, hir_ref_id, span, impl_) else { continue; }; // FIXME(inherent_associated_types): This does not substitute parameters. let ty = tcx.type_of(assoc_ty_did); let item_substs = self.create_substs_for_associated_item( span, assoc_ty_did, assoc_segment, adt_substs, ); let ty = tcx.bound_type_of(assoc_ty_did).subst(tcx, item_substs); return Ok((ty, DefKind::AssocTy, assoc_ty_did)); } }"}
{"_id":"doc-en-rust-2258414bf7cfd8eeaa8a2beae452d601589f1f35170aa4c43b9db2b1985b6149","title":"","text":" // check-pass #![feature(inherent_associated_types)] #![allow(incomplete_features)] struct S(T); impl S { type P = T; } fn main() { type A = S<()>::P; let _: A = (); } "}
{"_id":"doc-en-rust-7db83585bd4e6e58443a34c66c26106c181e90406627654f892e0ab9d272f6d3","title":"","text":"} // see if we can satisfy using an inherent associated type for impl_ in tcx.inherent_impls(adt_def.did()) { let assoc_ty = tcx.associated_items(impl_).find_by_name_and_kind( tcx, assoc_ident, ty::AssocKind::Type, *impl_, ); if let Some(assoc_ty) = assoc_ty { let ty = tcx.type_of(assoc_ty.def_id); return Ok((ty, DefKind::AssocTy, assoc_ty.def_id)); } for &impl_ in tcx.inherent_impls(adt_def.did()) { let Some(assoc_ty_did) = self.lookup_assoc_ty(assoc_ident, hir_ref_id, span, impl_) else { continue; }; // FIXME(inherent_associated_types): This does not substitute parameters. let ty = tcx.type_of(assoc_ty_did); return Ok((ty, DefKind::AssocTy, assoc_ty_did)); } }"}
{"_id":"doc-en-rust-c81afa26c7ab7af9d2d4f42166a14a2c1de6220b56ffd83b4c9b9fec5b30d104","title":"","text":"}; let trait_did = bound.def_id(); let (assoc_ident, def_scope) = tcx.adjust_ident_and_get_scope(assoc_ident, trait_did, hir_ref_id); // We have already adjusted the item name above, so compare with `ident.normalize_to_macros_2_0()` instead // of calling `filter_by_name_and_kind`. let item = tcx.associated_items(trait_did).in_definition_order().find(|i| { i.kind.namespace() == Namespace::TypeNS && i.ident(tcx).normalize_to_macros_2_0() == assoc_ident }); // Assume that if it's not matched, there must be a const defined with the same name // but it was used in a type position. let Some(item) = item else { let Some(assoc_ty_did) = self.lookup_assoc_ty(assoc_ident, hir_ref_id, span, trait_did) else { // Assume that if it's not matched, there must be a const defined with the same name // but it was used in a type position. let msg = format!(\"found associated const `{assoc_ident}` when type was expected\"); let guar = tcx.sess.struct_span_err(span, &msg).emit(); return Err(guar); }; let ty = self.projected_ty_from_poly_trait_ref(span, item.def_id, assoc_segment, bound); let ty = self.projected_ty_from_poly_trait_ref(span, assoc_ty_did, assoc_segment, bound); let ty = self.normalize_ty(span, ty); let kind = DefKind::AssocTy; if !item.visibility(tcx).is_accessible_from(def_scope, tcx) { let kind = kind.descr(item.def_id); let msg = format!(\"{} `{}` is private\", kind, assoc_ident); tcx.sess .struct_span_err(span, &msg) .span_label(span, &format!(\"private {}\", kind)) .emit(); } tcx.check_stability(item.def_id, Some(hir_ref_id), span, None); if let Some(variant_def_id) = variant_resolution { tcx.struct_span_lint_hir( AMBIGUOUS_ASSOCIATED_ITEMS,"}
{"_id":"doc-en-rust-ba8ffb29554e947e2a550289a95006fb89181d5aa6f8d59a11daf3424f68a062","title":"","text":"}; could_refer_to(DefKind::Variant, variant_def_id, \"\"); could_refer_to(kind, item.def_id, \" also\"); could_refer_to(DefKind::AssocTy, assoc_ty_did, \" also\"); lint.span_suggestion( span,"}
{"_id":"doc-en-rust-9e3fe72290f34d2b427a204710b1f5f4dcc2ca9bfec70242078c0d5a8e319b85","title":"","text":"}, ); } Ok((ty, kind, item.def_id)) Ok((ty, DefKind::AssocTy, assoc_ty_did)) } fn lookup_assoc_ty( &self, ident: Ident, block: hir::HirId, span: Span, scope: DefId, ) -> Option { let tcx = self.tcx(); let (ident, def_scope) = tcx.adjust_ident_and_get_scope(ident, scope, block); // We have already adjusted the item name above, so compare with `ident.normalize_to_macros_2_0()` instead // of calling `find_by_name_and_kind`. let item = tcx.associated_items(scope).in_definition_order().find(|i| { i.kind.namespace() == Namespace::TypeNS && i.ident(tcx).normalize_to_macros_2_0() == ident })?; let kind = DefKind::AssocTy; if !item.visibility(tcx).is_accessible_from(def_scope, tcx) { let kind = kind.descr(item.def_id); let msg = format!(\"{kind} `{ident}` is private\"); let def_span = self.tcx().def_span(item.def_id); tcx.sess .struct_span_err_with_code(span, &msg, rustc_errors::error_code!(E0624)) .span_label(span, &format!(\"private {kind}\")) .span_label(def_span, &format!(\"{kind} defined here\")) .emit(); } tcx.check_stability(item.def_id, Some(block), span, None); Some(item.def_id) } fn qpath_to_ty("}
{"_id":"doc-en-rust-5f544aed759098fa7984613b398c12008d0b1244718b7a2546d0301b1a032d81","title":"","text":" #![feature(inherent_associated_types)] #![allow(incomplete_features)] mod m { pub struct T; impl T { type P = (); } } type U = m::T::P; //~ ERROR associated type `P` is private mod n { pub mod n { pub struct T; impl T { pub(super) type P = bool; } } type U = n::T::P; } type V = n::n::T::P; //~ ERROR associated type `P` is private fn main() {} "}
{"_id":"doc-en-rust-201d247bbff9c8d0c61ea58f05f3e53aecc6939ecd33534dab1aada1d3338ab8","title":"","text":" error[E0624]: associated type `P` is private --> $DIR/assoc-inherent-private.rs:10:10 | LL | type P = (); | ------ associated type defined here ... LL | type U = m::T::P; | ^^^^^^^ private associated type error[E0624]: associated type `P` is private --> $DIR/assoc-inherent-private.rs:21:10 | LL | pub(super) type P = bool; | ----------------- associated type defined here ... LL | type V = n::n::T::P; | ^^^^^^^^^^ private associated type error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0624`. "}
{"_id":"doc-en-rust-b236a15281c4b12f62e28aeaa0a66898eed5f8eabe6b81965ee0f84502b71648","title":"","text":" // aux-crate:aux=assoc-inherent-unstable.rs // edition: 2021 type Data = aux::Owner::Data; //~ ERROR use of unstable library feature 'data' fn main() {} "}
{"_id":"doc-en-rust-be37deacec43611c6fcee98a0c274e9f591b4543595a0e3e8af660b5f511e102","title":"","text":" error[E0658]: use of unstable library feature 'data' --> $DIR/assoc-inherent-unstable.rs:4:13 | LL | type Data = aux::Owner::Data; | ^^^^^^^^^^^^^^^^ | = help: add `#![feature(data)]` to the crate attributes to enable error: aborting due to previous error For more information about this error, try `rustc --explain E0658`. "}
{"_id":"doc-en-rust-c9a9b6dc76ca22832af92b9ada0d913cd913d12c61127e5132d732717cb491d1","title":"","text":" #![feature(staged_api)] #![feature(inherent_associated_types)] #![stable(feature = \"main\", since = \"1.0.0\")] #[stable(feature = \"main\", since = \"1.0.0\")] pub struct Owner; impl Owner { #[unstable(feature = \"data\", issue = \"none\")] pub type Data = (); } "}
{"_id":"doc-en-rust-691cbe4bbc0722e43948ac73abafbfb7025c00a41869e050db05574037d93bcb","title":"","text":"LL | let _: S::C; | ^^^^ help: use fully-qualified syntax: `::C` error: associated type `A` is private error[E0624]: associated type `A` is private --> $DIR/item-privacy.rs:119:12 | LL | type A = u8; | ------ associated type defined here ... LL | let _: T::A; | ^^^^ private associated type"}
{"_id":"doc-en-rust-0e133ec912fd41620cc6adaf8104b1cc7ea9a392f56b078710cbf8929b9f5cc3","title":"","text":"/// /// assert_eq!(n.leading_zeros(), 0); /// ``` #[doc = concat!(\"[`ilog2`]: \", stringify!($SelfT), \"::ilog2\")] #[stable(feature = \"rust1\", since = \"1.0.0\")] #[rustc_const_stable(feature = \"const_int_methods\", since = \"1.32.0\")] #[must_use = \"this returns the result of the operation, "}
{"_id":"doc-en-rust-b3c6bcc568d68497bd06f1b68f2c2b5969e2be42cf7255c4c6d1c624c3cb3640","title":"","text":"/// Returns the number of leading zeros in the binary representation of `self`. /// /// Depending on what you're doing with the value, you might also be interested in the /// [`ilog2`] function which returns a consistent number, even if the type widens. /// /// # Examples /// /// Basic usage:"}
{"_id":"doc-en-rust-d614942aa4e737dbbd9da257ae6155c69f597cb5039b2938495dc8677098511e","title":"","text":"/// /// assert_eq!(n.leading_zeros(), 2); /// ``` #[doc = concat!(\"[`ilog2`]: \", stringify!($SelfT), \"::ilog2\")] #[stable(feature = \"rust1\", since = \"1.0.0\")] #[rustc_const_stable(feature = \"const_math\", since = \"1.32.0\")] #[must_use = \"this returns the result of the operation, "}
{"_id":"doc-en-rust-d26cc5d6d75fa090c3874abcf870d28893afb8d69177b689584e381f5f9e4c24","title":"","text":"}; e_flags } Architecture::Riscv64 if sess.target.options.features.contains(\"+d\") => { // copied from `riscv64-linux-gnu-gcc foo.c -c`, note though // that the `+d` target feature represents whether the double // float abi is enabled. let e_flags = elf::EF_RISCV_RVC | elf::EF_RISCV_FLOAT_ABI_DOUBLE; Architecture::Riscv32 | Architecture::Riscv64 => { // Source: https://github.com/riscv-non-isa/riscv-elf-psabi-doc/blob/079772828bd10933d34121117a222b4cc0ee2200/riscv-elf.adoc let mut e_flags: u32 = 0x0; let features = &sess.target.options.features; // Check if compressed is enabled if features.contains(\"+c\") { e_flags |= elf::EF_RISCV_RVC; } // Select the appropriate floating-point ABI if features.contains(\"+d\") { e_flags |= elf::EF_RISCV_FLOAT_ABI_DOUBLE; } else if features.contains(\"+f\") { e_flags |= elf::EF_RISCV_FLOAT_ABI_SINGLE; } else { e_flags |= elf::EF_RISCV_FLOAT_ABI_SOFT; } e_flags } _ => 0,"}
{"_id":"doc-en-rust-3d3cafcfac938777cdfce1914731da0fb34128abf30b62ee56c7ecb880a6b66a","title":"","text":"// In the algorithm above, we can change // cast(relative_tag) + niche_variants.start() // into // cast(tag) + (niche_variants.start() - niche_start) // cast(tag + (niche_variants.start() - niche_start)) // if either the casted type is no larger than the original // type, or if the niche values are contiguous (in either the // signed or unsigned sense). let can_incr_after_cast = cast_smaller || niches_ule || niches_sle; let can_incr = cast_smaller || niches_ule || niches_sle; let data_for_boundary_niche = || -> Option<(IntPredicate, u128)> { if !can_incr_after_cast { if !can_incr { None } else if niche_start == low_unsigned { Some((IntPredicate::IntULE, niche_end))"}
{"_id":"doc-en-rust-33356910c92947902932ddfe4d09047e084649fa0b789d9e3b41b07434d7f4f3","title":"","text":"// The algorithm is now this: // is_niche = tag <= niche_end // discr = if is_niche { // cast(tag) + (niche_variants.start() - niche_start) // cast(tag + (niche_variants.start() - niche_start)) // } else { // untagged_variant // } // (the first line may instead be tag >= niche_start, // and may be a signed or unsigned comparison) // The arithmetic must be done before the cast, so we can // have the correct wrapping behavior. See issue #104519 for // the consequences of getting this wrong. let is_niche = bx.icmp(predicate, tag, bx.cx().const_uint_big(tag_llty, constant)); let delta = (niche_variants.start().as_u32() as u128).wrapping_sub(niche_start); let incr_tag = if delta == 0 { tag } else { bx.add(tag, bx.cx().const_uint_big(tag_llty, delta)) }; let cast_tag = if cast_smaller { bx.intcast(tag, cast_to, false) bx.intcast(incr_tag, cast_to, false) } else if niches_ule { bx.zext(tag, cast_to) bx.zext(incr_tag, cast_to) } else { bx.sext(tag, cast_to) bx.sext(incr_tag, cast_to) }; let delta = (niche_variants.start().as_u32() as u128).wrapping_sub(niche_start); (is_niche, cast_tag, delta) (is_niche, cast_tag, 0) } else { // The special cases don't apply, so we'll have to go with // the general algorithm."}
{"_id":"doc-en-rust-d65a3fcee363818f43a04549cafd1029864c9a16471ac97d11793e45d91b9744","title":"","text":"// CHECK: define i8 @match1{{.*}} // CHECK-NEXT: start: // CHECK-NEXT: %1 = icmp ugt i8 %0, 1 // CHECK-NEXT: %2 = zext i8 %0 to i64 // CHECK-NEXT: %3 = add nsw i64 %2, -1 // CHECK-NEXT: %_2 = select i1 %1, i64 %3, i64 0 // CHECK-NEXT: switch i64 %_2, label {{.*}} [ // CHECK-NEXT: %1 = {{.*}}call i8 @llvm.usub.sat.i8(i8 %0, i8 1) // CHECK-NEXT: switch i8 %1, label {{.*}} [ #[no_mangle] pub fn match1(e: Enum1) -> u8 { use Enum1::*;"}
{"_id":"doc-en-rust-3ca7a30377fb32a30f1ff3ec6cb3d1b02296da28685581689b7bae690c0043d9","title":"","text":" // run-pass #![allow(dead_code)] enum OpenResult { Ok(()), Err(()), TransportErr(TransportErr), } #[repr(i32)] enum TransportErr { UnknownMethod = -2, } #[inline(never)] fn some_match(result: OpenResult) -> u8 { match result { OpenResult::Ok(()) => 0, _ => 1, } } fn main() { let result = OpenResult::Ok(()); assert_eq!(some_match(result), 0); let result = OpenResult::Ok(()); match result { OpenResult::Ok(()) => (), _ => unreachable!(\"message a\"), } match result { OpenResult::Ok(()) => (), _ => unreachable!(\"message b\"), } } "}
{"_id":"doc-en-rust-46ce4db73d3ea20d2548c3b8e7598c1d8948404f32cab4b2385916eedb87bf13","title":"","text":"} } /// Create an `Rc<[T]>` by reusing the underlying memory /// of a `Vec`. This will return the vector if the existing allocation /// is not large enough. #[cfg(not(no_global_oom_handling))] fn try_from_vec_in_place(mut v: Vec) -> Result, Vec> { let layout_elements = Layout::array::(v.len()).unwrap(); let layout_allocation = Layout::array::(v.capacity()).unwrap(); let layout_rcbox = rcbox_layout_for_value_layout(layout_elements); let mut ptr = NonNull::new(v.as_mut_ptr()).expect(\"`Vec` stores `NonNull`\"); if layout_rcbox.size() > layout_allocation.size() || layout_rcbox.align() > layout_allocation.align() { // Can't fit - calling `grow` would involve `realloc` // (which copies the elements), followed by copying again. return Err(v); } if layout_rcbox.size() < layout_allocation.size() || layout_rcbox.align() < layout_allocation.align() { // We need to shrink the allocation so that it fits // https://doc.rust-lang.org/nightly/std/alloc/trait.Allocator.html#memory-fitting // SAFETY: // - Vec allocates by requesting `Layout::array::(capacity)`, so this capacity matches // - `layout_rcbox` is smaller // If this fails, the ownership has not been transferred if let Ok(p) = unsafe { Global.shrink(ptr.cast(), layout_allocation, layout_rcbox) } { ptr = p.cast(); } else { return Err(v); } } // Make sure the vec's memory isn't deallocated now let v = mem::ManuallyDrop::new(v); let ptr: *mut RcBox<[T]> = ptr::slice_from_raw_parts_mut(ptr.as_ptr(), v.len()) as _; unsafe { ptr::copy(ptr.cast::(), &mut (*ptr).value as *mut [T] as *mut T, v.len()); ptr::write(&mut (*ptr).strong, Cell::new(1)); ptr::write(&mut (*ptr).weak, Cell::new(1)); Ok(Self::from_ptr(ptr)) } } /// Constructs an `Rc<[T]>` from an iterator known to be of a certain size. /// /// Behavior is undefined should the size be wrong."}
{"_id":"doc-en-rust-d46532ff3bb71345b6de2294fbd0d7ccfd79a2938a1ac87d2a3c0801b1bd9479","title":"","text":"/// assert_eq!(vec![1, 2, 3], *shared); /// ``` #[inline] fn from(v: Vec) -> Rc<[T]> { match Rc::try_from_vec_in_place(v) { Ok(rc) => rc, Err(mut v) => { unsafe { let rc = Rc::copy_from_slice(&v); // Allow the Vec to free its memory, but not destroy its contents v.set_len(0); rc } } fn from(mut v: Vec) -> Rc<[T]> { unsafe { let rc = Rc::copy_from_slice(&v); // Allow the Vec to free its memory, but not destroy its contents v.set_len(0); rc } } }"}
{"_id":"doc-en-rust-6a229649cf4995ec1fa3cf3c587edc3cb98b202687f56678ce6487bb18a81d7a","title":"","text":"} } /// Create an `Arc<[T]>` by reusing the underlying memory /// of a `Vec`. This will return the vector if the existing allocation /// is not large enough. #[cfg(not(no_global_oom_handling))] fn try_from_vec_in_place(mut v: Vec) -> Result, Vec> { let layout_elements = Layout::array::(v.len()).unwrap(); let layout_allocation = Layout::array::(v.capacity()).unwrap(); let layout_arcinner = arcinner_layout_for_value_layout(layout_elements); let mut ptr = NonNull::new(v.as_mut_ptr()).expect(\"`Vec` stores `NonNull`\"); if layout_arcinner.size() > layout_allocation.size() || layout_arcinner.align() > layout_allocation.align() { // Can't fit - calling `grow` would involve `realloc` // (which copies the elements), followed by copying again. return Err(v); } if layout_arcinner.size() < layout_allocation.size() || layout_arcinner.align() < layout_allocation.align() { // We need to shrink the allocation so that it fits // https://doc.rust-lang.org/nightly/std/alloc/trait.Allocator.html#memory-fitting // SAFETY: // - Vec allocates by requesting `Layout::array::(capacity)`, so this capacity matches // - `layout_arcinner` is smaller // If this fails, the ownership has not been transferred if let Ok(p) = unsafe { Global.shrink(ptr.cast(), layout_allocation, layout_arcinner) } { ptr = p.cast(); } else { return Err(v); } } // Make sure the vec's memory isn't deallocated now let v = mem::ManuallyDrop::new(v); let ptr: *mut ArcInner<[T]> = ptr::slice_from_raw_parts_mut(ptr.as_ptr(), v.len()) as _; unsafe { ptr::copy(ptr.cast::(), &mut (*ptr).data as *mut [T] as *mut T, v.len()); ptr::write(&mut (*ptr).strong, atomic::AtomicUsize::new(1)); ptr::write(&mut (*ptr).weak, atomic::AtomicUsize::new(1)); Ok(Self::from_ptr(ptr)) } } /// Constructs an `Arc<[T]>` from an iterator known to be of a certain size. /// /// Behavior is undefined should the size be wrong."}
{"_id":"doc-en-rust-5b09e84216ffa2f8f84d7a3d00a24a295487efb1421ab8620f4ba30609112f45","title":"","text":"/// assert_eq!(&[1, 2, 3], &shared[..]); /// ``` #[inline] fn from(v: Vec) -> Arc<[T]> { match Arc::try_from_vec_in_place(v) { Ok(rc) => rc, Err(mut v) => { unsafe { let rc = Arc::copy_from_slice(&v); // Allow the Vec to free its memory, but not destroy its contents v.set_len(0); rc } } fn from(mut v: Vec) -> Arc<[T]> { unsafe { let rc = Arc::copy_from_slice(&v); // Allow the Vec to free its memory, but not destroy its contents v.set_len(0); rc } } }"}
{"_id":"doc-en-rust-58d07b82c23d5e115886fea22c1b77c33b1f7878c96b4053ab50ffce7eb6e229","title":"","text":"// `val` dropped here while still borrowed // borrow might be used here, when `val` is dropped and runs the `Drop` code for type `std::sync::Weak` } #[test] fn arc_from_vec_opt() { let mut v = Vec::with_capacity(64); v.push(0usize); let addr = v.as_ptr().cast::(); let arc: Arc<[_]> = v.into(); unsafe { assert_eq!( arc.as_ptr().cast::().offset_from(addr), (std::mem::size_of::() * 2) as isize, \"Vector allocation not reused\" ); } } "}
{"_id":"doc-en-rust-f32929845634721c278676303fa5e5e820f5b7bb3352051311e4a40c6b12c0bf","title":"","text":"// `val` dropped here while still borrowed // borrow might be used here, when `val` is dropped and runs the `Drop` code for type `std::rc::Weak` } #[test] fn rc_from_vec_opt() { let mut v = Vec::with_capacity(64); v.push(0usize); let addr = v.as_ptr().cast::(); let rc: Rc<[_]> = v.into(); unsafe { assert_eq!( rc.as_ptr().cast::().offset_from(addr), (std::mem::size_of::() * 2) as isize, \"Vector allocation not reused\" ); } } "}
{"_id":"doc-en-rust-18d0ba2194b8aae1052814daae004b78c68d16b597c3848965f3b322d5ce7204","title":"","text":"} ty::FnPtr(sig) => (sig, None), _ => { for arg in arg_exprs { self.check_expr(arg); } if let hir::ExprKind::Path(hir::QPath::Resolved(_, path)) = &callee_expr.kind && let [segment] = path.segments && let Some(mut diag) = self"}
{"_id":"doc-en-rust-f4d908aa8b9cfa9fbbca9c326eb1b5813dbffd57524457b260c428ea675a8cf9","title":"","text":"expected: Expectation<'tcx>, ) -> Option> { if let [callee_expr, rest @ ..] = arg_exprs { let callee_ty = self.check_expr(callee_expr); let callee_ty = self.typeck_results.borrow().expr_ty_adjusted_opt(callee_expr)?; // First, do a probe with `IsSuggestion(true)` to avoid emitting // any strange errors. If it's successful, then we'll do a true // method lookup."}
{"_id":"doc-en-rust-bfc9359b50978cae1c6041a183b1598095e4e12e2dd7c9d11f15e723b44607e3","title":"","text":" fn main() -> Result<(), ()> { a(b(c(d(e( //~^ ERROR cannot find function `a` in this scope //~| ERROR cannot find function `b` in this scope //~| ERROR cannot find function `c` in this scope //~| ERROR cannot find function `d` in this scope //~| ERROR cannot find function `e` in this scope z???????????????????????????????????????????????????????????????????????????????????????? ????????????????????????????????????????????????????????????????????????????????????????? ?????????????????????????????????????????????????????????????????? //~^^^ ERROR cannot find value `z` in this scope ))))) } "}
{"_id":"doc-en-rust-aaa9b69d0960241daf1de0c0723ae40b3eec09a2a62605ec70c6aec9280b4759","title":"","text":" error[E0425]: cannot find value `z` in this scope --> $DIR/fn-to-method-deeply-nested.rs:8:9 | LL | z???????????????????????????????????????????????????????????????????????????????????????? | ^ not found in this scope error[E0425]: cannot find function `e` in this scope --> $DIR/fn-to-method-deeply-nested.rs:2:13 | LL | a(b(c(d(e( | ^ not found in this scope error[E0425]: cannot find function `d` in this scope --> $DIR/fn-to-method-deeply-nested.rs:2:11 | LL | a(b(c(d(e( | ^ not found in this scope error[E0425]: cannot find function `c` in this scope --> $DIR/fn-to-method-deeply-nested.rs:2:9 | LL | a(b(c(d(e( | ^ not found in this scope error[E0425]: cannot find function `b` in this scope --> $DIR/fn-to-method-deeply-nested.rs:2:7 | LL | a(b(c(d(e( | ^ not found in this scope error[E0425]: cannot find function `a` in this scope --> $DIR/fn-to-method-deeply-nested.rs:2:5 | LL | a(b(c(d(e( | ^ not found in this scope error: aborting due to 6 previous errors For more information about this error, try `rustc --explain E0425`. "}
{"_id":"doc-en-rust-17b720c902de637d51aa34a96d0fbdfb888467fd5b0dbedc2c8e59c223ffbd8c","title":"","text":" fn main() { a((), 1i32 == 2u32); //~^ ERROR cannot find function `a` in this scope //~| ERROR mismatched types } "}
{"_id":"doc-en-rust-bce566408450f8713a3ee5047f9d88cbc05f1b6b956b38dfe5074cf84e78e5b5","title":"","text":" error[E0308]: mismatched types --> $DIR/check-args-on-fn-err-2.rs:2:19 | LL | a((), 1i32 == 2u32); | ---- ^^^^ expected `i32`, found `u32` | | | expected because this is `i32` | help: change the type of the numeric literal from `u32` to `i32` | LL | a((), 1i32 == 2i32); | ~~~ error[E0425]: cannot find function `a` in this scope --> $DIR/check-args-on-fn-err-2.rs:2:5 | LL | a((), 1i32 == 2u32); | ^ not found in this scope error: aborting due to 2 previous errors Some errors have detailed explanations: E0308, E0425. For more information about an error, try `rustc --explain E0308`. "}
{"_id":"doc-en-rust-fd562c34adda8629857570dc5437982c77280b3756a4330a5b63392efba5b64c","title":"","text":" fn main() { unknown(1, |glyf| { //~^ ERROR: cannot find function `unknown` in this scope let actual = glyf; }); } "}
{"_id":"doc-en-rust-e52e2b89015415c2c6e74e8d625cb6038c6fb13f45fa4f8ae46a50449701e561","title":"","text":" error[E0425]: cannot find function `unknown` in this scope --> $DIR/check-args-on-fn-err.rs:2:5 | LL | unknown(1, |glyf| { | ^^^^^^^ not found in this scope error: aborting due to previous error For more information about this error, try `rustc --explain E0425`. "}
{"_id":"doc-en-rust-e83b2d8b2f7e315dfb74f5e50b1c4431c9680d2a88a53e98018dc15e773f8682","title":"","text":"_ => {} } } let lines = origtext.lines().filter_map(|l| map_line(l).for_html()); let text = lines.intersperse(\"n\".into()).collect::(); let parse_result = match kind { CodeBlockKind::Fenced(ref lang) => {"}
{"_id":"doc-en-rust-b12d6844623033b9cfcf308ab6ff620335bdf64742d91b4d394154f06f94a7f8","title":"","text":"
\", ); } "}
{"_id":"doc-en-rust-08c047090122345af8734da7b6ef616a45979689800faed00ab694e9d83c6fa5","title":"","text":"let entry = spanned_predicates.entry(spans); entry.or_insert_with(|| (path, tr_self_ty, Vec::new())).2.push(p); } Some(Node::Item(hir::Item { kind: hir::ItemKind::Trait(rustc_ast::ast::IsAuto::Yes, ..), span: item_span, .. })) => { tcx.sess.delay_span_bug( *item_span, \"auto trait is invoked with no method error, but no error reported?\", ); } Some(_) => unreachable!(), None => (), }"}
{"_id":"doc-en-rust-44997c8035a50b1e0751882529c65f4adb171c403a1053e0816d533287865a09","title":"","text":" #![feature(auto_traits)] auto trait Foo { fn g(&self); //~ ERROR auto traits cannot have associated items } trait Bar { fn f(&self) { self.g(); //~ ERROR the method `g` exists for reference `&Self`, but its trait bounds were not satisfied } } fn main() {} "}
{"_id":"doc-en-rust-cc9aadb57cfd2aa0187450c49ddaf2e4147542cf66e815fb23b85c4bd4bb8490","title":"","text":" error[E0380]: auto traits cannot have associated items --> $DIR/issue-105732.rs:4:8 | LL | auto trait Foo { | --- auto trait cannot have associated items LL | fn g(&self); | ---^-------- help: remove these associated items error[E0599]: the method `g` exists for reference `&Self`, but its trait bounds were not satisfied --> $DIR/issue-105732.rs:9:14 | LL | self.g(); | ^ | = note: the following trait bounds were not satisfied: `Self: Foo` which is required by `&Self: Foo` `&Self: Foo` = help: items from traits can only be used if the type parameter is bounded by the trait help: the following trait defines an item `g`, perhaps you need to add a supertrait for it: | LL | trait Bar: Foo { | +++++ error: aborting due to 2 previous errors Some errors have detailed explanations: E0380, E0599. For more information about an error, try `rustc --explain E0380`. "}
{"_id":"doc-en-rust-4b07a6b87a070e7352474b1c0d71a235e5478fbe10b228395cae440c42f765bd","title":"","text":"GenericParamKind, HirId, Node, }; use rustc_hir as hir; use rustc_hir::def::DefKind; use rustc_hir::def_id::DefId; use rustc_middle::ty::{self, TyCtxt}; use rustc_session::lint;"}
{"_id":"doc-en-rust-2a607b0b61c984c976cc6fe6fb87a1c01e2d9b265f0e6912dce0632438989c66","title":"","text":"Some(tcx.typeck_root_def_id(def_id)) } Node::Item(item) => match item.kind { ItemKind::OpaqueTy(hir::OpaqueTy { .. }) => { ItemKind::OpaqueTy(hir::OpaqueTy { origin: hir::OpaqueTyOrigin::FnReturn(fn_def_id) | hir::OpaqueTyOrigin::AsyncFn(fn_def_id), in_trait, .. }) => { if in_trait { assert!(matches!(tcx.def_kind(fn_def_id), DefKind::AssocFn)) } else { assert!(matches!(tcx.def_kind(fn_def_id), DefKind::AssocFn | DefKind::Fn)) } Some(fn_def_id.to_def_id()) } ItemKind::OpaqueTy(hir::OpaqueTy { origin: hir::OpaqueTyOrigin::TyAlias, .. }) => { let parent_id = tcx.hir().get_parent_item(hir_id); assert_ne!(parent_id, hir::CRATE_OWNER_ID); debug!(\"generics_of: parent of opaque ty {:?} is {:?}\", def_id, parent_id);"}
{"_id":"doc-en-rust-f6f283fe0a740cbb9996bb3ace1dd306066b068285ea40405c8cf7e2db0ad7ed","title":"","text":" // check-pass // edition: 2021 // known-bug: #105197 // failure-status:101 // dont-check-compiler-stderr #![feature(async_fn_in_trait)] #![feature(return_position_impl_trait_in_trait)]"}
{"_id":"doc-en-rust-428c04975df5ad50f3d633036449d469cf471f19e62a7117668e4e108025b01c","title":"","text":"self.typeck_results.borrow().qpath_res(qpath, callee_expr.hir_id) } hir::ExprKind::Call(ref inner_callee, _) => { // If the call spans more than one line and the callee kind is // itself another `ExprCall`, that's a clue that we might just be // missing a semicolon (Issue #51055) let call_is_multiline = self.tcx.sess.source_map().is_multiline(call_expr.span); if call_is_multiline { err.span_suggestion( callee_expr.span.shrink_to_hi(), \"consider using a semicolon here\", \";\", Applicability::MaybeIncorrect, ); } if let hir::ExprKind::Path(ref inner_qpath) = inner_callee.kind { inner_callee_path = Some(inner_qpath); self.typeck_results.borrow().qpath_res(inner_qpath, inner_callee.hir_id)"}
{"_id":"doc-en-rust-78d175d27cfbed36e5b865c5466a55a99eabcbff557316bcc5d6aa196b242460","title":"","text":"}; if !self.maybe_suggest_bad_array_definition(&mut err, call_expr, callee_expr) { // If the call spans more than one line and the callee kind is // itself another `ExprCall`, that's a clue that we might just be // missing a semicolon (#51055, #106515). let call_is_multiline = self .tcx .sess .source_map() .is_multiline(call_expr.span.with_lo(callee_expr.span.hi())) && call_expr.span.ctxt() == callee_expr.span.ctxt(); if call_is_multiline { err.span_suggestion( callee_expr.span.shrink_to_hi(), \"consider using a semicolon here to finish the statement\", \";\", Applicability::MaybeIncorrect, ); } if let Some((maybe_def, output_ty, _)) = self.extract_callable_info(callee_ty) && !self.type_is_sized_modulo_regions(self.param_env, output_ty) {"}
{"_id":"doc-en-rust-4d656c101519d866e2a9a4c16d416ee800dd1240cf7a5f7a902509bc9c2349d8","title":"","text":"| ----------------------- `vindictive` defined here returns `bool` ... LL | vindictive() | -^^^^^^^^^^^- help: consider using a semicolon here: `;` | -^^^^^^^^^^^- help: consider using a semicolon here to finish the statement: `;` | _____| | | LL | | (1, 2)"}
{"_id":"doc-en-rust-49d1ca63a7fef2cfab30c4e36af103643dd91dff9543c79eafbc5546ab03a486","title":"","text":" // run-rustfix #![allow(dead_code, unused_variables, path_statements)] fn a() { let x = 5; let y = x; //~ ERROR expected function (); //~ ERROR expected `;`, found `}` } fn b() { let x = 5; let y = x; //~ ERROR expected function (); } fn c() { let x = 5; x; //~ ERROR expected function () } fn d() { // ok let x = || (); x () } fn e() { // ok let x = || (); x (); } fn f() { let y = 5; //~ ERROR expected function (); //~ ERROR expected `;`, found `}` } fn g() { 5; //~ ERROR expected function (); } fn main() {} "}
{"_id":"doc-en-rust-43fef71aeacb631a582a6c6ba9acb4c667abcfe9f7a3a6f381e1b5355497e2ba","title":"","text":" // run-rustfix #![allow(dead_code, unused_variables, path_statements)] fn a() { let x = 5; let y = x //~ ERROR expected function () //~ ERROR expected `;`, found `}` } fn b() { let x = 5; let y = x //~ ERROR expected function (); } fn c() { let x = 5; x //~ ERROR expected function () } fn d() { // ok let x = || (); x () } fn e() { // ok let x = || (); x (); } fn f() { let y = 5 //~ ERROR expected function () //~ ERROR expected `;`, found `}` } fn g() { 5 //~ ERROR expected function (); } fn main() {} "}
{"_id":"doc-en-rust-f2c16ad0daae35a939b3a30e303553d86f7b4a0b8894cbb904e0ab1f3179592d","title":"","text":" error: expected `;`, found `}` --> $DIR/missing-semicolon.rs:6:7 | LL | () | ^ help: add `;` here LL | } | - unexpected token error: expected `;`, found `}` --> $DIR/missing-semicolon.rs:32:7 | LL | () | ^ help: add `;` here LL | } | - unexpected token error[E0618]: expected function, found `{integer}` --> $DIR/missing-semicolon.rs:5:13 | LL | let x = 5; | - `x` has type `{integer}` LL | let y = x | ^- help: consider using a semicolon here to finish the statement: `;` | _____________| | | LL | | () | |______- call expression requires function error[E0618]: expected function, found `{integer}` --> $DIR/missing-semicolon.rs:11:13 | LL | let x = 5; | - `x` has type `{integer}` LL | let y = x | ^- help: consider using a semicolon here to finish the statement: `;` | _____________| | | LL | | (); | |______- call expression requires function error[E0618]: expected function, found `{integer}` --> $DIR/missing-semicolon.rs:16:5 | LL | let x = 5; | - `x` has type `{integer}` LL | x | ^- help: consider using a semicolon here to finish the statement: `;` | _____| | | LL | | () | |______- call expression requires function error[E0618]: expected function, found `{integer}` --> $DIR/missing-semicolon.rs:31:13 | LL | let y = 5 | ^- help: consider using a semicolon here to finish the statement: `;` | _____________| | | LL | | () | |______- call expression requires function error[E0618]: expected function, found `{integer}` --> $DIR/missing-semicolon.rs:35:5 | LL | 5 | ^- help: consider using a semicolon here to finish the statement: `;` | _____| | | LL | | (); | |______- call expression requires function error: aborting due to 7 previous errors For more information about this error, try `rustc --explain E0618`. "}
{"_id":"doc-en-rust-a785693731099ea40e2ac514216e5610eb64206f46e3b954af96173ba2acab6c","title":"","text":"note = \"if you want to iterate between `start` until a value `end`, use the exclusive range syntax `start..end` or the inclusive range syntax `start..=end`\" ), on( _Self = \"{float}\", note = \"if you want to iterate between `start` until a value `end`, use the exclusive range syntax `start..end` or the inclusive range syntax `start..=end`\" ), label = \"`{Self}` is not an iterator\", message = \"`{Self}` is not an iterator\" )]"}
{"_id":"doc-en-rust-6909fccc96f5d97be145e450bc723f5705fdbe25873852a808546886e8cabe95","title":"","text":" // #106728 fn main() { for i in 0.2 { //~^ ERROR `{float}` is not an iterator //~| `{float}` is not an iterator //~| NOTE in this expansion of desugaring of `for` loop //~| NOTE in this expansion of desugaring of `for` loop //~| NOTE in this expansion of desugaring of `for` loop //~| NOTE in this expansion of desugaring of `for` loop //~| NOTE if you want to iterate between `start` until a value `end`, use the exclusive range syntax `start..end` or the inclusive range syntax `start..=end` //~| NOTE required for `{float}` to implement `IntoIterator` println!(); } } "}
{"_id":"doc-en-rust-9852cf898f323704560454a01895519154f97af59ae974548addf0161cb0949b","title":"","text":" error[E0277]: `{float}` is not an iterator --> $DIR/float_iterator_hint.rs:4:14 | LL | for i in 0.2 { | ^^^ `{float}` is not an iterator | = help: the trait `Iterator` is not implemented for `{float}` = note: if you want to iterate between `start` until a value `end`, use the exclusive range syntax `start..end` or the inclusive range syntax `start..=end` = note: required for `{float}` to implement `IntoIterator` error: aborting due to previous error For more information about this error, try `rustc --explain E0277`. "}
{"_id":"doc-en-rust-ac608463a734c150320b3d1ed98e6db00d9bb96eb3aff7af962a9ca3212c788e","title":"","text":"| ^^^^ `{float}` is not an iterator | = help: the trait `Iterator` is not implemented for `{float}` = note: if you want to iterate between `start` until a value `end`, use the exclusive range syntax `start..end` or the inclusive range syntax `start..=end` = note: required for `{float}` to implement `IntoIterator` error: aborting due to 12 previous errors"}
{"_id":"doc-en-rust-cd2376f1f324e296cb61b47dafcec2f57ddb93d363536d9e8a437435b722be7d","title":"","text":"if !check && paths.is_empty() { match get_modified_rs_files(build) { Ok(Some(files)) => { if files.len() <= 10 { for file in &files { println!(\"formatting modified file {file}\"); } } else { println!(\"formatting {} modified files\", files.len()); } for file in files { println!(\"formatting modified file {file}\"); ignore_fmt.add(&format!(\"/{file}\")).expect(&file); } }"}
{"_id":"doc-en-rust-94071e4acf6f5c0915e331f9061a16e09f887c1947a58645b490954b9a6f93cf","title":"","text":"sections[None] = [] section_order = [None] targets = {} top_level_keys = [] for line in open(rust_dir + '/config.toml.example').read().split(\"n\"): if cur_section == None: if line.count('=') == 1: top_level_key = line.split('=')[0] top_level_key = top_level_key.strip(' #') top_level_keys.append(top_level_key) if line.startswith('['): cur_section = line[1:-1] if cur_section.startswith('target'):"}
{"_id":"doc-en-rust-65f5bceee9c1749a7a549da2e04707d247228d0748d6ad71106fcf915839e3b2","title":"","text":"raise RuntimeError(\"failed to find config line for {}\".format(key)) for section_key in config: section_config = config[section_key] if section_key not in sections: raise RuntimeError(\"config key {} not in sections\".format(section_key)) def configure_top_level_key(lines, top_level_key, value): for i, line in enumerate(lines): if line.startswith('#' + top_level_key + ' = ') or line.startswith(top_level_key + ' = '): lines[i] = \"{} = {}\".format(top_level_key, value) return if section_key == 'target': raise RuntimeError(\"failed to find config line for {}\".format(top_level_key)) for section_key, section_config in config.items(): if section_key not in sections and section_key not in top_level_keys: raise RuntimeError(\"config key {} not in sections or top_level_keys\".format(section_key)) if section_key in top_level_keys: configure_top_level_key(sections[None], section_key, section_config) elif section_key == 'target': for target in section_config: configure_section(targets[target], section_config[target]) else:"}
{"_id":"doc-en-rust-d04d99a91d1b39c7c8b56787097248094ac19d2977f00828c60e89a0c66e73b6","title":"","text":"all(target_vendor = \"fortanix\", target_env = \"sgx\"), feature(slice_index_methods, coerce_unsized, sgx_platform) )] #![cfg_attr(windows, feature(round_char_boundary))] // // Language features: #![feature(alloc_error_handler)]"}
{"_id":"doc-en-rust-7c4cf518769fbf19cd76f0d002c44322baf833d706d6baf24684f25476ff4bc7","title":"","text":"use crate::ffi::CStr; use crate::mem; use crate::os::raw::{c_char, c_int, c_long, c_longlong, c_uint, c_ulong, c_ushort}; use crate::os::raw::{c_char, c_long, c_longlong, c_uint, c_ulong, c_ushort}; use crate::os::windows::io::{BorrowedHandle, HandleOrInvalid, HandleOrNull}; use crate::ptr; use core::ffi::NonZero_c_ulong; use libc::{c_void, size_t, wchar_t}; pub use crate::os::raw::c_int; #[path = \"c/errors.rs\"] // c.rs is included from two places so we need to specify this mod errors; pub use errors::*;"}
{"_id":"doc-en-rust-8deb8fdda823b79945f44f3db92107245e9285ec49952bc857f8795cc4c60468","title":"","text":"pub type LPBOOL = *mut BOOL; pub type LPBYTE = *mut BYTE; pub type LPCCH = *const CHAR; pub type LPCSTR = *const CHAR; pub type LPCWCH = *const WCHAR; pub type LPCWSTR = *const WCHAR; pub type LPCVOID = *const c_void; pub type LPDWORD = *mut DWORD; pub type LPHANDLE = *mut HANDLE; pub type LPOVERLAPPED = *mut OVERLAPPED; pub type LPPROCESS_INFORMATION = *mut PROCESS_INFORMATION; pub type LPSECURITY_ATTRIBUTES = *mut SECURITY_ATTRIBUTES; pub type LPSTARTUPINFO = *mut STARTUPINFO; pub type LPSTR = *mut CHAR; pub type LPVOID = *mut c_void; pub type LPCVOID = *const c_void; pub type LPWCH = *mut WCHAR; pub type LPWIN32_FIND_DATAW = *mut WIN32_FIND_DATAW; pub type LPWSADATA = *mut WSADATA;"}
{"_id":"doc-en-rust-9602aaaf9568f0a6e14b73c897ea554d07869e497a0b7c9d037405f2ded07d09","title":"","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":"doc-en-rust-024fa20b175c6b3e4f8ef0de7a3976df60c39cc33c90c2bc9c14ef2051cdb484","title":"","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":"doc-en-rust-9f9cfac09ad524a283bcbccb6f17892aa9c139abd26d35f11be30ca9a74a8cde","title":"","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":"doc-en-rust-90b1d01c323ddb0a9ce545bb7f2cefc22731e4d4a52cf5d4e863248da9940544","title":"","text":"// a missing surrogate can be produced (and also because of the UTF-8 validation above), // write the missing surrogate out now. // Buffering it would mean we have to lie about the number of bytes written. let first_char_remaining = utf16[written]; if first_char_remaining >= 0xDCEE && first_char_remaining <= 0xDFFF { let first_code_unit_remaining = utf16[written]; if first_code_unit_remaining >= 0xDCEE && first_code_unit_remaining <= 0xDFFF { // low surrogate // We just hope this works, and give up otherwise let _ = write_u16s(handle, &utf16[written..written + 1]);"}
{"_id":"doc-en-rust-2f245b11f846beb7037c085ca8b6a127deaa4cd751ceb5f5254b07b5ca8a7e60","title":"","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":"doc-en-rust-a00840a7caacf7682f470ca6b4350c2322113fe752d3a67a2121c208b482ee49","title":"","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":"doc-en-rust-4c58651cdd73604ad12f1562c8f6cb064da4e4e9fb23da16e9d796af96d2c09f","title":"","text":"invalid monomorphization of `{$name}` intrinsic: unsupported {$name} from `{$in_ty}` with element `{$elem_ty}` to `{$ret_ty}` codegen_gcc_invalid_monomorphization_invalid_bitmask = invalid monomorphization of `{$name}` intrinsic: invalid bitmask `{ty}`, expected `u{$expected_int_bits}` or `[u8; {$expected_bytes}]` invalid monomorphization of `{$name}` intrinsic: invalid bitmask `{$ty}`, expected `u{$expected_int_bits}` or `[u8; {$expected_bytes}]` codegen_gcc_invalid_monomorphization_simd_shuffle = invalid monomorphization of `{$name}` intrinsic: simd_shuffle index must be an array of `u32`, got `{$ty}`"}
{"_id":"doc-en-rust-292146ccba7fb38437c86976476a3c6e6361ba5a6d360784b41d3fbe955a048f","title":"","text":"codegen_ssa_unsupported_arch = unsupported arch `{$arch}` for os `{$os}` codegen_ssa_apple_sdk_error_sdk_path = failed to get {$sdk_name} SDK path: {error} codegen_ssa_apple_sdk_error_sdk_path = failed to get {$sdk_name} SDK path: {$error} codegen_ssa_read_file = failed to read file: {message} codegen_ssa_read_file = failed to read file: {$message} codegen_ssa_unsupported_link_self_contained = option `-C link-self-contained` is not supported on this target"}
{"_id":"doc-en-rust-c510633ed7db2fbba23754e7ff880c8f7d02e5269870069f356e01d3a0cc03b1","title":"","text":"}; use fluent_bundle::{FluentBundle, FluentError, FluentResource}; use fluent_syntax::{ ast::{Attribute, Entry, Identifier, Message}, ast::{ Attribute, Entry, Expression, Identifier, InlineExpression, Message, Pattern, PatternElement, }, parser::ParserError, }; use proc_macro::{Diagnostic, Level, Span};"}
{"_id":"doc-en-rust-aa83151887ab49215a3bd158aa86e8ede1d23cce1639afb457c038d2fc1c765a","title":"","text":"}; let mut constants = TokenStream::new(); let mut messagerefs = Vec::new(); for entry in resource.entries() { let span = res.krate.span(); if let Entry::Message(Message { id: Identifier { name }, attributes, .. }) = entry { if let Entry::Message(Message { id: Identifier { name }, attributes, value, .. }) = entry { let _ = previous_defns.entry(name.to_string()).or_insert(path_span); if name.contains('-') {"}
{"_id":"doc-en-rust-81ecf0c9ba5675c05bcd1846616a0636eb732ea077b2e5d8aefdb803fb9e8b94","title":"","text":".emit(); } if let Some(Pattern { elements }) = value { for elt in elements { if let PatternElement::Placeable { expression: Expression::Inline(InlineExpression::MessageReference { id, .. }), } = elt { messagerefs.push((id.name, *name)); } } } // Require that the message name starts with the crate name // `hir_typeck_foo_bar` (in `hir_typeck.ftl`) // `const_eval_baz` (in `const_eval.ftl`)"}
{"_id":"doc-en-rust-4e6f6cc961c82ffe16c067274e7ec245e73e05a0f2a3d93ae5824f59bd56c389","title":"","text":"} } for (mref, name) in messagerefs.into_iter() { if !previous_defns.contains_key(mref) { Diagnostic::spanned( path_span, Level::Error, format!(\"referenced message `{mref}` does not exist (in message `{name}`)\"), ) .help(&format!(\"you may have meant to use a variable reference (`{{${mref}}}`)\")) .emit(); } } if let Err(errs) = bundle.add_resource(resource) { for e in errs { match e {"}
{"_id":"doc-en-rust-93b778151e3f4e792ca2abee2c58468a35f3a4e948d55a27facd42e8b35e1e76","title":"","text":"use self::fluent_generated::{DEFAULT_LOCALE_RESOURCES, test_crate_foo, with_hyphens}; } mod missing_message_ref { use super::fluent_messages; fluent_messages! { missing => \"./missing-message-ref.ftl\" //~^ ERROR referenced message `message` does not exist } } "}
{"_id":"doc-en-rust-b2bc88e58696cdda9efbe7cafd6a04545f12ae9a55c72bcb29797fc317dbdc25","title":"","text":"| = help: replace any '-'s with '_'s error: aborting due to 10 previous errors error: referenced message `message` does not exist (in message `missing_message_ref`) --> $DIR/test.rs:104:20 | LL | missing => \"./missing-message-ref.ftl\" | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: you may have meant to use a variable reference (`{$message}`) error: aborting due to 11 previous errors For more information about this error, try `rustc --explain E0428`."}
{"_id":"doc-en-rust-0871c8f59b1cda45799a5c0bb1619db59940176ca32ca213a9f982d6becaf95e","title":"","text":"\"{place_name} {partially_str}moved due to this method call{loop_message}\", ), ); let infcx = tcx.infer_ctxt().build(); // Erase and shadow everything that could be passed to the new infcx. let ty = tcx.erase_regions(moved_place.ty(self.body, tcx).ty); let method_substs = tcx.erase_regions(method_substs); if let ty::Adt(def, substs) = ty.kind() && Some(def.did()) == tcx.lang_items().pin_type() && let ty::Ref(_, _, hir::Mutability::Mut) = substs.type_at(0).kind()"}
{"_id":"doc-en-rust-82f9bf9fc4f9c6186e47e34df25b19d8d2205b3e4e36d5c43f650a6493d16049","title":"","text":" // run-rustfix use std::pin::Pin; fn foo(_: &mut ()) {} fn main() { let mut uwu = (); let mut r = Pin::new(&mut uwu); foo(r.as_mut().get_mut()); foo(r.get_mut()); //~ ERROR use of moved value } "}
{"_id":"doc-en-rust-1bfcc44cab5dc923b9f98b3ba26e0f7d388f9955abd1f35fc7f36a6631124e63","title":"","text":" // run-rustfix use std::pin::Pin; fn foo(_: &mut ()) {} fn main() { let mut uwu = (); let mut r = Pin::new(&mut uwu); foo(r.get_mut()); foo(r.get_mut()); //~ ERROR use of moved value } "}
{"_id":"doc-en-rust-547c996341dd8aaa37a8bd324b3e36d92fe1638250aa1004f5490d0eb968b2a5","title":"","text":" error[E0382]: use of moved value: `r` --> $DIR/pin-mut-reborrow-infer-var-issue-107419.rs:10:9 | LL | let mut r = Pin::new(&mut uwu); | ----- move occurs because `r` has type `Pin<&mut ()>`, which does not implement the `Copy` trait LL | foo(r.get_mut()); | --------- `r` moved due to this method call LL | foo(r.get_mut()); | ^ value used here after move | note: `Pin::<&'a mut T>::get_mut` takes ownership of the receiver `self`, which moves `r` --> $SRC_DIR/core/src/pin.rs:LL:COL help: consider reborrowing the `Pin` instead of moving it | LL | foo(r.as_mut().get_mut()); | +++++++++ error: aborting due to previous error For more information about this error, try `rustc --explain E0382`. "}
{"_id":"doc-en-rust-0bfd7b1c2c7f0d337ecb37a4a51ea93ff9e4fb51be1eb9fd49df6d14846bd79f","title":"","text":" // Verify that move before the call of the function with noalias, nocapture, readonly. // #107436 // compile-flags: -O // min-llvm-version: 17 #![crate_type = \"lib\"] #[repr(C)] pub struct ThreeSlices<'a>(&'a [u32], &'a [u32], &'a [u32]); #[no_mangle] pub fn sum_slices(val: ThreeSlices) -> u32 { // CHECK-NOT: memcpy let val = val; sum(&val) } #[no_mangle] #[inline(never)] pub fn sum(val: &ThreeSlices) -> u32 { val.0.iter().sum::() + val.1.iter().sum::() + val.2.iter().sum::() } "}
{"_id":"doc-en-rust-5830570f612ee84a42cfd553e8c6d2357222a6d5669ca00fd9d654ccec1d992d","title":"","text":"self.mark_as_used_if_union(*adt, fields); } } hir::ExprKind::Closure(cls) => { self.insert_def_id(cls.def_id.to_def_id()); } _ => (), }"}
{"_id":"doc-en-rust-7a3a2c9bdff588f2ee7ed0ae6cb2748afcb5f464f28245d9383fdd222c0aa397","title":"","text":" // edition: 2021 #![deny(dead_code)] pub fn foo() { let closure = || { fn a() {} //~ ERROR function `a` is never used }; closure() } pub async fn async_foo() { const A: usize = 1; //~ ERROR constant `A` is never used } fn main() {} "}
{"_id":"doc-en-rust-4ddfcb9397040f18d76dfc3d674814cef12ef18ac0588d6596b59f35af73b08b","title":"","text":" error: function `a` is never used --> $DIR/in-closure.rs:7:12 | LL | fn a() {} | ^ | note: the lint level is defined here --> $DIR/in-closure.rs:3:9 | LL | #![deny(dead_code)] | ^^^^^^^^^ error: constant `A` is never used --> $DIR/in-closure.rs:13:11 | LL | const A: usize = 1; | ^ error: aborting due to 2 previous errors "}
{"_id":"doc-en-rust-be3076d11d9fb71044a605d7bfff2ebfdf2e07cf5dfee7afe3ba1da48307ddcc","title":"","text":"// through and constrain Pi. let mut subcomponents = smallvec![]; let mut subvisited = SsoHashSet::new(); compute_components_recursive(tcx, ty.into(), &mut subcomponents, &mut subvisited); compute_alias_components_recursive(tcx, ty, &mut subcomponents, &mut subvisited); out.push(Component::EscapingAlias(subcomponents.into_iter().collect())); } }"}
{"_id":"doc-en-rust-0e5187b435a93a81d78a1b2e383fc74748a37bbc89414eb65ac2a54fc467dc53","title":"","text":"/// /// This should not be used to get the components of `parent` itself. /// Use [push_outlives_components] instead. pub(super) fn compute_components_recursive<'tcx>( pub(super) fn compute_alias_components_recursive<'tcx>( tcx: TyCtxt<'tcx>, alias_ty: Ty<'tcx>, out: &mut SmallVec<[Component<'tcx>; 4]>, visited: &mut SsoHashSet>, ) { let ty::Alias(kind, alias_ty) = alias_ty.kind() else { bug!() }; let opt_variances = if *kind == ty::Opaque { tcx.variances_of(alias_ty.def_id) } else { &[] }; for (index, child) in alias_ty.substs.iter().enumerate() { if opt_variances.get(index) == Some(&ty::Bivariant) { continue; } if !visited.insert(child) { continue; } match child.unpack() { GenericArgKind::Type(ty) => { compute_components(tcx, ty, out, visited); } GenericArgKind::Lifetime(lt) => { // Ignore late-bound regions. if !lt.is_late_bound() { out.push(Component::Region(lt)); } } GenericArgKind::Const(_) => { compute_components_recursive(tcx, child, out, visited); } } } } /// Collect [Component]s for *all* the substs of `parent`. /// /// This should not be used to get the components of `parent` itself. /// Use [push_outlives_components] instead. fn compute_components_recursive<'tcx>( tcx: TyCtxt<'tcx>, parent: GenericArg<'tcx>, out: &mut SmallVec<[Component<'tcx>; 4]>,"}
{"_id":"doc-en-rust-9b71b5fde73fcc1554bd061a4d5624f89293614d24d87cb9fa0dd02db921ffba","title":"","text":"// the problem is to add `T: 'r`, which isn't true. So, if there are no // inference variables, we use a verify constraint instead of adding // edges, which winds up enforcing the same condition. let is_opaque = alias_ty.kind(self.tcx) == ty::Opaque; if approx_env_bounds.is_empty() && trait_bounds.is_empty() && (alias_ty.needs_infer() || alias_ty.kind(self.tcx) == ty::Opaque) && (alias_ty.needs_infer() || is_opaque) { debug!(\"no declared bounds\"); self.substs_must_outlive(alias_ty.substs, origin, region); let opt_variances = is_opaque.then(|| self.tcx.variances_of(alias_ty.def_id)); self.substs_must_outlive(alias_ty.substs, origin, region, opt_variances); return; }"}
{"_id":"doc-en-rust-383533e1ffc9f9a7de0e73c3da075c5b1e57f57297d1fe819bf1b82e65982a45","title":"","text":"self.delegate.push_verify(origin, GenericKind::Alias(alias_ty), region, verify_bound); } #[instrument(level = \"debug\", skip(self))] fn substs_must_outlive( &mut self, substs: SubstsRef<'tcx>, origin: infer::SubregionOrigin<'tcx>, region: ty::Region<'tcx>, opt_variances: Option<&[ty::Variance]>, ) { let constraint = origin.to_constraint_category(); for k in substs { for (index, k) in substs.iter().enumerate() { match k.unpack() { GenericArgKind::Lifetime(lt) => { self.delegate.push_sub_region_constraint( origin.clone(), region, lt, constraint, ); let variance = if let Some(variances) = opt_variances { variances[index] } else { ty::Invariant }; if variance == ty::Invariant { self.delegate.push_sub_region_constraint( origin.clone(), region, lt, constraint, ); } } GenericArgKind::Type(ty) => { self.type_must_outlive(origin.clone(), ty, region, constraint);"}
{"_id":"doc-en-rust-8bcbda56104edc5078582ff7c2e72c90a938cb9771dc46356b113f653ee82ddc","title":"","text":" use crate::infer::outlives::components::{compute_components_recursive, Component}; use crate::infer::outlives::components::{compute_alias_components_recursive, Component}; use crate::infer::outlives::env::RegionBoundPairs; use crate::infer::region_constraints::VerifyIfEq; use crate::infer::VerifyBound;"}
{"_id":"doc-en-rust-1270aafa272eb93aceab26cbd0ba0cc14f1cbf6980560701cf1c359c824a93ae","title":"","text":"// see the extensive comment in projection_must_outlive let recursive_bound = { let mut components = smallvec![]; compute_components_recursive(self.tcx, alias_ty_as_ty.into(), &mut components, visited); compute_alias_components_recursive( self.tcx, alias_ty_as_ty.into(), &mut components, visited, ); self.bound_from_components(&components, visited) };"}
{"_id":"doc-en-rust-c3ee31413b6576b1a5d350cb10c34cdf54769ab42733d4ca07f1928444a2c03d","title":"","text":" // check-pass #![feature(type_alias_impl_trait)] struct MyTy<'a>(Vec, &'a ()); impl MyTy<'_> { fn one(&mut self) -> &mut impl Sized { &mut self.0 } fn two(&mut self) -> &mut (impl Sized + 'static) { self.one() } } type Opaque<'a> = impl Sized; fn define<'a>() -> Opaque<'a> {} fn test<'a>() { None::<&'static Opaque<'a>>; } fn one<'a, 'b: 'b>() -> &'a impl Sized { &() } fn two<'a, 'b>() { one::<'a, 'b>(); } fn main() {} "}
{"_id":"doc-en-rust-3f9f0805fa0df31fe1c63fa293eeb4ec5b7e32339ba025b0b5c19fff77ee52a6","title":"","text":" // check-pass #![feature(type_alias_impl_trait)] fn opaque<'a: 'a>() -> impl Sized {} fn assert_static(_: T) {} fn test_closure() { let closure = |_| { assert_static(opaque()); }; closure(&opaque()); } type Opaque<'a> = impl Sized; fn define<'a>() -> Opaque<'a> {} fn test_tait(_: &Opaque<'_>) { None::<&'static Opaque<'_>>; } fn main() {} "}
{"_id":"doc-en-rust-7750522f0c30036cdcc03f8f16c07f6e168c013aec93b8c5aee322c9247ed136","title":"","text":"pub fn check_target_feature_trait_unsafe(tcx: TyCtxt<'_>, id: LocalDefId, attr_span: Span) { if let DefKind::AssocFn = tcx.def_kind(id) { let parent_id = tcx.local_parent(id); if let DefKind::Impl { of_trait: true } = tcx.def_kind(parent_id) { if let DefKind::Trait | DefKind::Impl { of_trait: true } = tcx.def_kind(parent_id) { tcx.sess .struct_span_err( attr_span,"}
{"_id":"doc-en-rust-483d1d9a278cc4290a2e5fee770061113f2d3d2a88612f8a0e3caaea07035f5d","title":"","text":"unsafe fn unsf_foo(&self) {} } trait Qux { #[target_feature(enable = \"sse2\")] //~^ ERROR cannot be applied to safe trait method fn foo(&self) {} } fn main() {}"}
{"_id":"doc-en-rust-c402dbdb426463989328b0f9fd5bf1ac35acc52cc089ebafd283d69f5700b404","title":"","text":"error: `#[target_feature(..)]` cannot be applied to safe trait method --> $DIR/trait-impl.rs:22:5 | LL | #[target_feature(enable = \"sse2\")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot be applied to safe trait method LL | LL | fn foo(&self) {} | ------------- not an `unsafe` function error: `#[target_feature(..)]` cannot be applied to safe trait method --> $DIR/trait-impl.rs:13:5 | LL | #[target_feature(enable = \"sse2\")]"}
{"_id":"doc-en-rust-cafac23b6f1dd2021c4ce8569042b989ec7a4f5fcd730a20211322eb84a13725","title":"","text":"LL | fn foo(&self) {} | ------------- not an `unsafe` function error: aborting due to previous error error: aborting due to 2 previous errors "}
{"_id":"doc-en-rust-c64863de2e310a7dfffc32c84c68f3812a2d2229b16a984e578c54eb04878b88","title":"","text":"false, ); // HACK: This avoids putting the newly built artifacts in the sysroot if we're using // `download-rustc`, to avoid \"multiple candidates for `rmeta`\" errors. Technically, that's // not quite right: people can set `download-rustc = true` to download even if there are // changes to the compiler, and in that case ideally we would put the *new* artifacts in the // sysroot, in case there are API changes that should be used by tools. In practice, // though, that should be very uncommon, and people can still disable download-rustc. if !builder.download_rustc() { let libdir = builder.sysroot_libdir(compiler, target); let hostdir = builder.sysroot_libdir(compiler, compiler.host); add_to_sysroot(&builder, &libdir, &hostdir, &librustc_stamp(builder, compiler, target)); } let libdir = builder.sysroot_libdir(compiler, target); let hostdir = builder.sysroot_libdir(compiler, compiler.host); add_to_sysroot(&builder, &libdir, &hostdir, &librustc_stamp(builder, compiler, target)); } }"}
{"_id":"doc-en-rust-03905ca7bf6739059c62cca51f607eb955ba1bc253070611c6b4a9065f0ff775","title":"","text":"use std::borrow::Cow; use std::collections::HashSet; use std::env; use std::ffi::OsStr; use std::fs; use std::io::prelude::*; use std::io::BufReader;"}
{"_id":"doc-en-rust-6b0ad601969ee6bcf7796362d41107fc977c9d18a3cd6b35a253a87f32eb54fa","title":"","text":"// so its artifacts can't be reused. if builder.download_rustc() && compiler.stage != 0 { // Copy the existing artifacts instead of rebuilding them. // NOTE: this path is only taken for tools linking to rustc-dev. builder.ensure(Sysroot { compiler }); // NOTE: this path is only taken for tools linking to rustc-dev (including ui-fulldeps tests). let sysroot = builder.ensure(Sysroot { compiler }); let ci_rustc_dir = builder.out.join(&*builder.build.build.triple).join(\"ci-rustc\"); for file in builder.config.rustc_dev_contents() { let src = ci_rustc_dir.join(&file); let dst = sysroot.join(file); if src.is_dir() { t!(fs::create_dir_all(dst)); } else { builder.copy(&src, &dst); } } return; }"}
{"_id":"doc-en-rust-adccc4e980337402afe640673cd6c898d5d08b4146395da648883d74977f0b1d","title":"","text":"} // Copy the compiler into the correct sysroot. builder.cp_r(&builder.ci_rustc_dir(builder.build.build), &sysroot); // NOTE(#108767): We intentionally don't copy `rustc-dev` artifacts until they're requested with `builder.ensure(Rustc)`. // This fixes an issue where we'd have multiple copies of libc in the sysroot with no way to tell which to load. // There are a few quirks of bootstrap that interact to make this reliable: // 1. The order `Step`s are run is hard-coded in `builder.rs` and not configurable. This // avoids e.g. reordering `test::UiFulldeps` before `test::Ui` and causing the latter to // fail because of duplicate metadata. // 2. The sysroot is deleted and recreated between each invocation, so running `x test // ui-fulldeps && x test ui` can't cause failures. let mut filtered_files = Vec::new(); // Don't trim directories or files that aren't loaded per-target; they can't cause conflicts. let suffix = format!(\"lib/rustlib/{}/lib\", compiler.host); for path in builder.config.rustc_dev_contents() { let path = Path::new(&path); if path.parent().map_or(false, |parent| parent.ends_with(&suffix)) { filtered_files.push(path.file_name().unwrap().to_owned()); } } let filtered_extensions = [OsStr::new(\"rmeta\"), OsStr::new(\"rlib\"), OsStr::new(\"so\")]; let ci_rustc_dir = builder.ci_rustc_dir(builder.config.build); builder.cp_filtered(&ci_rustc_dir, &sysroot, &|path| { if path.extension().map_or(true, |ext| !filtered_extensions.contains(&ext)) { return true; } if !path.parent().map_or(true, |p| p.ends_with(&suffix)) { return true; } if !filtered_files.iter().all(|f| f != path.file_name().unwrap()) { builder.verbose_than(1, &format!(\"ignoring {}\", path.display())); false } else { true } }); return INTERNER.intern_path(sysroot); }"}
{"_id":"doc-en-rust-dd6359dad8d7bcc90d22b62f8fb849e5f54eec6f328b8e66bb8f2a1ea9b70038","title":"","text":"env, ffi::{OsStr, OsString}, fs::{self, File}, io::{BufRead, BufReader, ErrorKind}, io::{BufRead, BufReader, BufWriter, ErrorKind, Write}, path::{Path, PathBuf}, process::{Command, Stdio}, };"}
{"_id":"doc-en-rust-a03cf1c3dd948614a0ed12bfd2a663d5d3f2c32271f7fa5b14aba91789d6ae20","title":"","text":"let directory_prefix = Path::new(Path::new(uncompressed_filename).file_stem().unwrap()); // decompress the file let data = t!(File::open(tarball)); let data = t!(File::open(tarball), format!(\"file {} not found\", tarball.display())); let decompressor = XzDecoder::new(BufReader::new(data)); let mut tar = tar::Archive::new(decompressor); // `compile::Sysroot` needs to know the contents of the `rustc-dev` tarball to avoid adding // it to the sysroot unless it was explicitly requested. But parsing the 100 MB tarball is slow. // Cache the entries when we extract it so we only have to read it once. let mut recorded_entries = if dst.ends_with(\"ci-rustc\") && pattern == \"rustc-dev\" { Some(BufWriter::new(t!(File::create(dst.join(\".rustc-dev-contents\"))))) } else { None }; for member in t!(tar.entries()) { let mut member = t!(member); let original_path = t!(member.path()).into_owned();"}
{"_id":"doc-en-rust-3f1ab69dc365633cc26367fa7559ccbf00c49ee764173dd4c9991a32c6e313a4","title":"","text":"if !t!(member.unpack_in(dst)) { panic!(\"path traversal attack ??\"); } if let Some(record) = &mut recorded_entries { t!(writeln!(record, \"{}\", short_path.to_str().unwrap())); } let src_path = dst.join(original_path); if src_path.is_dir() && dst_path.exists() { continue; } t!(fs::rename(src_path, dst_path)); } t!(fs::remove_dir_all(dst.join(directory_prefix))); let dst_dir = dst.join(directory_prefix); if dst_dir.exists() { t!(fs::remove_dir_all(&dst_dir), format!(\"failed to remove {}\", dst_dir.display())); } } /// Returns whether the SHA256 checksum of `path` matches `expected`."}
{"_id":"doc-en-rust-b4c0988620d9024428e34db5622a8c981d6399436439d808d14e859b05c20647","title":"","text":"Some(rustfmt_path) } pub(crate) fn rustc_dev_contents(&self) -> Vec { assert!(self.download_rustc()); let ci_rustc_dir = self.out.join(&*self.build.triple).join(\"ci-rustc\"); let rustc_dev_contents_file = t!(File::open(ci_rustc_dir.join(\".rustc-dev-contents\"))); t!(BufReader::new(rustc_dev_contents_file).lines().collect()) } pub(crate) fn download_ci_rustc(&self, commit: &str) { self.verbose(&format!(\"using downloaded stage2 artifacts from CI (commit {commit})\"));"}
{"_id":"doc-en-rust-d3091dbdd4a781b54c4c2b440bb0e8a784d75c370f84ae2372509c801be29a9b","title":"","text":" // Test that `download-rustc` doesn't put duplicate copies of libc in the sysroot. // check-pass #![crate_type = \"lib\"] #![no_std] #![feature(rustc_private)] extern crate libc; "}
{"_id":"doc-en-rust-8d9865a27092f45c912d85e4ecca1ed1413b44104b738208f9a4ccd9889d0406","title":"","text":".iter() .enumerate() .map(|(i, ty)| Argument { name: name_from_pat(&body.params[i].pat), name: Symbol::intern(&rustc_hir_pretty::param_to_string(&body.params[i])), type_: ty.clean(cx), }) .collect(),"}
{"_id":"doc-en-rust-aff37c95101343fcee3195e932bce2b72cf2d2a1d59914f6f1947f97bcf54c84","title":"","text":"Path { global: path.global, res: path.res, segments } } crate fn qpath_to_string(p: &hir::QPath<'_>) -> String { let segments = match *p { hir::QPath::Resolved(_, ref path) => &path.segments, hir::QPath::TypeRelative(_, ref segment) => return segment.ident.to_string(), hir::QPath::LangItem(lang_item, ..) => return lang_item.name().to_string(), }; let mut s = String::new(); for (i, seg) in segments.iter().enumerate() { if i > 0 { s.push_str(\"::\"); } if seg.ident.name != kw::PathRoot { s.push_str(&seg.ident.as_str()); } } s } crate fn build_deref_target_impls(cx: &DocContext<'_>, items: &[Item], ret: &mut Vec) { let tcx = cx.tcx;"}
{"_id":"doc-en-rust-526ca719b953f8382fc5f06b27593cd84a0f6071325a5c70b0cb9d9487f433ac","title":"","text":"} } crate fn name_from_pat(p: &hir::Pat<'_>) -> Symbol { use rustc_hir::*; debug!(\"trying to get a name from pattern: {:?}\", p); Symbol::intern(&match p.kind { PatKind::Wild => return kw::Underscore, PatKind::Binding(_, _, ident, _) => return ident.name, PatKind::TupleStruct(ref p, ..) | PatKind::Path(ref p) => qpath_to_string(p), PatKind::Struct(ref name, ref fields, etc) => format!( \"{} {{ {}{} }}\", qpath_to_string(name), fields .iter() .map(|fp| format!(\"{}: {}\", fp.ident, name_from_pat(&fp.pat))) .collect::>() .join(\", \"), if etc { \", ..\" } else { \"\" } ), PatKind::Or(ref pats) => pats .iter() .map(|p| name_from_pat(&**p).to_string()) .collect::>() .join(\" | \"), PatKind::Tuple(ref elts, _) => format!( \"({})\", elts.iter() .map(|p| name_from_pat(&**p).to_string()) .collect::>() .join(\", \") ), PatKind::Box(ref p) => return name_from_pat(&**p), PatKind::Ref(ref p, _) => return name_from_pat(&**p), PatKind::Lit(..) => { warn!( \"tried to get argument name from PatKind::Lit, which is silly in function arguments\" ); return Symbol::intern(\"()\"); } PatKind::Range(..) => panic!( \"tried to get argument name from PatKind::Range, which is not allowed in function arguments\" ), PatKind::Slice(ref begin, ref mid, ref end) => { let begin = begin.iter().map(|p| name_from_pat(&**p).to_string()); let mid = mid.as_ref().map(|p| format!(\"..{}\", name_from_pat(&**p))).into_iter(); let end = end.iter().map(|p| name_from_pat(&**p).to_string()); format!(\"[{}]\", begin.chain(mid).chain(end).collect::>().join(\", \")) } }) } crate fn print_const(cx: &DocContext<'_>, n: &'tcx ty::Const<'_>) -> String { match n.val { ty::ConstKind::Unevaluated(def, _, promoted) => {"}
{"_id":"doc-en-rust-df43ba6bf4aefc7e35203040f51dca21aa05fb95e6ed8060c53a1d518338290b","title":"","text":" // check-pass fn func(0u8..=255: u8) {} "}
{"_id":"doc-en-rust-857e1d25fb89cef025bd38243dc6175e05d6605766295975c711bf3c5c41b93d","title":"","text":" #![crate_name = \"foo\"] // @has foo/fn.f.html // @has - '//*[@class=\"rust fn\"]' 'pub fn f(0u8 ...255: u8)' pub fn f(0u8...255: u8) {} "}
{"_id":"doc-en-rust-b2807740b707ef2b8ae129c625c6449d751ef8dbc4aed4e89e094c40c5430147","title":"","text":" error[E0637]: `&` without an explicit lifetime name cannot be used here --> $DIR/issue-109071.rs:8:17 | LL | type Item = &[T]; | ^ explicit lifetime name needed here error[E0107]: missing generics for struct `Windows` --> $DIR/issue-109071.rs:7:9 | LL | impl Windows { | ^^^^^^^ expected 1 generic argument | note: struct defined here, with 1 generic parameter: `T` --> $DIR/issue-109071.rs:5:8 | LL | struct Windows {} | ^^^^^^^ - help: add missing generic argument | LL | impl Windows { | +++ error[E0658]: inherent associated types are unstable --> $DIR/issue-109071.rs:8:5 | LL | type Item = &[T]; | ^^^^^^^^^^^^^^^^^ | = note: see issue #8995 for more information = help: add `#![feature(inherent_associated_types)]` to the crate attributes to enable error: aborting due to 3 previous errors Some errors have detailed explanations: E0107, E0637, E0658. For more information about an error, try `rustc --explain E0107`. "}
{"_id":"doc-en-rust-6f4df27f06947c83de719d1583949626b2f173d078d2fe9f3ea95751c803b75a","title":"","text":" // revisions: with_gate no_gate #![cfg_attr(with_gate, feature(inherent_associated_types))] #![cfg_attr(with_gate, allow(incomplete_features))] struct Windows {} impl Windows { //~ ERROR: missing generics for struct `Windows` type Item = &[T]; //~ ERROR: `&` without an explicit lifetime name cannot be used here //[no_gate]~^ ERROR: inherent associated types are unstable fn next() -> Option {} } impl Windows { fn T() -> Option {} } fn main() {} "}
{"_id":"doc-en-rust-7ff5a4cf1725d90bf964c4a79109de9063a0dff5444f7bece240d85ff7a097b2","title":"","text":" error[E0637]: `&` without an explicit lifetime name cannot be used here --> $DIR/issue-109071.rs:8:17 | LL | type Item = &[T]; | ^ explicit lifetime name needed here error[E0107]: missing generics for struct `Windows` --> $DIR/issue-109071.rs:7:9 | LL | impl Windows { | ^^^^^^^ expected 1 generic argument | note: struct defined here, with 1 generic parameter: `T` --> $DIR/issue-109071.rs:5:8 | LL | struct Windows {} | ^^^^^^^ - help: add missing generic argument | LL | impl Windows { | +++ error: aborting due to 2 previous errors Some errors have detailed explanations: E0107, E0637. For more information about an error, try `rustc --explain E0107`. "}
{"_id":"doc-en-rust-a90f713392ff119a8866a5e7b8b5fc801d1abf06a3d18b4ea16dcec1cfb13440","title":"","text":"} pub fn stat(path: &Path) -> io::Result { metadata(path, ReparsePoint::Follow) match metadata(path, ReparsePoint::Follow) { Err(err) if err.raw_os_error() == Some(c::ERROR_CANT_ACCESS_FILE as i32) => { if let Ok(attrs) = lstat(path) { if !attrs.file_type().is_symlink() { return Ok(attrs); } } Err(err) } result => result, } } pub fn lstat(path: &Path) -> io::Result {"}
{"_id":"doc-en-rust-c8851f733914b45eb50adbb756282aafab4338d99e014072b6653b345aba1f52","title":"","text":"} else { resolution.binding = Some(nonglob_binding); } resolution.shadowed_glob = Some(glob_binding); if let Some(old_binding) = resolution.shadowed_glob { assert!(old_binding.is_glob_import()); if glob_binding.res() != old_binding.res() { resolution.shadowed_glob = Some(this.ambiguity( AmbiguityKind::GlobVsGlob, old_binding, glob_binding, )); } else if !old_binding.vis.is_at_least(binding.vis, this.tcx) { resolution.shadowed_glob = Some(glob_binding); } } else { resolution.shadowed_glob = Some(glob_binding); } } (false, false) => { return Err(old_binding);"}
{"_id":"doc-en-rust-6977e261d9dd0054ba4180001d05e39fc3313ceae1c794a61681175d62ab4538","title":"","text":"LL | use V; | ^ ambiguous name | = note: ambiguous because of multiple potential import sources = note: ambiguous because of multiple glob imports of a name in the same module note: `V` could refer to the variant imported here --> $DIR/issue-105069.rs:1:5 | LL | use self::A::*; | ^^^^^^^^^^ = help: consider adding an explicit import of `V` to disambiguate note: `V` could also refer to the variant imported here --> $DIR/issue-105069.rs:3:5 | LL | use self::B::*; | ^^^^^^^^^^ = help: consider adding an explicit import of `V` to disambiguate error: aborting due to previous error"}
{"_id":"doc-en-rust-9607d1e0a7f28fdc7194d38fd476735713570aa6e5c0b36e85d4f4ee33995cab","title":"","text":" use foo::*; mod foo { pub mod bar { pub mod bar { pub mod bar {} } } } use bar::bar; //~ ERROR `bar` is ambiguous use bar::*; fn main() { } "}
{"_id":"doc-en-rust-10cb2834c62ba15fa1ffe3766402ebe566aad84fa249051c2dd33c5210bdb2ef","title":"","text":" error[E0659]: `bar` is ambiguous --> $DIR/issue-109153.rs:11:5 | LL | use bar::bar; | ^^^ ambiguous name | = note: ambiguous because of multiple glob imports of a name in the same module note: `bar` could refer to the module imported here --> $DIR/issue-109153.rs:1:5 | LL | use foo::*; | ^^^^^^ = help: consider adding an explicit import of `bar` to disambiguate note: `bar` could also refer to the module imported here --> $DIR/issue-109153.rs:12:5 | LL | use bar::*; | ^^^^^^ = help: consider adding an explicit import of `bar` to disambiguate error: aborting due to previous error For more information about this error, try `rustc --explain E0659`. "}
{"_id":"doc-en-rust-fb5211bbc433a7a4708e749ecf691ed4934449150a243bbc9c7c3e7dbfe2e2e0","title":"","text":"ct_op: |ct| ct, ty_op: |ty| match *ty.kind() { ty::Alias(ty::Opaque, ty::AliasTy { def_id, .. }) if replace_opaque_type(def_id) => if replace_opaque_type(def_id) && !ty.has_escaping_bound_vars() => { let def_span = self.tcx.def_span(def_id); let span = if span.contains(def_span) { def_span } else { span };"}
{"_id":"doc-en-rust-527b53af5eb4bd7dd64e2f13f5bd14317aeb87bb316cc9b5fb17236e2b950318","title":"","text":"//! This test checks that opaque type collection doesn't try to normalize the projection //! without respecting its binders (which would ICE). //! Unfortunately we don't even reach opaque type collection, as we ICE in typeck before that. // known-bug: #109281 // failure-status: 101 // error-pattern:internal compiler error // normalize-stderr-test \"internal compiler error.*\" -> \"\" // normalize-stderr-test \"DefId([^)]*)\" -> \"...\" // normalize-stderr-test \"nerror: internal compiler error.*nn\" -> \"\" // normalize-stderr-test \"note:.*unexpectedly panicked.*nn\" -> \"\" // normalize-stderr-test \"note: we would appreciate a bug report.*nn\" -> \"\" // normalize-stderr-test \"note: compiler flags.*nn\" -> \"\" // normalize-stderr-test \"note: rustc.*running on.*nn\" -> \"\" // normalize-stderr-test \"thread.*panicked.*:n.*n\" -> \"\" // normalize-stderr-test \"stack backtrace:n\" -> \"\" // normalize-stderr-test \"sd{1,}: .*n\" -> \"\" // normalize-stderr-test \"s at .*n\" -> \"\" // normalize-stderr-test \".*note: Some details.*n\" -> \"\" // normalize-stderr-test \"nn[ ]*n\" -> \"\" // normalize-stderr-test \"compiler/.*: projection\" -> \"projection\" // normalize-stderr-test \".*omitted d{1,} frame.*n\" -> \"\" // normalize-stderr-test \"error: [sn]*query stack\" -> \"error: query stack\" // normalize-stderr-test \"[ns]*nquery stack during panic:\" -> \"query stack during panic:\" //! See #109281 for the original report. // edition:2018 // error-pattern: expected generic lifetime parameter, found `'a` #![feature(type_alias_impl_trait)] #![allow(incomplete_features)]"}
{"_id":"doc-en-rust-fee9ee19347bf383529fae47719334b017724885d10958606a776cf2e88221fb","title":"","text":" error: --> $DIR/issue-90014-tait2.rs:44:27 | LL | fn make_fut(&self) -> Box Trait<'a, Thing = Fut<'a>>> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^query stack during panic: #0 [typeck] type-checking `::make_fut` #1 [type_of] computing type of `Fut::{opaque#0}` #2 [check_mod_item_types] checking item types in top-level module #3 [analysis] running analysis passes on this crate end of query stack error[E0792]: expected generic lifetime parameter, found `'a` error: aborting due to previous error For more information about this error, try `rustc --explain E0792`. "}
{"_id":"doc-en-rust-e2e822978a8e44a168f9e7e104e4fc49b401ba6769d59eff06b25b2b07bd2df8","title":"","text":" #![feature(type_alias_impl_trait)] type Opaque<'a> = impl Sized + 'a; fn test(f: fn(u8)) -> fn(Opaque<'_>) { f //~ ERROR E0792 } fn main() {} "}
{"_id":"doc-en-rust-90b88845116e8585113b85b7064d26048042aa5883209f3d539ff3af3c3b10e7","title":"","text":" error[E0792]: expected generic lifetime parameter, found `'_` --> $DIR/under-binder.rs:6:5 | LL | type Opaque<'a> = impl Sized + 'a; | -- this generic parameter must be used with a generic lifetime parameter ... LL | f | ^ error: aborting due to previous error For more information about this error, try `rustc --explain E0792`. "}
{"_id":"doc-en-rust-4aa04c0d91a78bcaeeea5f545c43bcd30c0d7b638a6c95d8c67c63e2a8bbf9fa","title":"","text":"for (i, proj) in place.projections.iter().enumerate() { match proj.kind { ProjectionKind::Index => { // Arrays are completely captured, so we drop Index projections ProjectionKind::Index | ProjectionKind::Subslice => { // Arrays are completely captured, so we drop Index and Subslice projections truncate_place_to_len_and_update_capture_kind(&mut place, &mut curr_mode, i); return (place, curr_mode); } ProjectionKind::Deref => {} ProjectionKind::Field(..) => {} // ignore ProjectionKind::Subslice => {} // We never capture this } }"}
{"_id":"doc-en-rust-48b74484eb6fad6b4c77cbf71d127fb08891f56ade506ebb38fe4938e45341fe","title":"","text":" // regression test for #109298 // edition: 2021 pub fn subslice_array(x: [u8; 3]) { let f = || { let [_x @ ..] = x; let [ref y, ref mut z @ ..] = x; //~ ERROR cannot borrow `x[..]` as mutable }; f(); //~ ERROR cannot borrow `f` as mutable } fn main() {} "}
{"_id":"doc-en-rust-45ffe405ab053c5fee016ad199b6ab6597009d4a3ac411028cb029d04e94826c","title":"","text":" error[E0596]: cannot borrow `x[..]` as mutable, as `x` is not declared as mutable --> $DIR/array_subslice.rs:7:21 | LL | pub fn subslice_array(x: [u8; 3]) { | - help: consider changing this to be mutable: `mut x` ... LL | let [ref y, ref mut z @ ..] = x; | ^^^^^^^^^ cannot borrow as mutable error[E0596]: cannot borrow `f` as mutable, as it is not declared as mutable --> $DIR/array_subslice.rs:10:5 | LL | let [ref y, ref mut z @ ..] = x; | - calling `f` requires mutable binding due to mutable borrow of `x` ... LL | f(); | ^ cannot borrow as mutable | help: consider changing this to be mutable | LL | let mut f = || { | +++ error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0596`. "}
{"_id":"doc-en-rust-c88e4bb2d1c33f7d2f89bea814e6341e642686b820ea4feeac11b7e87e41e25f","title":"","text":" //@ assembly-output: emit-asm //@ compile-flags:-Copt-level=3 //@ only-x86_64 #![crate_type = \"lib\"] #[no_mangle] type T = u8; type T1 = (T, T, T, T, T, T, T, T); type T2 = [T; 8]; #[no_mangle] // CHECK-LABEL: foo1a // CHECK: cmp // CHECK-NEXT: set // CHECK-NEXT: ret pub fn foo1a(a: T1, b: T1) -> bool { a == b } #[no_mangle] // CHECK-LABEL: foo1b // CHECK: mov // CHECK-NEXT: cmp // CHECK-NEXT: set // CHECK-NEXT: ret pub fn foo1b(a: &T1, b: &T1) -> bool { a == b } "}
{"_id":"doc-en-rust-1f1622d7078c48d54749e4b08b4f15fc029376c2b730dbd3ca6d59da6353f53c","title":"","text":" //@ compile-flags: -O //@ min-llvm-version: 17 #![crate_type = \"lib\"] #[no_mangle] // CHECK-LABEL: @foo // CHECK: getelementptr inbounds // CHECK-NEXT: load i64 // CHECK-NEXT: icmp eq i64 // CHECK-NEXT: br i1 #[no_mangle] pub fn foo(input: &mut &[u64]) -> Option { let (first, rest) = input.split_first()?; *input = rest; Some(*first) } "}
{"_id":"doc-en-rust-35f320816bcb0ba41943216784220e3866b16b66c408ed09581f2e2415ac3af1","title":"","text":" //@ compile-flags: -O // XXX: The x86-64 assembly get optimized correclty. But llvm-ir output is not until llvm 18? //@ min-llvm-version: 18 #![crate_type = \"lib\"] pub enum K{ A(Box<[i32]>), B(Box<[u8]>), C(Box<[String]>), D(Box<[u16]>), } #[no_mangle] // CHECK-LABEL: @get_len // CHECK: getelementptr inbounds // CHECK-NEXT: load // CHECK-NEXT: ret i64 // CHECK-NOT: switch pub fn get_len(arg: &K)->usize{ match arg { K::A(ref lst)=>lst.len(), K::B(ref lst)=>lst.len(), K::C(ref lst)=>lst.len(), K::D(ref lst)=>lst.len(), } } "}
{"_id":"doc-en-rust-03f975a8d25650388370b27a01341ee6f7e6a2234bcf6a0a1d827001db81941d","title":"","text":" //@ compile-flags: -O // This regress since Rust version 1.72. //@ min-llvm-version: 18.1.4 #![crate_type = \"lib\"] use std::convert::TryInto; const N: usize = 24; #[no_mangle] // CHECK-LABEL: @example // CHECK-NOT: unwrap_failed pub fn example(a: Vec) -> u8 { if a.len() != 32 { return 0; } let a: [u8; 32] = a.try_into().unwrap(); a[15] + a[N] } "}
{"_id":"doc-en-rust-e281b5a1f8828b3cc909f2562a53e8540735d74a2381090c9a5386068291d804","title":"","text":" //@ compile-flags: -O //@ min-llvm-version: 17 #![crate_type = \"lib\"] // CHECK-LABEL: @write_u8_variant_a // CHECK: getelementptr // CHECK-NEXT: icmp ugt #[no_mangle] pub fn write_u8_variant_a( bytes: &mut [u8], buf: u8, offset: usize, ) -> Option<&mut [u8]> { let buf = buf.to_le_bytes(); bytes .get_mut(offset..).and_then(|bytes| bytes.get_mut(..buf.len())) } "}
{"_id":"doc-en-rust-7838ca78214a6ee13a087be8cc2ae6aca58d0f0c720a96241c39cf2d7fdcad1f","title":"","text":" // in Rust 1.73, -O and opt-level=3 optimizes differently //@ compile-flags: -C opt-level=3 //@ min-llvm-version: 17 #![crate_type = \"lib\"] use std::cmp::max; #[no_mangle] // CHECK-LABEL: @foo // CHECK-NOT: slice_start_index_len_fail // CHECK-NOT: unreachable pub fn foo(v: &mut Vec, size: usize)-> Option<&mut [u8]> { if v.len() > max(1, size) { let start = v.len() - size; Some(&mut v[start..]) } else { None } } "}
{"_id":"doc-en-rust-d65100dd9bb73ba9d0b249df14f671d2e895bf46f659dab449ab263ba1f1de22","title":"","text":" //@ compile-flags: -O //@ min-llvm-version: 18 #![crate_type = \"lib\"] // CHECK-LABEL: @div2 // CHECK: ashr i32 %a, 1 // CHECK-NEXT: ret i32 #[no_mangle] pub fn div2(a: i32) -> i32 { a.div_euclid(2) } "}
{"_id":"doc-en-rust-5a11803cbc7421cb836b5645b72141c0f0ddad499d0c81bd40e088f1edb0a766","title":"","text":" //@ compile-flags: -O #![crate_type = \"lib\"] const N: usize = 3; pub type T = u8; #[no_mangle] // CHECK-LABEL: @split_mutiple // CHECK-NOT: unreachable pub fn split_mutiple(slice: &[T]) -> (&[T], &[T]) { let len = slice.len() / N; slice.split_at(len * N) } "}
{"_id":"doc-en-rust-0035aa3b0eaca9981e8ef57f78a52308876952e6cb8366776db1ab4385ec1dfa","title":"","text":" //@ compile-flags: -O //@ min-llvm-version: 17 #![crate_type = \"lib\"] #[no_mangle] // CHECK-LABEL: @foo // CHECK: {{.*}}: // CHECK: ret // CHECK-NOT: unreachable pub fn foo(arr: &mut [u32]) { for i in 0..arr.len() { for j in 0..i { assert!(j < arr.len()); } } } "}
{"_id":"doc-en-rust-bf221456c6835cf0d5b999371402841d3ffd3eca443d079f355c1b5157df7edb","title":"","text":" //@ compile-flags: -O //@ min-llvm-version: 18 #![crate_type = \"lib\"] use std::ptr::NonNull; // CHECK-LABEL: @slice_ptr_len_1 // CHECK: {{.*}}: // CHECK-NEXT: ret i64 %ptr.1 #[no_mangle] pub fn slice_ptr_len_1(ptr: *const [u8]) -> usize { let ptr = ptr.cast_mut(); if let Some(ptr) = NonNull::new(ptr) { ptr.len() } else { // We know ptr is null, so we know ptr.wrapping_byte_add(1) is not null. NonNull::new(ptr.wrapping_byte_add(1)).unwrap().len() } } "}
{"_id":"doc-en-rust-8cccc557bbb897a16095005ee621c7ec3b6bad7d7579ceda5c9e41f2620fd571","title":"","text":"resolve_module_only = visibility must resolve to a module resolve_macro_expected_found = expected {$expected}, found {$found} `{$macro_path}` resolve_remove_surrounding_derive = remove from the surrounding `derive()` resolve_add_as_non_derive = add as non-Derive macro `#[{$macro_path}]` "}
{"_id":"doc-en-rust-76705641d9b1b09943b43f0635db853252b46fe094d6c94f1a3715054606022f","title":"","text":"#[derive(Diagnostic)] #[diag(resolve_module_only)] pub(crate) struct ModuleOnly(#[primary_span] pub(crate) Span); #[derive(Diagnostic, Default)] #[diag(resolve_macro_expected_found)] pub(crate) struct MacroExpectedFound<'a> { #[primary_span] pub(crate) span: Span, pub(crate) found: &'a str, pub(crate) expected: &'a str, pub(crate) macro_path: &'a str, #[subdiagnostic] pub(crate) remove_surrounding_derive: Option, #[subdiagnostic] pub(crate) add_as_non_derive: Option>, } #[derive(Subdiagnostic)] #[help(resolve_remove_surrounding_derive)] pub(crate) struct RemoveSurroundingDerive { #[primary_span] pub(crate) span: Span, } #[derive(Subdiagnostic)] #[help(resolve_add_as_non_derive)] pub(crate) struct AddAsNonDerive<'a> { pub(crate) macro_path: &'a str, } "}
{"_id":"doc-en-rust-33d8a2d19c33d139f9d7bb5d075ec160af09eaba0d46a25f856f23858edaa665","title":"","text":"//! A bunch of methods and structures more or less related to resolving macros and //! interface provided by `Resolver` to macro expander. use crate::errors::{AddAsNonDerive, MacroExpectedFound, RemoveSurroundingDerive}; use crate::Namespace::*; use crate::{BuiltinMacroState, Determinacy}; use crate::{DeriveData, Finalize, ParentScope, ResolutionError, Resolver, ScopeSet};"}
{"_id":"doc-en-rust-298127f5e10575f2aa3954069880b8766885a810ced2c1417d5f2d0f380809e7","title":"","text":"}; if let Some((article, expected)) = unexpected_res { let path_str = pprust::path_to_string(path); let msg = format!(\"expected {}, found {} `{}`\", expected, res.descr(), path_str); self.tcx .sess .struct_span_err(path.span, &msg) .span_label(path.span, format!(\"not {} {}\", article, expected)) .emit(); let mut err = MacroExpectedFound { span: path.span, expected, found: res.descr(), macro_path: &path_str, ..Default::default() // Subdiagnostics default to None }; // Suggest moving the macro out of the derive() if the macro isn't Derive if !path.span.from_expansion() && kind == MacroKind::Derive && ext.macro_kind() != MacroKind::Derive { err.remove_surrounding_derive = Some(RemoveSurroundingDerive { span: path.span }); err.add_as_non_derive = Some(AddAsNonDerive { macro_path: &path_str }); } let mut err = self.tcx.sess.create_err(err); err.span_label(path.span, format!(\"not {} {}\", article, expected)); err.emit(); return Ok((self.dummy_ext(kind), Res::Err)); }"}
{"_id":"doc-en-rust-ab8f94842075ac92bed6b179ffeac1da558914494c94193e7fe448ad45e97ec5","title":"","text":"| LL | #[derive(inline)] | ^^^^^^ not a derive macro | help: remove from the surrounding `derive()` --> $DIR/macro-path-prelude-fail-4.rs:1:10 | LL | #[derive(inline)] | ^^^^^^ = help: add as non-Derive macro `#[inline]` error: aborting due to previous error"}
{"_id":"doc-en-rust-178eef223314271eaf255cfdb37a0165301b246581a44626dba4149fb22cb2f6","title":"","text":" #[derive(Clone, Debug)] // OK struct S; #[derive(Debug, inline)] //~ ERROR expected derive macro, found built-in attribute `inline` struct T; #[derive(inline, Debug)] //~ ERROR expected derive macro, found built-in attribute `inline` struct U; fn main() {} "}
{"_id":"doc-en-rust-f2664f2e9882bb354b52801a467176e5e16d66ce56bd50eeae02f3708fb4bc6c","title":"","text":" error: expected derive macro, found built-in attribute `inline` --> $DIR/macro-path-prelude-fail-5.rs:4:17 | LL | #[derive(Debug, inline)] | ^^^^^^ not a derive macro | help: remove from the surrounding `derive()` --> $DIR/macro-path-prelude-fail-5.rs:4:17 | LL | #[derive(Debug, inline)] | ^^^^^^ = help: add as non-Derive macro `#[inline]` error: expected derive macro, found built-in attribute `inline` --> $DIR/macro-path-prelude-fail-5.rs:7:10 | LL | #[derive(inline, Debug)] | ^^^^^^ not a derive macro | help: remove from the surrounding `derive()` --> $DIR/macro-path-prelude-fail-5.rs:7:10 | LL | #[derive(inline, Debug)] | ^^^^^^ = help: add as non-Derive macro `#[inline]` error: aborting due to 2 previous errors "}
{"_id":"doc-en-rust-316f6238c0b0aedc554c82c8bd6238c75337dad1168877a35a664513e0971cff","title":"","text":"| LL | #[derive(my_macro_attr)] | ^^^^^^^^^^^^^ not a derive macro | help: remove from the surrounding `derive()` --> $DIR/macro-namespace-reserved-2.rs:53:10 | LL | #[derive(my_macro_attr)] | ^^^^^^^^^^^^^ = help: add as non-Derive macro `#[my_macro_attr]` error: can't use a procedural macro from the same crate that defines it --> $DIR/macro-namespace-reserved-2.rs:56:10"}
{"_id":"doc-en-rust-abc5309373c2e34d4bf1f051addfd3dd68b1bef77f4cfa38b60d8dfef4faff55","title":"","text":"| LL | #[derive(crate::my_macro)] | ^^^^^^^^^^^^^^^ not a derive macro | help: remove from the surrounding `derive()` --> $DIR/macro-namespace-reserved-2.rs:50:10 | LL | #[derive(crate::my_macro)] | ^^^^^^^^^^^^^^^ = help: add as non-Derive macro `#[crate::my_macro]` error: cannot find macro `my_macro_attr` in this scope --> $DIR/macro-namespace-reserved-2.rs:28:5"}
{"_id":"doc-en-rust-f259d33995b84327300ae9723317634e23e2f2bd89b8f6f6deb96734e85a2b5d","title":"","text":"| LL | #[derive(rustfmt::skip)] | ^^^^^^^^^^^^^ not a derive macro | help: remove from the surrounding `derive()` --> $DIR/tool-attributes-misplaced-2.rs:1:10 | LL | #[derive(rustfmt::skip)] | ^^^^^^^^^^^^^ = help: add as non-Derive macro `#[rustfmt::skip]` error: expected macro, found tool attribute `rustfmt::skip` --> $DIR/tool-attributes-misplaced-2.rs:5:5"}
{"_id":"doc-en-rust-de296a669f888411831f4186c2ed14f8a5dfb85cda31ecae11ad5dad20611913","title":"","text":"#[macro_use] mod print; mod session_diagnostics; #[cfg(all(unix, any(target_env = \"gnu\", target_os = \"macos\")))] mod signal_handler; #[cfg(not(all(unix, any(target_env = \"gnu\", target_os = \"macos\"))))] mod signal_handler { /// On platforms which don't support our signal handler's requirements, /// simply use the default signal handler provided by std. pub(super) fn install() {} } use crate::session_diagnostics::{ RLinkEmptyVersionNumber, RLinkEncodingVersionMismatch, RLinkRustcVersionMismatch,"}
{"_id":"doc-en-rust-56d4968f271bcd26a752042eee64ee33fab114d8cd71ae0cad3d76e475fa79c7","title":"","text":"} } #[cfg(all(unix, any(target_env = \"gnu\", target_os = \"macos\")))] mod signal_handler { extern \"C\" { fn backtrace_symbols_fd( buffer: *const *mut libc::c_void, size: libc::c_int, fd: libc::c_int, ); } extern \"C\" fn print_stack_trace(_: libc::c_int) { const MAX_FRAMES: usize = 256; static mut STACK_TRACE: [*mut libc::c_void; MAX_FRAMES] = [std::ptr::null_mut(); MAX_FRAMES]; unsafe { let depth = libc::backtrace(STACK_TRACE.as_mut_ptr(), MAX_FRAMES as i32); if depth == 0 { return; } backtrace_symbols_fd(STACK_TRACE.as_ptr(), depth, 2); } } /// When an error signal (such as SIGABRT or SIGSEGV) is delivered to the /// process, print a stack trace and then exit. pub(super) fn install() { use std::alloc::{alloc, Layout}; unsafe { let alt_stack_size: usize = min_sigstack_size() + 64 * 1024; let mut alt_stack: libc::stack_t = std::mem::zeroed(); alt_stack.ss_sp = alloc(Layout::from_size_align(alt_stack_size, 1).unwrap()).cast(); alt_stack.ss_size = alt_stack_size; libc::sigaltstack(&alt_stack, std::ptr::null_mut()); let mut sa: libc::sigaction = std::mem::zeroed(); sa.sa_sigaction = print_stack_trace as libc::sighandler_t; sa.sa_flags = libc::SA_NODEFER | libc::SA_RESETHAND | libc::SA_ONSTACK; libc::sigemptyset(&mut sa.sa_mask); libc::sigaction(libc::SIGSEGV, &sa, std::ptr::null_mut()); } } /// Modern kernels on modern hardware can have dynamic signal stack sizes. #[cfg(any(target_os = \"linux\", target_os = \"android\"))] fn min_sigstack_size() -> usize { const AT_MINSIGSTKSZ: core::ffi::c_ulong = 51; let dynamic_sigstksz = unsafe { libc::getauxval(AT_MINSIGSTKSZ) }; // If getauxval couldn't find the entry, it returns 0, // so take the higher of the \"constant\" and auxval. // This transparently supports older kernels which don't provide AT_MINSIGSTKSZ libc::MINSIGSTKSZ.max(dynamic_sigstksz as _) } /// Not all OS support hardware where this is needed. #[cfg(not(any(target_os = \"linux\", target_os = \"android\")))] fn min_sigstack_size() -> usize { libc::MINSIGSTKSZ } } #[cfg(not(all(unix, any(target_env = \"gnu\", target_os = \"macos\"))))] mod signal_handler { pub(super) fn install() {} } pub fn main() -> ! { let start_time = Instant::now(); let start_rss = get_resident_set_size();"}
{"_id":"doc-en-rust-7d87cd3362eaa3e2313c1adae1dac848e4031edc560f546f90c5c08fc3fdbfde","title":"","text":" //! Signal handler for rustc //! Primarily used to extract a backtrace from stack overflow use std::alloc::{alloc, Layout}; use std::{fmt, mem, ptr}; extern \"C\" { fn backtrace_symbols_fd(buffer: *const *mut libc::c_void, size: libc::c_int, fd: libc::c_int); } fn backtrace_stderr(buffer: &[*mut libc::c_void]) { let size = buffer.len().try_into().unwrap_or_default(); unsafe { backtrace_symbols_fd(buffer.as_ptr(), size, libc::STDERR_FILENO) }; } /// Unbuffered, unsynchronized writer to stderr. /// /// Only acceptable because everything will end soon anyways. struct RawStderr(()); impl fmt::Write for RawStderr { fn write_str(&mut self, s: &str) -> Result<(), fmt::Error> { let ret = unsafe { libc::write(libc::STDERR_FILENO, s.as_ptr().cast(), s.len()) }; if ret == -1 { Err(fmt::Error) } else { Ok(()) } } } /// We don't really care how many bytes we actually get out. SIGSEGV comes for our head. /// Splash stderr with letters of our own blood to warn our friends about the monster. macro raw_errln($tokens:tt) { let _ = ::core::fmt::Write::write_fmt(&mut RawStderr(()), format_args!($tokens)); let _ = ::core::fmt::Write::write_char(&mut RawStderr(()), 'n'); } /// Signal handler installed for SIGSEGV extern \"C\" fn print_stack_trace(_: libc::c_int) { const MAX_FRAMES: usize = 256; // Reserve data segment so we don't have to malloc in a signal handler, which might fail // in incredibly undesirable and unexpected ways due to e.g. the allocator deadlocking static mut STACK_TRACE: [*mut libc::c_void; MAX_FRAMES] = [ptr::null_mut(); MAX_FRAMES]; let stack = unsafe { // Collect return addresses let depth = libc::backtrace(STACK_TRACE.as_mut_ptr(), MAX_FRAMES as i32); if depth == 0 { return; } &STACK_TRACE.as_slice()[0..(depth as _)] }; // Just a stack trace is cryptic. Explain what we're doing. raw_errln!(\"error: rustc interrupted by SIGSEGV, printing backtracen\"); let mut written = 1; let mut consumed = 0; // Begin elaborating return addrs into symbols and writing them directly to stderr // Most backtraces are stack overflow, most stack overflows are from recursion // Check for cycles before writing 250 lines of the same ~5 symbols let cycled = |(runner, walker)| runner == walker; let mut cyclic = false; if let Some(period) = stack.iter().skip(1).step_by(2).zip(stack).position(cycled) { let period = period.saturating_add(1); // avoid \"what if wrapped?\" branches let Some(offset) = stack.iter().skip(period).zip(stack).position(cycled) else { // impossible. return; }; // Count matching trace slices, else we could miscount \"biphasic cycles\" // with the same period + loop entry but a different inner loop let next_cycle = stack[offset..].chunks_exact(period).skip(1); let cycles = 1 + next_cycle .zip(stack[offset..].chunks_exact(period)) .filter(|(next, prev)| next == prev) .count(); backtrace_stderr(&stack[..offset]); written += offset; consumed += offset; if cycles > 1 { raw_errln!(\"n### cycle encountered after {offset} frames with period {period}\"); backtrace_stderr(&stack[consumed..consumed + period]); raw_errln!(\"### recursed {cycles} timesn\"); written += period + 4; consumed += period * cycles; cyclic = true; }; } let rem = &stack[consumed..]; backtrace_stderr(rem); raw_errln!(\"\"); written += rem.len() + 1; let random_depth = || 8 * 16; // chosen by random diceroll (2d20) if cyclic || stack.len() > random_depth() { // technically speculation, but assert it with confidence anyway. // rustc only arrived in this signal handler because bad things happened // and this message is for explaining it's not the programmer's fault raw_errln!(\"note: rustc unexpectedly overflowed its stack! this is a bug\"); written += 1; } if stack.len() == MAX_FRAMES { raw_errln!(\"note: maximum backtrace depth reached, frames may have been lost\"); written += 1; } raw_errln!(\"note: we would appreciate a report at https://github.com/rust-lang/rust\"); written += 1; if written > 24 { // We probably just scrolled the earlier \"we got SIGSEGV\" message off the terminal raw_errln!(\"note: backtrace dumped due to SIGSEGV! resuming signal\"); }; } /// When SIGSEGV is delivered to the process, print a stack trace and then exit. pub(super) fn install() { unsafe { let alt_stack_size: usize = min_sigstack_size() + 64 * 1024; let mut alt_stack: libc::stack_t = mem::zeroed(); alt_stack.ss_sp = alloc(Layout::from_size_align(alt_stack_size, 1).unwrap()).cast(); alt_stack.ss_size = alt_stack_size; libc::sigaltstack(&alt_stack, ptr::null_mut()); let mut sa: libc::sigaction = mem::zeroed(); sa.sa_sigaction = print_stack_trace as libc::sighandler_t; sa.sa_flags = libc::SA_NODEFER | libc::SA_RESETHAND | libc::SA_ONSTACK; libc::sigemptyset(&mut sa.sa_mask); libc::sigaction(libc::SIGSEGV, &sa, ptr::null_mut()); } } /// Modern kernels on modern hardware can have dynamic signal stack sizes. #[cfg(any(target_os = \"linux\", target_os = \"android\"))] fn min_sigstack_size() -> usize { const AT_MINSIGSTKSZ: core::ffi::c_ulong = 51; let dynamic_sigstksz = unsafe { libc::getauxval(AT_MINSIGSTKSZ) }; // If getauxval couldn't find the entry, it returns 0, // so take the higher of the \"constant\" and auxval. // This transparently supports older kernels which don't provide AT_MINSIGSTKSZ libc::MINSIGSTKSZ.max(dynamic_sigstksz as _) } /// Not all OS support hardware where this is needed. #[cfg(not(any(target_os = \"linux\", target_os = \"android\")))] fn min_sigstack_size() -> usize { libc::MINSIGSTKSZ } "}
{"_id":"doc-en-rust-663644571deade5e1e9f8bcc536072e77b115f1234656de9786608e8523aa947","title":"","text":"[[package]] name = \"gccjit\" version = \"1.0.0\" source = \"git+https://github.com/antoyo/gccjit.rs#eefb8c662d61477f34b7c32d26bcda5f1ef08432\" source = \"git+https://github.com/antoyo/gccjit.rs#fe242b7eb26980e6c78859d51c8d4cc1e43381a3\" dependencies = [ \"gccjit_sys\", ]"}
{"_id":"doc-en-rust-361fa5771e4e991ace4556712031d6dd8a97aaf22c93fdcbcb1a02576fe60fc1","title":"","text":"[[package]] name = \"gccjit_sys\" version = \"0.0.1\" source = \"git+https://github.com/antoyo/gccjit.rs#eefb8c662d61477f34b7c32d26bcda5f1ef08432\" source = \"git+https://github.com/antoyo/gccjit.rs#fe242b7eb26980e6c78859d51c8d4cc1e43381a3\" dependencies = [ \"libc 0.1.12\", \"libc\", ] [[package]]"}
{"_id":"doc-en-rust-3c5fa3ddcb57d1977cae1486cee45f6ce65035093021a97ecdd6679c027e637c","title":"","text":"checksum = \"7fcd999463524c52659517fe2cea98493cfe485d10565e7b0fb07dbba7ad2753\" dependencies = [ \"cfg-if\", \"libc 0.2.112\", \"libc\", \"wasi\", ]"}
{"_id":"doc-en-rust-e9d1464466aede799fa3e194e830bd3e76f067424054a8d53d36952a7be5661e","title":"","text":"source = \"registry+https://github.com/rust-lang/crates.io-index\" checksum = \"62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33\" dependencies = [ \"libc 0.2.112\", \"libc\", ] [[package]]"}
{"_id":"doc-en-rust-46ffab6f5e8d8c09612f9cc7eb55f2bb4bf8fb4d4c031eb4291ed63d2384f1f7","title":"","text":"dependencies = [ \"fm\", \"getopts\", \"libc 0.2.112\", \"libc\", \"num_cpus\", \"termcolor\", \"threadpool\","}
{"_id":"doc-en-rust-d036240af68a05d3ffe39ca80ecc037d58ade0a3df6165c1194e5f4fc3bc977e","title":"","text":"[[package]] name = \"libc\" version = \"0.1.12\" source = \"registry+https://github.com/rust-lang/crates.io-index\" checksum = \"e32a70cf75e5846d53a673923498228bbec6a8624708a9ea5645f075d6276122\" [[package]] name = \"libc\" version = \"0.2.112\" source = \"registry+https://github.com/rust-lang/crates.io-index\" checksum = \"1b03d17f364a3a042d5e5d46b053bbbf82c92c9430c592dd4c064dc6ee997125\""}
{"_id":"doc-en-rust-104102bd782f0fba6e1893fe933f36625b8e7ca0b182f56ef80c20831a8f995a","title":"","text":"checksum = \"05499f3756671c15885fee9034446956fff3f243d6077b91e5767df161f766b3\" dependencies = [ \"hermit-abi\", \"libc 0.2.112\", \"libc\", ] [[package]]"}
{"_id":"doc-en-rust-0c11f4f055b746444255c2800a86d7aafc783b078af163c9c1c4881c7e5e72cc","title":"","text":"source = \"registry+https://github.com/rust-lang/crates.io-index\" checksum = \"2e7573632e6454cf6b99d7aac4ccca54be06da05aca2ef7423d22d27d4d4bcd8\" dependencies = [ \"libc 0.2.112\", \"libc\", \"rand_chacha\", \"rand_core\", \"rand_hc\","}
{"_id":"doc-en-rust-2eecb4d630c95336b203e9b2091ab59bc53288e85a38694fc6bebfc5d243245c","title":"","text":"checksum = \"dac1c663cfc93810f88aed9b8941d48cabf856a1b111c29a40439018d870eb22\" dependencies = [ \"cfg-if\", \"libc 0.2.112\", \"libc\", \"rand\", \"redox_syscall\", \"remove_dir_all\","}
{"_id":"doc-en-rust-aa1d8a9122109f8c63077083893f7bc934831c9f74585db4a477e61f3af72230","title":"","text":"source = \"registry+https://github.com/rust-lang/crates.io-index\" checksum = \"9f200f5b12eb75f8c1ed65abd4b2db8a6e1b138a20de009dacee265a2498f3f6\" dependencies = [ \"libc 0.2.112\", \"libc\", ] [[package]]"}
{"_id":"doc-en-rust-82338ff14fdeb563be9f15dba88e5a990a0972735c524766b9a651264410e8c7","title":"","text":"// index position where it *should have been*, which is *after* the previous one. if let Some(provided_idx) = provided_idx { prev = provided_idx.index() as i64; continue; } let idx = ProvidedIdx::from_usize((prev + 1) as usize); if let None = provided_idx && let Some((_, arg_span)) = provided_arg_tys.get(idx) { if let Some((_, arg_span)) = provided_arg_tys.get(idx) { prev += 1; // There is a type that was *not* found anywhere, so it isn't a move, but a // replacement and we look at what type it should have been. This will allow us // To suggest a multipart suggestion when encountering `foo(1, \"\")` where the def"}
{"_id":"doc-en-rust-5db59d44dfd59430b6efc69de60da8b1ad5cfdf9008caa4ef83dd3609b6efc44","title":"","text":" struct A; struct B; fn f(b1: B, b2: B, a2: C) {} //~ ERROR E0412 fn main() { f(A, A, B, C); //~ ERROR E0425 //~^ ERROR E0061 } "}
{"_id":"doc-en-rust-8f05fa786ea1a47ff1234efdfdc09c56fdf7751d44c30504810bacffadd964b6","title":"","text":" error[E0412]: cannot find type `C` in this scope --> $DIR/issue-109831.rs:4:24 | LL | struct A; | --------- similarly named struct `A` defined here ... LL | fn f(b1: B, b2: B, a2: C) {} | ^ | help: a struct with a similar name exists | LL | fn f(b1: B, b2: B, a2: A) {} | ~ help: you might be missing a type parameter | LL | fn f(b1: B, b2: B, a2: C) {} | +++ error[E0425]: cannot find value `C` in this scope --> $DIR/issue-109831.rs:7:16 | LL | struct A; | --------- similarly named unit struct `A` defined here ... LL | f(A, A, B, C); | ^ help: a unit struct with a similar name exists: `A` error[E0061]: this function takes 3 arguments but 4 arguments were supplied --> $DIR/issue-109831.rs:7:5 | LL | f(A, A, B, C); | ^ - - - unexpected argument | | | | | expected `B`, found `A` | expected `B`, found `A` | note: function defined here --> $DIR/issue-109831.rs:4:4 | LL | fn f(b1: B, b2: B, a2: C) {} | ^ ----- ----- ----- help: remove the extra argument | LL - f(A, A, B, C); LL + f(/* B */, /* B */, B); | error: aborting due to 3 previous errors Some errors have detailed explanations: E0061, E0412, E0425. For more information about an error, try `rustc --explain E0061`. "}
{"_id":"doc-en-rust-81fb057c353b530318402da780dbf61e2e7e4dc6c054d5966d6d4e5a18479b74","title":"","text":"let tcx = self.tcx; let def_id = instance.def_id(); let containing_scope = get_containing_scope(self, instance); let (containing_scope, is_method) = get_containing_scope(self, instance); let span = tcx.def_span(def_id); let loc = self.lookup_debug_loc(span.lo()); let file_metadata = file_metadata(self, &loc.file);"}
{"_id":"doc-en-rust-273c7e6bbc3125a4901e982b47f083a82e0bb3bf34ad31bbe719cd431d914e8b","title":"","text":"} } unsafe { return llvm::LLVMRustDIBuilderCreateFunction( // When we're adding a method to a type DIE, we only want a DW_AT_declaration there, because // LLVM LTO can't unify type definitions when a child DIE is a full subprogram definition. // When we use this `decl` below, the subprogram definition gets created at the CU level // with a DW_AT_specification pointing back to the type's declaration. let decl = is_method.then(|| unsafe { llvm::LLVMRustDIBuilderCreateMethod( DIB(self), containing_scope, name.as_ptr().cast(), name.len(), linkage_name.as_ptr().cast(), linkage_name.len(), file_metadata, loc.line, function_type_metadata, flags, spflags & !DISPFlags::SPFlagDefinition, template_parameters, ) }); return unsafe { llvm::LLVMRustDIBuilderCreateFunction( DIB(self), containing_scope, name.as_ptr().cast(),"}
{"_id":"doc-en-rust-004b0f27c043622f4cf292a91cb7d1d01dc2407189414de16781512a28d9c3d7","title":"","text":"spflags, maybe_definition_llfn, template_parameters, None, ); } decl, ) }; fn get_function_signature<'ll, 'tcx>( cx: &CodegenCx<'ll, 'tcx>,"}
{"_id":"doc-en-rust-577347ff97a897de52aeafa2b5ea174a38d8065492229dedd255a8acc7029c42","title":"","text":"names } /// Returns a scope, plus `true` if that's a type scope for \"class\" methods, /// otherwise `false` for plain namespace scopes. fn get_containing_scope<'ll, 'tcx>( cx: &CodegenCx<'ll, 'tcx>, instance: Instance<'tcx>, ) -> &'ll DIScope { ) -> (&'ll DIScope, bool) { // First, let's see if this is a method within an inherent impl. Because // if yes, we want to make the result subroutine DIE a child of the // subroutine's self-type. let self_type = cx.tcx.impl_of_method(instance.def_id()).and_then(|impl_def_id| { if let Some(impl_def_id) = cx.tcx.impl_of_method(instance.def_id()) { // If the method does *not* belong to a trait, proceed if cx.tcx.trait_id_of_impl(impl_def_id).is_none() { let impl_self_ty = cx.tcx.subst_and_normalize_erasing_regions("}
{"_id":"doc-en-rust-812257b9bdeb685c50874e6f128920f13b777316032b980e574632fdda214a1c","title":"","text":"// Only \"class\" methods are generally understood by LLVM, // so avoid methods on other types (e.g., `<*mut T>::null`). match impl_self_ty.kind() { ty::Adt(def, ..) if !def.is_box() => { // Again, only create type information if full debuginfo is enabled if cx.sess().opts.debuginfo == DebugInfo::Full && !impl_self_ty.has_param() { Some(type_di_node(cx, impl_self_ty)) } else { Some(namespace::item_namespace(cx, def.did())) } if let ty::Adt(def, ..) = impl_self_ty.kind() && !def.is_box() { // Again, only create type information if full debuginfo is enabled if cx.sess().opts.debuginfo == DebugInfo::Full && !impl_self_ty.has_param() { return (type_di_node(cx, impl_self_ty), true); } else { return (namespace::item_namespace(cx, def.did()), false); } _ => None, } } else { // For trait method impls we still use the \"parallel namespace\" // strategy None } }); } self_type.unwrap_or_else(|| { namespace::item_namespace( cx, DefId { krate: instance.def_id().krate, index: cx .tcx .def_key(instance.def_id()) .parent .expect(\"get_containing_scope: missing parent?\"), }, ) }) let scope = namespace::item_namespace( cx, DefId { krate: instance.def_id().krate, index: cx .tcx .def_key(instance.def_id()) .parent .expect(\"get_containing_scope: missing parent?\"), }, ); (scope, false) } }"}
{"_id":"doc-en-rust-0be7240ef85bc21347d918bc5d890d696866e23a0db884eb854b166a26b2507e","title":"","text":"Decl: Option<&'a DIDescriptor>, ) -> &'a DISubprogram; pub fn LLVMRustDIBuilderCreateMethod<'a>( Builder: &DIBuilder<'a>, Scope: &'a DIDescriptor, Name: *const c_char, NameLen: size_t, LinkageName: *const c_char, LinkageNameLen: size_t, File: &'a DIFile, LineNo: c_uint, Ty: &'a DIType, Flags: DIFlags, SPFlags: DISPFlags, TParam: &'a DIArray, ) -> &'a DISubprogram; pub fn LLVMRustDIBuilderCreateBasicType<'a>( Builder: &DIBuilder<'a>, Name: *const c_char,"}
{"_id":"doc-en-rust-4e8f316ef48671535b797caecef9dca4f9964f383067bca8b9067100a3c86f70","title":"","text":"return wrap(Sub); } extern \"C\" LLVMMetadataRef LLVMRustDIBuilderCreateMethod( LLVMRustDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name, size_t NameLen, const char *LinkageName, size_t LinkageNameLen, LLVMMetadataRef File, unsigned LineNo, LLVMMetadataRef Ty, LLVMRustDIFlags Flags, LLVMRustDISPFlags SPFlags, LLVMMetadataRef TParam) { DITemplateParameterArray TParams = DITemplateParameterArray(unwrap(TParam)); DISubprogram::DISPFlags llvmSPFlags = fromRust(SPFlags); DINode::DIFlags llvmFlags = fromRust(Flags); DISubprogram *Sub = Builder->createMethod( unwrapDI(Scope), StringRef(Name, NameLen), StringRef(LinkageName, LinkageNameLen), unwrapDI(File), LineNo, unwrapDI(Ty), 0, 0, nullptr, // VTable params aren't used llvmFlags, llvmSPFlags, TParams); return wrap(Sub); } extern \"C\" LLVMMetadataRef LLVMRustDIBuilderCreateBasicType( LLVMRustDIBuilderRef Builder, const char *Name, size_t NameLen, uint64_t SizeInBits, unsigned Encoding) {"}
{"_id":"doc-en-rust-04b039140e9d55e2882bf916372c154de5846db9f452826e34f921a8d9a56423","title":"","text":" # ignore-cross-compile include ../tools.mk # With the upgrade to LLVM 16, this was getting: # # error: Cannot represent a difference across sections # # The error stemmed from DI function definitions under type scopes, fixed by # only declaring in type scope and defining the subprogram elsewhere. all: $(RUSTC) lib.rs --test -C lto=fat -C debuginfo=2 -C incremental=$(TMPDIR)/inc-fat "}
{"_id":"doc-en-rust-3832c1dda031dac89de40e50c7c43769c33998421d496b0b2e5f0bd53e2bae8d","title":"","text":" extern crate alloc; #[cfg(test)] mod tests { #[test] fn something_alloc() { assert_eq!(Vec::::new(), Vec::::new()); } } "}
{"_id":"doc-en-rust-7b8470178e22d34a4a768d3b0d5d1dd10b71d7a45f797f4951a866a990d3363e","title":"","text":"/// use std::sync::Arc; /// use std::task::{Context, Poll, Wake}; /// use std::thread::{self, Thread}; /// use core::pin::pin; /// /// /// A waker that wakes up the current thread when called. /// struct ThreadWaker(Thread);"}
{"_id":"doc-en-rust-dd8d3690ad863d2d9c58b8048cedb838a3086a0681cb8102d208db01420cc335","title":"","text":"/// /// Run a future to completion on the current thread. /// fn block_on(fut: impl Future