| author | bors <bors@rust-lang.org> 2025-06-22 09:49:14 UTC |
| committer | bors <bors@rust-lang.org> 2025-06-22 09:49:14 UTC |
| log | a30f1783fe136d92545423dd30b12eb619973cdb |
| tree | 61f87ea56fcedeae69b194a37dd41b06e1f5f866 |
| parent | 9972ebfcc2b1ab322dc6611c1c997344078e05cd |
| parent | 34dd5362be9fc460208d7b465d0911f25ab4035b |
Rollup of 10 pull requests
Successful merges:
- rust-lang/rust#140254 (Pass -Cpanic=abort for the panic_abort crate)
- rust-lang/rust#142600 (Port `#[rustc_pub_transparent]` to the new attribute system)
- rust-lang/rust#142617 (improve search graph docs, reset `encountered_overflow` between reruns)
- rust-lang/rust#142747 (rustdoc_json: conversion cleanups)
- rust-lang/rust#142776 (All HIR attributes are outer)
- rust-lang/rust#142800 (integer docs: remove extraneous text)
- rust-lang/rust#142841 (Enable fmt-write-bloat for Windows)
- rust-lang/rust#142845 (Enable textrel-on-minimal-lib for Windows)
- rust-lang/rust#142850 (remove asm_goto feature annotation, for it is now stabilized)
- rust-lang/rust#142860 (Notify me on tidy changes)
r? `@ghost`
`@rustbot` modify labels: rollup36 files changed, 536 insertions(+), 913 deletions(-)
compiler/rustc_ast/src/attr/mod.rs+22-7| ... | ... | @@ -206,12 +206,24 @@ impl AttributeExt for Attribute { |
| 206 | 206 | } |
| 207 | 207 | } |
| 208 | 208 | |
| 209 | fn style(&self) -> AttrStyle { | |
| 210 | self.style | |
| 209 | fn doc_resolution_scope(&self) -> Option<AttrStyle> { | |
| 210 | match &self.kind { | |
| 211 | AttrKind::DocComment(..) => Some(self.style), | |
| 212 | AttrKind::Normal(normal) | |
| 213 | if normal.item.path == sym::doc && normal.item.value_str().is_some() => | |
| 214 | { | |
| 215 | Some(self.style) | |
| 216 | } | |
| 217 | _ => None, | |
| 218 | } | |
| 211 | 219 | } |
| 212 | 220 | } |
| 213 | 221 | |
| 214 | 222 | impl Attribute { |
| 223 | pub fn style(&self) -> AttrStyle { | |
| 224 | self.style | |
| 225 | } | |
| 226 | ||
| 215 | 227 | pub fn may_have_doc_links(&self) -> bool { |
| 216 | 228 | self.doc_str().is_some_and(|s| comments::may_have_doc_links(s.as_str())) |
| 217 | 229 | } |
| ... | ... | @@ -806,7 +818,14 @@ pub trait AttributeExt: Debug { |
| 806 | 818 | /// * `#[doc(...)]` returns `None`. |
| 807 | 819 | fn doc_str_and_comment_kind(&self) -> Option<(Symbol, CommentKind)>; |
| 808 | 820 | |
| 809 | fn style(&self) -> AttrStyle; | |
| 821 | /// Returns outer or inner if this is a doc attribute or a sugared doc | |
| 822 | /// comment, otherwise None. | |
| 823 | /// | |
| 824 | /// This is used in the case of doc comments on modules, to decide whether | |
| 825 | /// to resolve intra-doc links against the symbols in scope within the | |
| 826 | /// commented module (for inner doc) vs within its parent module (for outer | |
| 827 | /// doc). | |
| 828 | fn doc_resolution_scope(&self) -> Option<AttrStyle>; | |
| 810 | 829 | } |
| 811 | 830 | |
| 812 | 831 | // FIXME(fn_delegation): use function delegation instead of manually forwarding |
| ... | ... | @@ -881,8 +900,4 @@ impl Attribute { |
| 881 | 900 | pub fn doc_str_and_comment_kind(&self) -> Option<(Symbol, CommentKind)> { |
| 882 | 901 | AttributeExt::doc_str_and_comment_kind(self) |
| 883 | 902 | } |
| 884 | ||
| 885 | pub fn style(&self) -> AttrStyle { | |
| 886 | AttributeExt::style(self) | |
| 887 | } | |
| 888 | 903 | } |
compiler/rustc_attr_data_structures/src/attributes.rs+3| ... | ... | @@ -240,6 +240,9 @@ pub enum AttributeKind { |
| 240 | 240 | /// Represents `#[optimize(size|speed)]` |
| 241 | 241 | Optimize(OptimizeAttr, Span), |
| 242 | 242 | |
| 243 | /// Represents `#[rustc_pub_transparent]` (used by the `repr_transparent_external_private_fields` lint). | |
| 244 | PubTransparent(Span), | |
| 245 | ||
| 243 | 246 | /// Represents [`#[repr]`](https://doc.rust-lang.org/stable/reference/type-layout.html#representations). |
| 244 | 247 | Repr(ThinVec<(ReprAttr, Span)>), |
| 245 | 248 |
compiler/rustc_attr_parsing/src/attributes/lint_helpers.rs+13| ... | ... | @@ -19,3 +19,16 @@ impl<S: Stage> SingleAttributeParser<S> for AsPtrParser { |
| 19 | 19 | Some(AttributeKind::AsPtr(cx.attr_span)) |
| 20 | 20 | } |
| 21 | 21 | } |
| 22 | ||
| 23 | pub(crate) struct PubTransparentParser; | |
| 24 | impl<S: Stage> SingleAttributeParser<S> for PubTransparentParser { | |
| 25 | const PATH: &[Symbol] = &[sym::rustc_pub_transparent]; | |
| 26 | const ATTRIBUTE_ORDER: AttributeOrder = AttributeOrder::KeepFirst; | |
| 27 | const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error; | |
| 28 | const TEMPLATE: AttributeTemplate = template!(Word); | |
| 29 | ||
| 30 | fn convert(cx: &mut AcceptContext<'_, '_, S>, _args: &ArgParser<'_>) -> Option<AttributeKind> { | |
| 31 | // FIXME: check that there's no args (this is currently checked elsewhere) | |
| 32 | Some(AttributeKind::PubTransparent(cx.attr_span)) | |
| 33 | } | |
| 34 | } |
compiler/rustc_attr_parsing/src/context.rs+2-1| ... | ... | @@ -19,7 +19,7 @@ use crate::attributes::codegen_attrs::{ColdParser, OptimizeParser}; |
| 19 | 19 | use crate::attributes::confusables::ConfusablesParser; |
| 20 | 20 | use crate::attributes::deprecation::DeprecationParser; |
| 21 | 21 | use crate::attributes::inline::{InlineParser, RustcForceInlineParser}; |
| 22 | use crate::attributes::lint_helpers::AsPtrParser; | |
| 22 | use crate::attributes::lint_helpers::{AsPtrParser, PubTransparentParser}; | |
| 23 | 23 | use crate::attributes::repr::{AlignParser, ReprParser}; |
| 24 | 24 | use crate::attributes::semantics::MayDangleParser; |
| 25 | 25 | use crate::attributes::stability::{ |
| ... | ... | @@ -113,6 +113,7 @@ attribute_parsers!( |
| 113 | 113 | Single<InlineParser>, |
| 114 | 114 | Single<MayDangleParser>, |
| 115 | 115 | Single<OptimizeParser>, |
| 116 | Single<PubTransparentParser>, | |
| 116 | 117 | Single<RustcForceInlineParser>, |
| 117 | 118 | Single<TransparencyParser>, |
| 118 | 119 | // tidy-alphabetical-end |
compiler/rustc_feature/src/builtin_attrs.rs+1-1| ... | ... | @@ -710,7 +710,7 @@ pub static BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[ |
| 710 | 710 | ), |
| 711 | 711 | rustc_attr!( |
| 712 | 712 | rustc_pub_transparent, Normal, template!(Word), |
| 713 | WarnFollowing, EncodeCrossCrate::Yes, | |
| 713 | ErrorFollowing, EncodeCrossCrate::Yes, | |
| 714 | 714 | "used internally to mark types with a `transparent` representation when it is guaranteed by the documentation", |
| 715 | 715 | ), |
| 716 | 716 |
compiler/rustc_hir/src/hir.rs+10-21| ... | ... | @@ -1346,12 +1346,13 @@ impl AttributeExt for Attribute { |
| 1346 | 1346 | } |
| 1347 | 1347 | } |
| 1348 | 1348 | |
| 1349 | #[inline] | |
| 1350 | fn style(&self) -> AttrStyle { | |
| 1351 | match &self { | |
| 1352 | Attribute::Unparsed(u) => u.style, | |
| 1353 | Attribute::Parsed(AttributeKind::DocComment { style, .. }) => *style, | |
| 1354 | _ => panic!(), | |
| 1349 | fn doc_resolution_scope(&self) -> Option<AttrStyle> { | |
| 1350 | match self { | |
| 1351 | Attribute::Parsed(AttributeKind::DocComment { style, .. }) => Some(*style), | |
| 1352 | Attribute::Unparsed(attr) if self.has_name(sym::doc) && self.value_str().is_some() => { | |
| 1353 | Some(attr.style) | |
| 1354 | } | |
| 1355 | _ => None, | |
| 1355 | 1356 | } |
| 1356 | 1357 | } |
| 1357 | 1358 | } |
| ... | ... | @@ -1442,11 +1443,6 @@ impl Attribute { |
| 1442 | 1443 | pub fn doc_str_and_comment_kind(&self) -> Option<(Symbol, CommentKind)> { |
| 1443 | 1444 | AttributeExt::doc_str_and_comment_kind(self) |
| 1444 | 1445 | } |
| 1445 | ||
| 1446 | #[inline] | |
| 1447 | pub fn style(&self) -> AttrStyle { | |
| 1448 | AttributeExt::style(self) | |
| 1449 | } | |
| 1450 | 1446 | } |
| 1451 | 1447 | |
| 1452 | 1448 | /// Attributes owned by a HIR owner. |
| ... | ... | @@ -2286,16 +2282,9 @@ pub struct Expr<'hir> { |
| 2286 | 2282 | } |
| 2287 | 2283 | |
| 2288 | 2284 | impl Expr<'_> { |
| 2289 | pub fn precedence( | |
| 2290 | &self, | |
| 2291 | for_each_attr: &dyn Fn(HirId, &mut dyn FnMut(&Attribute)), | |
| 2292 | ) -> ExprPrecedence { | |
| 2285 | pub fn precedence(&self, has_attr: &dyn Fn(HirId) -> bool) -> ExprPrecedence { | |
| 2293 | 2286 | let prefix_attrs_precedence = || -> ExprPrecedence { |
| 2294 | let mut has_outer_attr = false; | |
| 2295 | for_each_attr(self.hir_id, &mut |attr: &Attribute| { | |
| 2296 | has_outer_attr |= matches!(attr.style(), AttrStyle::Outer) | |
| 2297 | }); | |
| 2298 | if has_outer_attr { ExprPrecedence::Prefix } else { ExprPrecedence::Unambiguous } | |
| 2287 | if has_attr(self.hir_id) { ExprPrecedence::Prefix } else { ExprPrecedence::Unambiguous } | |
| 2299 | 2288 | }; |
| 2300 | 2289 | |
| 2301 | 2290 | match &self.kind { |
| ... | ... | @@ -2351,7 +2340,7 @@ impl Expr<'_> { |
| 2351 | 2340 | | ExprKind::Use(..) |
| 2352 | 2341 | | ExprKind::Err(_) => prefix_attrs_precedence(), |
| 2353 | 2342 | |
| 2354 | ExprKind::DropTemps(expr, ..) => expr.precedence(for_each_attr), | |
| 2343 | ExprKind::DropTemps(expr, ..) => expr.precedence(has_attr), | |
| 2355 | 2344 | } |
| 2356 | 2345 | } |
| 2357 | 2346 |
compiler/rustc_hir_analysis/src/check/check.rs+6-1| ... | ... | @@ -2,6 +2,7 @@ use std::cell::LazyCell; |
| 2 | 2 | use std::ops::ControlFlow; |
| 3 | 3 | |
| 4 | 4 | use rustc_abi::FieldIdx; |
| 5 | use rustc_attr_data_structures::AttributeKind; | |
| 5 | 6 | use rustc_attr_data_structures::ReprAttr::ReprPacked; |
| 6 | 7 | use rustc_data_structures::unord::{UnordMap, UnordSet}; |
| 7 | 8 | use rustc_errors::codes::*; |
| ... | ... | @@ -1384,7 +1385,11 @@ pub(super) fn check_transparent<'tcx>(tcx: TyCtxt<'tcx>, adt: ty::AdtDef<'tcx>) |
| 1384 | 1385 | ty::Tuple(list) => list.iter().try_for_each(|t| check_non_exhaustive(tcx, t)), |
| 1385 | 1386 | ty::Array(ty, _) => check_non_exhaustive(tcx, *ty), |
| 1386 | 1387 | ty::Adt(def, args) => { |
| 1387 | if !def.did().is_local() && !tcx.has_attr(def.did(), sym::rustc_pub_transparent) | |
| 1388 | if !def.did().is_local() | |
| 1389 | && !attrs::find_attr!( | |
| 1390 | tcx.get_all_attrs(def.did()), | |
| 1391 | AttributeKind::PubTransparent(_) | |
| 1392 | ) | |
| 1388 | 1393 | { |
| 1389 | 1394 | let non_exhaustive = def.is_variant_list_non_exhaustive() |
| 1390 | 1395 | || def |
compiler/rustc_hir_pretty/src/lib.rs+40-54| ... | ... | @@ -10,7 +10,7 @@ use std::vec; |
| 10 | 10 | |
| 11 | 11 | use rustc_abi::ExternAbi; |
| 12 | 12 | use rustc_ast::util::parser::{self, ExprPrecedence, Fixity}; |
| 13 | use rustc_ast::{AttrStyle, DUMMY_NODE_ID, DelimArgs}; | |
| 13 | use rustc_ast::{DUMMY_NODE_ID, DelimArgs}; | |
| 14 | 14 | use rustc_ast_pretty::pp::Breaks::{Consistent, Inconsistent}; |
| 15 | 15 | use rustc_ast_pretty::pp::{self, BoxMarker, Breaks}; |
| 16 | 16 | use rustc_ast_pretty::pprust::state::MacHeader; |
| ... | ... | @@ -81,32 +81,24 @@ impl<'a> State<'a> { |
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | fn precedence(&self, expr: &hir::Expr<'_>) -> ExprPrecedence { |
| 84 | let for_each_attr = |id: HirId, callback: &mut dyn FnMut(&hir::Attribute)| { | |
| 85 | self.attrs(id).iter().for_each(callback); | |
| 86 | }; | |
| 87 | expr.precedence(&for_each_attr) | |
| 88 | } | |
| 89 | ||
| 90 | fn print_attrs_as_inner(&mut self, attrs: &[hir::Attribute]) { | |
| 91 | self.print_either_attributes(attrs, ast::AttrStyle::Inner) | |
| 92 | } | |
| 93 | ||
| 94 | fn print_attrs_as_outer(&mut self, attrs: &[hir::Attribute]) { | |
| 95 | self.print_either_attributes(attrs, ast::AttrStyle::Outer) | |
| 84 | let has_attr = |id: HirId| !self.attrs(id).is_empty(); | |
| 85 | expr.precedence(&has_attr) | |
| 96 | 86 | } |
| 97 | 87 | |
| 98 | fn print_either_attributes(&mut self, attrs: &[hir::Attribute], style: ast::AttrStyle) { | |
| 88 | fn print_attrs(&mut self, attrs: &[hir::Attribute]) { | |
| 99 | 89 | if attrs.is_empty() { |
| 100 | 90 | return; |
| 101 | 91 | } |
| 102 | 92 | |
| 103 | 93 | for attr in attrs { |
| 104 | self.print_attribute_inline(attr, style); | |
| 94 | self.print_attribute_as_style(attr, ast::AttrStyle::Outer); | |
| 105 | 95 | } |
| 106 | 96 | self.hardbreak_if_not_bol(); |
| 107 | 97 | } |
| 108 | 98 | |
| 109 | fn print_attribute_inline(&mut self, attr: &hir::Attribute, style: AttrStyle) { | |
| 99 | /// Print a single attribute as if it has style `style`, disregarding the | |
| 100 | /// actual style of the attribute. | |
| 101 | fn print_attribute_as_style(&mut self, attr: &hir::Attribute, style: ast::AttrStyle) { | |
| 110 | 102 | match &attr { |
| 111 | 103 | hir::Attribute::Unparsed(unparsed) => { |
| 112 | 104 | self.maybe_print_comment(unparsed.span.lo()); |
| ... | ... | @@ -118,14 +110,17 @@ impl<'a> State<'a> { |
| 118 | 110 | self.word("]"); |
| 119 | 111 | self.hardbreak() |
| 120 | 112 | } |
| 121 | hir::Attribute::Parsed(AttributeKind::DocComment { style, kind, comment, .. }) => { | |
| 113 | hir::Attribute::Parsed(AttributeKind::DocComment { kind, comment, .. }) => { | |
| 122 | 114 | self.word(rustc_ast_pretty::pprust::state::doc_comment_to_string( |
| 123 | *kind, *style, *comment, | |
| 115 | *kind, style, *comment, | |
| 124 | 116 | )); |
| 125 | 117 | self.hardbreak() |
| 126 | 118 | } |
| 127 | 119 | hir::Attribute::Parsed(pa) => { |
| 128 | self.word("#[attr = "); | |
| 120 | match style { | |
| 121 | ast::AttrStyle::Inner => self.word("#![attr = "), | |
| 122 | ast::AttrStyle::Outer => self.word("#[attr = "), | |
| 123 | } | |
| 129 | 124 | pa.print_attribute(self); |
| 130 | 125 | self.word("]"); |
| 131 | 126 | self.hardbreak() |
| ... | ... | @@ -281,10 +276,17 @@ pub fn print_crate<'a>( |
| 281 | 276 | ann, |
| 282 | 277 | }; |
| 283 | 278 | |
| 279 | // Print all attributes, regardless of actual style, as inner attributes | |
| 280 | // since this is the crate root with nothing above it to print outer | |
| 281 | // attributes. | |
| 282 | for attr in s.attrs(hir::CRATE_HIR_ID) { | |
| 283 | s.print_attribute_as_style(attr, ast::AttrStyle::Inner); | |
| 284 | } | |
| 285 | ||
| 284 | 286 | // When printing the AST, we sometimes need to inject `#[no_std]` here. |
| 285 | 287 | // Since you can't compile the HIR, it's not necessary. |
| 286 | 288 | |
| 287 | s.print_mod(krate, (*attrs)(hir::CRATE_HIR_ID)); | |
| 289 | s.print_mod(krate); | |
| 288 | 290 | s.print_remaining_comments(); |
| 289 | 291 | s.s.eof() |
| 290 | 292 | } |
| ... | ... | @@ -299,7 +301,7 @@ where |
| 299 | 301 | } |
| 300 | 302 | |
| 301 | 303 | pub fn attribute_to_string(ann: &dyn PpAnn, attr: &hir::Attribute) -> String { |
| 302 | to_string(ann, |s| s.print_attribute_inline(attr, AttrStyle::Outer)) | |
| 304 | to_string(ann, |s| s.print_attribute_as_style(attr, ast::AttrStyle::Outer)) | |
| 303 | 305 | } |
| 304 | 306 | |
| 305 | 307 | pub fn ty_to_string(ann: &dyn PpAnn, ty: &hir::Ty<'_>) -> String { |
| ... | ... | @@ -361,8 +363,7 @@ impl<'a> State<'a> { |
| 361 | 363 | self.commasep_cmnt(b, exprs, |s, e| s.print_expr(e), |e| e.span); |
| 362 | 364 | } |
| 363 | 365 | |
| 364 | fn print_mod(&mut self, _mod: &hir::Mod<'_>, attrs: &[hir::Attribute]) { | |
| 365 | self.print_attrs_as_inner(attrs); | |
| 366 | fn print_mod(&mut self, _mod: &hir::Mod<'_>) { | |
| 366 | 367 | for &item_id in _mod.item_ids { |
| 367 | 368 | self.ann.nested(self, Nested::Item(item_id)); |
| 368 | 369 | } |
| ... | ... | @@ -479,7 +480,7 @@ impl<'a> State<'a> { |
| 479 | 480 | fn print_foreign_item(&mut self, item: &hir::ForeignItem<'_>) { |
| 480 | 481 | self.hardbreak_if_not_bol(); |
| 481 | 482 | self.maybe_print_comment(item.span.lo()); |
| 482 | self.print_attrs_as_outer(self.attrs(item.hir_id())); | |
| 483 | self.print_attrs(self.attrs(item.hir_id())); | |
| 483 | 484 | match item.kind { |
| 484 | 485 | hir::ForeignItemKind::Fn(sig, arg_idents, generics) => { |
| 485 | 486 | let (cb, ib) = self.head(""); |
| ... | ... | @@ -565,7 +566,7 @@ impl<'a> State<'a> { |
| 565 | 566 | self.hardbreak_if_not_bol(); |
| 566 | 567 | self.maybe_print_comment(item.span.lo()); |
| 567 | 568 | let attrs = self.attrs(item.hir_id()); |
| 568 | self.print_attrs_as_outer(attrs); | |
| 569 | self.print_attrs(attrs); | |
| 569 | 570 | self.ann.pre(self, AnnNode::Item(item)); |
| 570 | 571 | match item.kind { |
| 571 | 572 | hir::ItemKind::ExternCrate(orig_name, ident) => { |
| ... | ... | @@ -647,14 +648,13 @@ impl<'a> State<'a> { |
| 647 | 648 | self.print_ident(ident); |
| 648 | 649 | self.nbsp(); |
| 649 | 650 | self.bopen(ib); |
| 650 | self.print_mod(mod_, attrs); | |
| 651 | self.print_mod(mod_); | |
| 651 | 652 | self.bclose(item.span, cb); |
| 652 | 653 | } |
| 653 | 654 | hir::ItemKind::ForeignMod { abi, items } => { |
| 654 | 655 | let (cb, ib) = self.head("extern"); |
| 655 | 656 | self.word_nbsp(abi.to_string()); |
| 656 | 657 | self.bopen(ib); |
| 657 | self.print_attrs_as_inner(self.attrs(item.hir_id())); | |
| 658 | 658 | for item in items { |
| 659 | 659 | self.ann.nested(self, Nested::ForeignItem(item.id)); |
| 660 | 660 | } |
| ... | ... | @@ -731,7 +731,6 @@ impl<'a> State<'a> { |
| 731 | 731 | |
| 732 | 732 | self.space(); |
| 733 | 733 | self.bopen(ib); |
| 734 | self.print_attrs_as_inner(attrs); | |
| 735 | 734 | for impl_item in items { |
| 736 | 735 | self.ann.nested(self, Nested::ImplItem(impl_item.id)); |
| 737 | 736 | } |
| ... | ... | @@ -822,7 +821,7 @@ impl<'a> State<'a> { |
| 822 | 821 | for v in variants { |
| 823 | 822 | self.space_if_not_bol(); |
| 824 | 823 | self.maybe_print_comment(v.span.lo()); |
| 825 | self.print_attrs_as_outer(self.attrs(v.hir_id)); | |
| 824 | self.print_attrs(self.attrs(v.hir_id)); | |
| 826 | 825 | let ib = self.ibox(INDENT_UNIT); |
| 827 | 826 | self.print_variant(v); |
| 828 | 827 | self.word(","); |
| ... | ... | @@ -857,7 +856,7 @@ impl<'a> State<'a> { |
| 857 | 856 | self.popen(); |
| 858 | 857 | self.commasep(Inconsistent, struct_def.fields(), |s, field| { |
| 859 | 858 | s.maybe_print_comment(field.span.lo()); |
| 860 | s.print_attrs_as_outer(s.attrs(field.hir_id)); | |
| 859 | s.print_attrs(s.attrs(field.hir_id)); | |
| 861 | 860 | s.print_type(field.ty); |
| 862 | 861 | }); |
| 863 | 862 | self.pclose(); |
| ... | ... | @@ -878,7 +877,7 @@ impl<'a> State<'a> { |
| 878 | 877 | for field in struct_def.fields() { |
| 879 | 878 | self.hardbreak_if_not_bol(); |
| 880 | 879 | self.maybe_print_comment(field.span.lo()); |
| 881 | self.print_attrs_as_outer(self.attrs(field.hir_id)); | |
| 880 | self.print_attrs(self.attrs(field.hir_id)); | |
| 882 | 881 | self.print_ident(field.ident); |
| 883 | 882 | self.word_nbsp(":"); |
| 884 | 883 | self.print_type(field.ty); |
| ... | ... | @@ -916,7 +915,7 @@ impl<'a> State<'a> { |
| 916 | 915 | self.ann.pre(self, AnnNode::SubItem(ti.hir_id())); |
| 917 | 916 | self.hardbreak_if_not_bol(); |
| 918 | 917 | self.maybe_print_comment(ti.span.lo()); |
| 919 | self.print_attrs_as_outer(self.attrs(ti.hir_id())); | |
| 918 | self.print_attrs(self.attrs(ti.hir_id())); | |
| 920 | 919 | match ti.kind { |
| 921 | 920 | hir::TraitItemKind::Const(ty, default) => { |
| 922 | 921 | self.print_associated_const(ti.ident, ti.generics, ty, default); |
| ... | ... | @@ -944,7 +943,7 @@ impl<'a> State<'a> { |
| 944 | 943 | self.ann.pre(self, AnnNode::SubItem(ii.hir_id())); |
| 945 | 944 | self.hardbreak_if_not_bol(); |
| 946 | 945 | self.maybe_print_comment(ii.span.lo()); |
| 947 | self.print_attrs_as_outer(self.attrs(ii.hir_id())); | |
| 946 | self.print_attrs(self.attrs(ii.hir_id())); | |
| 948 | 947 | |
| 949 | 948 | match ii.kind { |
| 950 | 949 | hir::ImplItemKind::Const(ty, expr) => { |
| ... | ... | @@ -1028,27 +1027,16 @@ impl<'a> State<'a> { |
| 1028 | 1027 | } |
| 1029 | 1028 | |
| 1030 | 1029 | fn print_block(&mut self, blk: &hir::Block<'_>, cb: BoxMarker, ib: BoxMarker) { |
| 1031 | self.print_block_with_attrs(blk, &[], cb, ib) | |
| 1030 | self.print_block_maybe_unclosed(blk, Some(cb), ib) | |
| 1032 | 1031 | } |
| 1033 | 1032 | |
| 1034 | 1033 | fn print_block_unclosed(&mut self, blk: &hir::Block<'_>, ib: BoxMarker) { |
| 1035 | self.print_block_maybe_unclosed(blk, &[], None, ib) | |
| 1036 | } | |
| 1037 | ||
| 1038 | fn print_block_with_attrs( | |
| 1039 | &mut self, | |
| 1040 | blk: &hir::Block<'_>, | |
| 1041 | attrs: &[hir::Attribute], | |
| 1042 | cb: BoxMarker, | |
| 1043 | ib: BoxMarker, | |
| 1044 | ) { | |
| 1045 | self.print_block_maybe_unclosed(blk, attrs, Some(cb), ib) | |
| 1034 | self.print_block_maybe_unclosed(blk, None, ib) | |
| 1046 | 1035 | } |
| 1047 | 1036 | |
| 1048 | 1037 | fn print_block_maybe_unclosed( |
| 1049 | 1038 | &mut self, |
| 1050 | 1039 | blk: &hir::Block<'_>, |
| 1051 | attrs: &[hir::Attribute], | |
| 1052 | 1040 | cb: Option<BoxMarker>, |
| 1053 | 1041 | ib: BoxMarker, |
| 1054 | 1042 | ) { |
| ... | ... | @@ -1060,8 +1048,6 @@ impl<'a> State<'a> { |
| 1060 | 1048 | self.ann.pre(self, AnnNode::Block(blk)); |
| 1061 | 1049 | self.bopen(ib); |
| 1062 | 1050 | |
| 1063 | self.print_attrs_as_inner(attrs); | |
| 1064 | ||
| 1065 | 1051 | for st in blk.stmts { |
| 1066 | 1052 | self.print_stmt(st); |
| 1067 | 1053 | } |
| ... | ... | @@ -1251,7 +1237,7 @@ impl<'a> State<'a> { |
| 1251 | 1237 | |
| 1252 | 1238 | fn print_expr_field(&mut self, field: &hir::ExprField<'_>) { |
| 1253 | 1239 | let cb = self.cbox(INDENT_UNIT); |
| 1254 | self.print_attrs_as_outer(self.attrs(field.hir_id)); | |
| 1240 | self.print_attrs(self.attrs(field.hir_id)); | |
| 1255 | 1241 | if !field.is_shorthand { |
| 1256 | 1242 | self.print_ident(field.ident); |
| 1257 | 1243 | self.word_space(":"); |
| ... | ... | @@ -1451,7 +1437,7 @@ impl<'a> State<'a> { |
| 1451 | 1437 | |
| 1452 | 1438 | fn print_expr(&mut self, expr: &hir::Expr<'_>) { |
| 1453 | 1439 | self.maybe_print_comment(expr.span.lo()); |
| 1454 | self.print_attrs_as_outer(self.attrs(expr.hir_id)); | |
| 1440 | self.print_attrs(self.attrs(expr.hir_id)); | |
| 1455 | 1441 | let ib = self.ibox(INDENT_UNIT); |
| 1456 | 1442 | self.ann.pre(self, AnnNode::Expr(expr)); |
| 1457 | 1443 | match expr.kind { |
| ... | ... | @@ -2076,7 +2062,7 @@ impl<'a> State<'a> { |
| 2076 | 2062 | self.space(); |
| 2077 | 2063 | } |
| 2078 | 2064 | let cb = self.cbox(INDENT_UNIT); |
| 2079 | self.print_attrs_as_outer(self.attrs(field.hir_id)); | |
| 2065 | self.print_attrs(self.attrs(field.hir_id)); | |
| 2080 | 2066 | if !field.is_shorthand { |
| 2081 | 2067 | self.print_ident(field.ident); |
| 2082 | 2068 | self.word_nbsp(":"); |
| ... | ... | @@ -2086,7 +2072,7 @@ impl<'a> State<'a> { |
| 2086 | 2072 | } |
| 2087 | 2073 | |
| 2088 | 2074 | fn print_param(&mut self, arg: &hir::Param<'_>) { |
| 2089 | self.print_attrs_as_outer(self.attrs(arg.hir_id)); | |
| 2075 | self.print_attrs(self.attrs(arg.hir_id)); | |
| 2090 | 2076 | self.print_pat(arg.pat); |
| 2091 | 2077 | } |
| 2092 | 2078 | |
| ... | ... | @@ -2121,7 +2107,7 @@ impl<'a> State<'a> { |
| 2121 | 2107 | let cb = self.cbox(INDENT_UNIT); |
| 2122 | 2108 | self.ann.pre(self, AnnNode::Arm(arm)); |
| 2123 | 2109 | let ib = self.ibox(0); |
| 2124 | self.print_attrs_as_outer(self.attrs(arm.hir_id)); | |
| 2110 | self.print_attrs(self.attrs(arm.hir_id)); | |
| 2125 | 2111 | self.print_pat(arm.pat); |
| 2126 | 2112 | self.space(); |
| 2127 | 2113 | if let Some(ref g) = arm.guard { |
| ... | ... | @@ -2409,7 +2395,7 @@ impl<'a> State<'a> { |
| 2409 | 2395 | } |
| 2410 | 2396 | |
| 2411 | 2397 | fn print_where_predicate(&mut self, predicate: &hir::WherePredicate<'_>) { |
| 2412 | self.print_attrs_as_outer(self.attrs(predicate.hir_id)); | |
| 2398 | self.print_attrs(self.attrs(predicate.hir_id)); | |
| 2413 | 2399 | match *predicate.kind { |
| 2414 | 2400 | hir::WherePredicateKind::BoundPredicate(hir::WhereBoundPredicate { |
| 2415 | 2401 | bound_generic_params, |
compiler/rustc_hir_typeck/src/expr.rs+5-4| ... | ... | @@ -18,7 +18,7 @@ use rustc_errors::{ |
| 18 | 18 | use rustc_hir::def::{CtorKind, DefKind, Res}; |
| 19 | 19 | use rustc_hir::def_id::DefId; |
| 20 | 20 | use rustc_hir::lang_items::LangItem; |
| 21 | use rustc_hir::{Attribute, ExprKind, HirId, QPath}; | |
| 21 | use rustc_hir::{ExprKind, HirId, QPath}; | |
| 22 | 22 | use rustc_hir_analysis::NoVariantNamed; |
| 23 | 23 | use rustc_hir_analysis::hir_ty_lowering::{FeedConstTy, HirTyLowerer as _}; |
| 24 | 24 | use rustc_infer::infer; |
| ... | ... | @@ -55,7 +55,7 @@ use crate::{ |
| 55 | 55 | |
| 56 | 56 | impl<'a, 'tcx> FnCtxt<'a, 'tcx> { |
| 57 | 57 | pub(crate) fn precedence(&self, expr: &hir::Expr<'_>) -> ExprPrecedence { |
| 58 | let for_each_attr = |id: HirId, callback: &mut dyn FnMut(&Attribute)| { | |
| 58 | let has_attr = |id: HirId| -> bool { | |
| 59 | 59 | for attr in self.tcx.hir_attrs(id) { |
| 60 | 60 | // For the purpose of rendering suggestions, disregard attributes |
| 61 | 61 | // that originate from desugaring of any kind. For example, `x?` |
| ... | ... | @@ -71,11 +71,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { |
| 71 | 71 | // let y: u32 = (x?).try_into().unwrap(); |
| 72 | 72 | // + +++++++++++++++++++++ |
| 73 | 73 | if attr.span().desugaring_kind().is_none() { |
| 74 | callback(attr); | |
| 74 | return true; | |
| 75 | 75 | } |
| 76 | 76 | } |
| 77 | false | |
| 77 | 78 | }; |
| 78 | expr.precedence(&for_each_attr) | |
| 79 | expr.precedence(&has_attr) | |
| 79 | 80 | } |
| 80 | 81 | |
| 81 | 82 | /// Check an expr with an expectation type, and also demand that the expr's |
compiler/rustc_lint/src/context.rs+4-3| ... | ... | @@ -855,14 +855,15 @@ impl<'tcx> LateContext<'tcx> { |
| 855 | 855 | /// rendering diagnostic. This is not the same as the precedence that would |
| 856 | 856 | /// be used for pretty-printing HIR by rustc_hir_pretty. |
| 857 | 857 | pub fn precedence(&self, expr: &hir::Expr<'_>) -> ExprPrecedence { |
| 858 | let for_each_attr = |id: hir::HirId, callback: &mut dyn FnMut(&hir::Attribute)| { | |
| 858 | let has_attr = |id: hir::HirId| -> bool { | |
| 859 | 859 | for attr in self.tcx.hir_attrs(id) { |
| 860 | 860 | if attr.span().desugaring_kind().is_none() { |
| 861 | callback(attr); | |
| 861 | return true; | |
| 862 | 862 | } |
| 863 | 863 | } |
| 864 | false | |
| 864 | 865 | }; |
| 865 | expr.precedence(&for_each_attr) | |
| 866 | expr.precedence(&has_attr) | |
| 866 | 867 | } |
| 867 | 868 | |
| 868 | 869 | /// If the given expression is a local binding, find the initializer expression. |
compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs+1-1| ... | ... | @@ -430,7 +430,7 @@ where |
| 430 | 430 | canonical_input, |
| 431 | 431 | step_kind_from_parent, |
| 432 | 432 | &mut canonical_goal_evaluation, |
| 433 | |search_graph, canonical_goal_evaluation| { | |
| 433 | |search_graph, cx, canonical_input, canonical_goal_evaluation| { | |
| 434 | 434 | EvalCtxt::enter_canonical( |
| 435 | 435 | cx, |
| 436 | 436 | search_graph, |
compiler/rustc_passes/src/check_attr.rs+41-30| ... | ... | @@ -116,6 +116,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> { |
| 116 | 116 | let mut seen = FxHashMap::default(); |
| 117 | 117 | let attrs = self.tcx.hir_attrs(hir_id); |
| 118 | 118 | for attr in attrs { |
| 119 | let mut style = None; | |
| 119 | 120 | match attr { |
| 120 | 121 | Attribute::Parsed(AttributeKind::Confusables { first_span, .. }) => { |
| 121 | 122 | self.check_confusables(*first_span, target); |
| ... | ... | @@ -149,6 +150,10 @@ impl<'tcx> CheckAttrVisitor<'tcx> { |
| 149 | 150 | } |
| 150 | 151 | Attribute::Parsed(AttributeKind::Repr(_)) => { /* handled below this loop and elsewhere */ |
| 151 | 152 | } |
| 153 | ||
| 154 | &Attribute::Parsed(AttributeKind::PubTransparent(attr_span)) => { | |
| 155 | self.check_rustc_pub_transparent(attr_span, span, attrs) | |
| 156 | } | |
| 152 | 157 | Attribute::Parsed(AttributeKind::Cold(attr_span)) => { |
| 153 | 158 | self.check_cold(hir_id, *attr_span, span, target) |
| 154 | 159 | } |
| ... | ... | @@ -163,10 +168,11 @@ impl<'tcx> CheckAttrVisitor<'tcx> { |
| 163 | 168 | Attribute::Parsed(AttributeKind::AsPtr(attr_span)) => { |
| 164 | 169 | self.check_applied_to_fn_or_method(hir_id, *attr_span, span, target) |
| 165 | 170 | } |
| 166 | &Attribute::Parsed(AttributeKind::MayDangle(attr_span)) => { | |
| 167 | self.check_may_dangle(hir_id, attr_span) | |
| 171 | Attribute::Parsed(AttributeKind::MayDangle(attr_span)) => { | |
| 172 | self.check_may_dangle(hir_id, *attr_span) | |
| 168 | 173 | } |
| 169 | Attribute::Unparsed(_) => { | |
| 174 | Attribute::Unparsed(attr_item) => { | |
| 175 | style = Some(attr_item.style); | |
| 170 | 176 | match attr.path().as_slice() { |
| 171 | 177 | [sym::diagnostic, sym::do_not_recommend, ..] => { |
| 172 | 178 | self.check_do_not_recommend(attr.span(), hir_id, target, attr, item) |
| ... | ... | @@ -189,6 +195,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> { |
| 189 | 195 | } |
| 190 | 196 | [sym::doc, ..] => self.check_doc_attrs( |
| 191 | 197 | attr, |
| 198 | attr_item.style, | |
| 192 | 199 | hir_id, |
| 193 | 200 | target, |
| 194 | 201 | &mut specified_inline, |
| ... | ... | @@ -288,7 +295,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> { |
| 288 | 295 | self.check_type_const(hir_id,attr, target); |
| 289 | 296 | } |
| 290 | 297 | [sym::linkage, ..] => self.check_linkage(attr, span, target), |
| 291 | [sym::rustc_pub_transparent, ..] => self.check_rustc_pub_transparent(attr.span(), span, attrs), | |
| 292 | 298 | [ |
| 293 | 299 | // ok |
| 294 | 300 | sym::allow |
| ... | ... | @@ -350,14 +356,14 @@ impl<'tcx> CheckAttrVisitor<'tcx> { |
| 350 | 356 | if let Some(BuiltinAttribute { type_: AttributeType::CrateLevel, .. }) = |
| 351 | 357 | attr.ident().and_then(|ident| BUILTIN_ATTRIBUTE_MAP.get(&ident.name)) |
| 352 | 358 | { |
| 353 | match attr.style() { | |
| 354 | ast::AttrStyle::Outer => self.tcx.emit_node_span_lint( | |
| 359 | match style { | |
| 360 | Some(ast::AttrStyle::Outer) => self.tcx.emit_node_span_lint( | |
| 355 | 361 | UNUSED_ATTRIBUTES, |
| 356 | 362 | hir_id, |
| 357 | 363 | attr.span(), |
| 358 | 364 | errors::OuterCrateLevelAttr, |
| 359 | 365 | ), |
| 360 | ast::AttrStyle::Inner => self.tcx.emit_node_span_lint( | |
| 366 | Some(ast::AttrStyle::Inner) | None => self.tcx.emit_node_span_lint( | |
| 361 | 367 | UNUSED_ATTRIBUTES, |
| 362 | 368 | hir_id, |
| 363 | 369 | attr.span(), |
| ... | ... | @@ -371,7 +377,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> { |
| 371 | 377 | check_duplicates(self.tcx, attr, hir_id, *duplicates, &mut seen); |
| 372 | 378 | } |
| 373 | 379 | |
| 374 | self.check_unused_attribute(hir_id, attr) | |
| 380 | self.check_unused_attribute(hir_id, attr, style) | |
| 375 | 381 | } |
| 376 | 382 | |
| 377 | 383 | self.check_repr(attrs, span, target, item, hir_id); |
| ... | ... | @@ -1194,7 +1200,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> { |
| 1194 | 1200 | /// the first `inline`/`no_inline` attribute. |
| 1195 | 1201 | fn check_doc_inline( |
| 1196 | 1202 | &self, |
| 1197 | attr: &Attribute, | |
| 1203 | style: AttrStyle, | |
| 1198 | 1204 | meta: &MetaItemInner, |
| 1199 | 1205 | hir_id: HirId, |
| 1200 | 1206 | target: Target, |
| ... | ... | @@ -1224,8 +1230,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> { |
| 1224 | 1230 | meta.span(), |
| 1225 | 1231 | errors::DocInlineOnlyUse { |
| 1226 | 1232 | attr_span: meta.span(), |
| 1227 | item_span: (attr.style() == AttrStyle::Outer) | |
| 1228 | .then(|| self.tcx.hir_span(hir_id)), | |
| 1233 | item_span: (style == AttrStyle::Outer).then(|| self.tcx.hir_span(hir_id)), | |
| 1229 | 1234 | }, |
| 1230 | 1235 | ); |
| 1231 | 1236 | } |
| ... | ... | @@ -1234,7 +1239,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> { |
| 1234 | 1239 | |
| 1235 | 1240 | fn check_doc_masked( |
| 1236 | 1241 | &self, |
| 1237 | attr: &Attribute, | |
| 1242 | style: AttrStyle, | |
| 1238 | 1243 | meta: &MetaItemInner, |
| 1239 | 1244 | hir_id: HirId, |
| 1240 | 1245 | target: Target, |
| ... | ... | @@ -1246,8 +1251,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> { |
| 1246 | 1251 | meta.span(), |
| 1247 | 1252 | errors::DocMaskedOnlyExternCrate { |
| 1248 | 1253 | attr_span: meta.span(), |
| 1249 | item_span: (attr.style() == AttrStyle::Outer) | |
| 1250 | .then(|| self.tcx.hir_span(hir_id)), | |
| 1254 | item_span: (style == AttrStyle::Outer).then(|| self.tcx.hir_span(hir_id)), | |
| 1251 | 1255 | }, |
| 1252 | 1256 | ); |
| 1253 | 1257 | return; |
| ... | ... | @@ -1260,8 +1264,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> { |
| 1260 | 1264 | meta.span(), |
| 1261 | 1265 | errors::DocMaskedNotExternCrateSelf { |
| 1262 | 1266 | attr_span: meta.span(), |
| 1263 | item_span: (attr.style() == AttrStyle::Outer) | |
| 1264 | .then(|| self.tcx.hir_span(hir_id)), | |
| 1267 | item_span: (style == AttrStyle::Outer).then(|| self.tcx.hir_span(hir_id)), | |
| 1265 | 1268 | }, |
| 1266 | 1269 | ); |
| 1267 | 1270 | } |
| ... | ... | @@ -1285,13 +1288,14 @@ impl<'tcx> CheckAttrVisitor<'tcx> { |
| 1285 | 1288 | fn check_attr_crate_level( |
| 1286 | 1289 | &self, |
| 1287 | 1290 | attr: &Attribute, |
| 1291 | style: AttrStyle, | |
| 1288 | 1292 | meta: &MetaItemInner, |
| 1289 | 1293 | hir_id: HirId, |
| 1290 | 1294 | ) -> bool { |
| 1291 | 1295 | if hir_id != CRATE_HIR_ID { |
| 1292 | 1296 | // insert a bang between `#` and `[...` |
| 1293 | 1297 | let bang_span = attr.span().lo() + BytePos(1); |
| 1294 | let sugg = (attr.style() == AttrStyle::Outer | |
| 1298 | let sugg = (style == AttrStyle::Outer | |
| 1295 | 1299 | && self.tcx.hir_get_parent_item(hir_id) == CRATE_OWNER_ID) |
| 1296 | 1300 | .then_some(errors::AttrCrateLevelOnlySugg { |
| 1297 | 1301 | attr: attr.span().with_lo(bang_span).with_hi(bang_span), |
| ... | ... | @@ -1308,7 +1312,13 @@ impl<'tcx> CheckAttrVisitor<'tcx> { |
| 1308 | 1312 | } |
| 1309 | 1313 | |
| 1310 | 1314 | /// Checks that `doc(test(...))` attribute contains only valid attributes and are at the right place. |
| 1311 | fn check_test_attr(&self, attr: &Attribute, meta: &MetaItemInner, hir_id: HirId) { | |
| 1315 | fn check_test_attr( | |
| 1316 | &self, | |
| 1317 | attr: &Attribute, | |
| 1318 | style: AttrStyle, | |
| 1319 | meta: &MetaItemInner, | |
| 1320 | hir_id: HirId, | |
| 1321 | ) { | |
| 1312 | 1322 | if let Some(metas) = meta.meta_item_list() { |
| 1313 | 1323 | for i_meta in metas { |
| 1314 | 1324 | match (i_meta.name(), i_meta.meta_item()) { |
| ... | ... | @@ -1316,7 +1326,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> { |
| 1316 | 1326 | // Allowed everywhere like `#[doc]` |
| 1317 | 1327 | } |
| 1318 | 1328 | (Some(sym::no_crate_inject), _) => { |
| 1319 | self.check_attr_crate_level(attr, meta, hir_id); | |
| 1329 | self.check_attr_crate_level(attr, style, meta, hir_id); | |
| 1320 | 1330 | } |
| 1321 | 1331 | (_, Some(m)) => { |
| 1322 | 1332 | self.tcx.emit_node_span_lint( |
| ... | ... | @@ -1370,6 +1380,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> { |
| 1370 | 1380 | fn check_doc_attrs( |
| 1371 | 1381 | &self, |
| 1372 | 1382 | attr: &Attribute, |
| 1383 | style: AttrStyle, | |
| 1373 | 1384 | hir_id: HirId, |
| 1374 | 1385 | target: Target, |
| 1375 | 1386 | specified_inline: &mut Option<(bool, Span)>, |
| ... | ... | @@ -1404,7 +1415,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> { |
| 1404 | 1415 | } |
| 1405 | 1416 | |
| 1406 | 1417 | Some(sym::test) => { |
| 1407 | self.check_test_attr(attr, meta, hir_id); | |
| 1418 | self.check_test_attr(attr, style, meta, hir_id); | |
| 1408 | 1419 | } |
| 1409 | 1420 | |
| 1410 | 1421 | Some( |
| ... | ... | @@ -1415,25 +1426,25 @@ impl<'tcx> CheckAttrVisitor<'tcx> { |
| 1415 | 1426 | | sym::html_root_url |
| 1416 | 1427 | | sym::html_no_source, |
| 1417 | 1428 | ) => { |
| 1418 | self.check_attr_crate_level(attr, meta, hir_id); | |
| 1429 | self.check_attr_crate_level(attr, style, meta, hir_id); | |
| 1419 | 1430 | } |
| 1420 | 1431 | |
| 1421 | 1432 | Some(sym::cfg_hide) => { |
| 1422 | if self.check_attr_crate_level(attr, meta, hir_id) { | |
| 1433 | if self.check_attr_crate_level(attr, style, meta, hir_id) { | |
| 1423 | 1434 | self.check_doc_cfg_hide(meta, hir_id); |
| 1424 | 1435 | } |
| 1425 | 1436 | } |
| 1426 | 1437 | |
| 1427 | 1438 | Some(sym::inline | sym::no_inline) => { |
| 1428 | self.check_doc_inline(attr, meta, hir_id, target, specified_inline) | |
| 1439 | self.check_doc_inline(style, meta, hir_id, target, specified_inline) | |
| 1429 | 1440 | } |
| 1430 | 1441 | |
| 1431 | Some(sym::masked) => self.check_doc_masked(attr, meta, hir_id, target), | |
| 1442 | Some(sym::masked) => self.check_doc_masked(style, meta, hir_id, target), | |
| 1432 | 1443 | |
| 1433 | 1444 | Some(sym::cfg | sym::hidden | sym::notable_trait) => {} |
| 1434 | 1445 | |
| 1435 | 1446 | Some(sym::rust_logo) => { |
| 1436 | if self.check_attr_crate_level(attr, meta, hir_id) | |
| 1447 | if self.check_attr_crate_level(attr, style, meta, hir_id) | |
| 1437 | 1448 | && !self.tcx.features().rustdoc_internals() |
| 1438 | 1449 | { |
| 1439 | 1450 | feature_err( |
| ... | ... | @@ -1472,7 +1483,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> { |
| 1472 | 1483 | errors::DocTestUnknownInclude { |
| 1473 | 1484 | path, |
| 1474 | 1485 | value: value.to_string(), |
| 1475 | inner: match attr.style() { | |
| 1486 | inner: match style { | |
| 1476 | 1487 | AttrStyle::Inner => "!", |
| 1477 | 1488 | AttrStyle::Outer => "", |
| 1478 | 1489 | }, |
| ... | ... | @@ -2426,7 +2437,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> { |
| 2426 | 2437 | } |
| 2427 | 2438 | } |
| 2428 | 2439 | |
| 2429 | fn check_unused_attribute(&self, hir_id: HirId, attr: &Attribute) { | |
| 2440 | fn check_unused_attribute(&self, hir_id: HirId, attr: &Attribute, style: Option<AttrStyle>) { | |
| 2430 | 2441 | // FIXME(jdonszelmann): deduplicate these checks after more attrs are parsed. This is very |
| 2431 | 2442 | // ugly now but can 100% be removed later. |
| 2432 | 2443 | if let Attribute::Parsed(p) = attr { |
| ... | ... | @@ -2479,14 +2490,14 @@ impl<'tcx> CheckAttrVisitor<'tcx> { |
| 2479 | 2490 | }) |
| 2480 | 2491 | { |
| 2481 | 2492 | if hir_id != CRATE_HIR_ID { |
| 2482 | match attr.style() { | |
| 2483 | ast::AttrStyle::Outer => self.tcx.emit_node_span_lint( | |
| 2493 | match style { | |
| 2494 | Some(ast::AttrStyle::Outer) => self.tcx.emit_node_span_lint( | |
| 2484 | 2495 | UNUSED_ATTRIBUTES, |
| 2485 | 2496 | hir_id, |
| 2486 | 2497 | attr.span(), |
| 2487 | 2498 | errors::OuterCrateLevelAttr, |
| 2488 | 2499 | ), |
| 2489 | ast::AttrStyle::Inner => self.tcx.emit_node_span_lint( | |
| 2500 | Some(ast::AttrStyle::Inner) | None => self.tcx.emit_node_span_lint( | |
| 2490 | 2501 | UNUSED_ATTRIBUTES, |
| 2491 | 2502 | hir_id, |
| 2492 | 2503 | attr.span(), |
compiler/rustc_resolve/src/rustdoc.rs+6-1| ... | ... | @@ -356,7 +356,12 @@ pub fn strip_generics_from_path(path_str: &str) -> Result<Box<str>, MalformedGen |
| 356 | 356 | /// If there are no doc-comments, return true. |
| 357 | 357 | /// FIXME(#78591): Support both inner and outer attributes on the same item. |
| 358 | 358 | pub fn inner_docs(attrs: &[impl AttributeExt]) -> bool { |
| 359 | attrs.iter().find(|a| a.doc_str().is_some()).is_none_or(|a| a.style() == ast::AttrStyle::Inner) | |
| 359 | for attr in attrs { | |
| 360 | if let Some(attr_style) = attr.doc_resolution_scope() { | |
| 361 | return attr_style == ast::AttrStyle::Inner; | |
| 362 | } | |
| 363 | } | |
| 364 | true | |
| 360 | 365 | } |
| 361 | 366 | |
| 362 | 367 | /// Has `#[rustc_doc_primitive]` or `#[doc(keyword)]`. |
compiler/rustc_type_ir/src/search_graph/global_cache.rs+8-9| ... | ... | @@ -2,6 +2,7 @@ use derive_where::derive_where; |
| 2 | 2 | |
| 3 | 3 | use super::{AvailableDepth, Cx, NestedGoals}; |
| 4 | 4 | use crate::data_structures::HashMap; |
| 5 | use crate::search_graph::EvaluationResult; | |
| 5 | 6 | |
| 6 | 7 | struct Success<X: Cx> { |
| 7 | 8 | required_depth: usize, |
| ... | ... | @@ -43,28 +44,26 @@ impl<X: Cx> GlobalCache<X> { |
| 43 | 44 | &mut self, |
| 44 | 45 | cx: X, |
| 45 | 46 | input: X::Input, |
| 46 | ||
| 47 | origin_result: X::Result, | |
| 47 | evaluation_result: EvaluationResult<X>, | |
| 48 | 48 | dep_node: X::DepNodeIndex, |
| 49 | ||
| 50 | required_depth: usize, | |
| 51 | encountered_overflow: bool, | |
| 52 | nested_goals: NestedGoals<X>, | |
| 53 | 49 | ) { |
| 54 | let result = cx.mk_tracked(origin_result, dep_node); | |
| 50 | let EvaluationResult { encountered_overflow, required_depth, heads, nested_goals, result } = | |
| 51 | evaluation_result; | |
| 52 | debug_assert!(heads.is_empty()); | |
| 53 | let result = cx.mk_tracked(result, dep_node); | |
| 55 | 54 | let entry = self.map.entry(input).or_default(); |
| 56 | 55 | if encountered_overflow { |
| 57 | 56 | let with_overflow = WithOverflow { nested_goals, result }; |
| 58 | 57 | let prev = entry.with_overflow.insert(required_depth, with_overflow); |
| 59 | 58 | if let Some(prev) = &prev { |
| 60 | 59 | assert!(cx.evaluation_is_concurrent()); |
| 61 | assert_eq!(cx.get_tracked(&prev.result), origin_result); | |
| 60 | assert_eq!(cx.get_tracked(&prev.result), evaluation_result.result); | |
| 62 | 61 | } |
| 63 | 62 | } else { |
| 64 | 63 | let prev = entry.success.replace(Success { required_depth, nested_goals, result }); |
| 65 | 64 | if let Some(prev) = &prev { |
| 66 | 65 | assert!(cx.evaluation_is_concurrent()); |
| 67 | assert_eq!(cx.get_tracked(&prev.result), origin_result); | |
| 66 | assert_eq!(cx.get_tracked(&prev.result), evaluation_result.result); | |
| 68 | 67 | } |
| 69 | 68 | } |
| 70 | 69 | } |
compiler/rustc_type_ir/src/search_graph/mod.rs+109-59| ... | ... | @@ -1,16 +1,16 @@ |
| 1 | /// The search graph is responsible for caching and cycle detection in the trait | |
| 2 | /// solver. Making sure that caching doesn't result in soundness bugs or unstable | |
| 3 | /// query results is very challenging and makes this one of the most-involved | |
| 4 | /// self-contained components of the compiler. | |
| 5 | /// | |
| 6 | /// We added fuzzing support to test its correctness. The fuzzers used to verify | |
| 7 | /// the current implementation can be found in https://github.com/lcnr/search_graph_fuzz. | |
| 8 | /// | |
| 9 | /// This is just a quick overview of the general design, please check out the relevant | |
| 10 | /// [rustc-dev-guide chapter](https://rustc-dev-guide.rust-lang.org/solve/caching.html) for | |
| 11 | /// more details. Caching is split between a global cache and the per-cycle `provisional_cache`. | |
| 12 | /// The global cache has to be completely unobservable, while the per-cycle cache may impact | |
| 13 | /// behavior as long as the resulting behavior is still correct. | |
| 1 | //! The search graph is responsible for caching and cycle detection in the trait | |
| 2 | //! solver. Making sure that caching doesn't result in soundness bugs or unstable | |
| 3 | //! query results is very challenging and makes this one of the most-involved | |
| 4 | //! self-contained components of the compiler. | |
| 5 | //! | |
| 6 | //! We added fuzzing support to test its correctness. The fuzzers used to verify | |
| 7 | //! the current implementation can be found in <https://github.com/lcnr/search_graph_fuzz>. | |
| 8 | //! | |
| 9 | //! This is just a quick overview of the general design, please check out the relevant | |
| 10 | //! [rustc-dev-guide chapter](https://rustc-dev-guide.rust-lang.org/solve/caching.html) for | |
| 11 | //! more details. Caching is split between a global cache and the per-cycle `provisional_cache`. | |
| 12 | //! The global cache has to be completely unobservable, while the per-cycle cache may impact | |
| 13 | //! behavior as long as the resulting behavior is still correct. | |
| 14 | 14 | use std::cmp::Ordering; |
| 15 | 15 | use std::collections::BTreeMap; |
| 16 | 16 | use std::collections::hash_map::Entry; |
| ... | ... | @@ -381,18 +381,16 @@ impl PathsToNested { |
| 381 | 381 | /// The nested goals of each stack entry and the path from the |
| 382 | 382 | /// stack entry to that nested goal. |
| 383 | 383 | /// |
| 384 | /// They are used when checking whether reevaluating a global cache | |
| 385 | /// would encounter a cycle or use a provisional cache entry given the | |
| 386 | /// currentl search graph state. We need to disable the global cache | |
| 387 | /// in this case as it could otherwise result in behaviorial differences. | |
| 388 | /// Cycles can impact behavior. The cycle ABA may have different final | |
| 389 | /// results from a the cycle BAB depending on the cycle root. | |
| 390 | /// | |
| 384 | 391 | /// We only start tracking nested goals once we've either encountered |
| 385 | 392 | /// overflow or a solver cycle. This is a performance optimization to |
| 386 | 393 | /// avoid tracking nested goals on the happy path. |
| 387 | /// | |
| 388 | /// We use nested goals for two reasons: | |
| 389 | /// - when rebasing provisional cache entries | |
| 390 | /// - when checking whether we have to ignore a global cache entry as reevaluating | |
| 391 | /// it would encounter a cycle or use a provisional cache entry. | |
| 392 | /// | |
| 393 | /// We need to disable the global cache if using it would hide a cycle, as | |
| 394 | /// cycles can impact behavior. The cycle ABA may have different final | |
| 395 | /// results from a the cycle BAB depending on the cycle root. | |
| 396 | 394 | #[derive_where(Debug, Default, Clone; X: Cx)] |
| 397 | 395 | struct NestedGoals<X: Cx> { |
| 398 | 396 | nested_goals: HashMap<X::Input, PathsToNested>, |
| ... | ... | @@ -450,6 +448,43 @@ struct ProvisionalCacheEntry<X: Cx> { |
| 450 | 448 | result: X::Result, |
| 451 | 449 | } |
| 452 | 450 | |
| 451 | /// The final result of evaluating a goal. | |
| 452 | /// | |
| 453 | /// We reset `encountered_overflow` when reevaluating a goal, | |
| 454 | /// but need to track whether we've hit the recursion limit at | |
| 455 | /// all for correctness. | |
| 456 | /// | |
| 457 | /// We've previously simply returned the final `StackEntry` but this | |
| 458 | /// made it easy to accidentally drop information from the previous | |
| 459 | /// evaluation. | |
| 460 | #[derive_where(Debug; X: Cx)] | |
| 461 | struct EvaluationResult<X: Cx> { | |
| 462 | encountered_overflow: bool, | |
| 463 | required_depth: usize, | |
| 464 | heads: CycleHeads, | |
| 465 | nested_goals: NestedGoals<X>, | |
| 466 | result: X::Result, | |
| 467 | } | |
| 468 | ||
| 469 | impl<X: Cx> EvaluationResult<X> { | |
| 470 | fn finalize( | |
| 471 | final_entry: StackEntry<X>, | |
| 472 | encountered_overflow: bool, | |
| 473 | result: X::Result, | |
| 474 | ) -> EvaluationResult<X> { | |
| 475 | EvaluationResult { | |
| 476 | encountered_overflow, | |
| 477 | // Unlike `encountered_overflow`, we share `heads`, `required_depth`, | |
| 478 | // and `nested_goals` between evaluations. | |
| 479 | required_depth: final_entry.required_depth, | |
| 480 | heads: final_entry.heads, | |
| 481 | nested_goals: final_entry.nested_goals, | |
| 482 | // We only care about the final result. | |
| 483 | result, | |
| 484 | } | |
| 485 | } | |
| 486 | } | |
| 487 | ||
| 453 | 488 | pub struct SearchGraph<D: Delegate<Cx = X>, X: Cx = <D as Delegate>::Cx> { |
| 454 | 489 | root_depth: AvailableDepth, |
| 455 | 490 | /// The stack of goals currently being computed. |
| ... | ... | @@ -562,7 +597,7 @@ impl<D: Delegate<Cx = X>, X: Cx> SearchGraph<D> { |
| 562 | 597 | input: X::Input, |
| 563 | 598 | step_kind_from_parent: PathKind, |
| 564 | 599 | inspect: &mut D::ProofTreeBuilder, |
| 565 | mut evaluate_goal: impl FnMut(&mut Self, &mut D::ProofTreeBuilder) -> X::Result, | |
| 600 | evaluate_goal: impl Fn(&mut Self, X, X::Input, &mut D::ProofTreeBuilder) -> X::Result + Copy, | |
| 566 | 601 | ) -> X::Result { |
| 567 | 602 | let Some(available_depth) = |
| 568 | 603 | AvailableDepth::allowed_depth_for_nested::<D>(self.root_depth, &self.stack) |
| ... | ... | @@ -616,12 +651,12 @@ impl<D: Delegate<Cx = X>, X: Cx> SearchGraph<D> { |
| 616 | 651 | input, |
| 617 | 652 | step_kind_from_parent, |
| 618 | 653 | available_depth, |
| 654 | provisional_result: None, | |
| 619 | 655 | required_depth: 0, |
| 620 | 656 | heads: Default::default(), |
| 621 | 657 | encountered_overflow: false, |
| 622 | 658 | has_been_used: None, |
| 623 | 659 | nested_goals: Default::default(), |
| 624 | provisional_result: None, | |
| 625 | 660 | }); |
| 626 | 661 | |
| 627 | 662 | // This is for global caching, so we properly track query dependencies. |
| ... | ... | @@ -630,35 +665,41 @@ impl<D: Delegate<Cx = X>, X: Cx> SearchGraph<D> { |
| 630 | 665 | // not tracked by the cache key and from outside of this anon task, it |
| 631 | 666 | // must not be added to the global cache. Notably, this is the case for |
| 632 | 667 | // trait solver cycles participants. |
| 633 | let ((final_entry, result), dep_node) = cx.with_cached_task(|| { | |
| 634 | self.evaluate_goal_in_task(cx, input, inspect, &mut evaluate_goal) | |
| 635 | }); | |
| 668 | let (evaluation_result, dep_node) = | |
| 669 | cx.with_cached_task(|| self.evaluate_goal_in_task(cx, input, inspect, evaluate_goal)); | |
| 636 | 670 | |
| 637 | 671 | // We've finished computing the goal and have popped it from the stack, |
| 638 | 672 | // lazily update its parent goal. |
| 639 | 673 | Self::update_parent_goal( |
| 640 | 674 | &mut self.stack, |
| 641 | final_entry.step_kind_from_parent, | |
| 642 | final_entry.required_depth, | |
| 643 | &final_entry.heads, | |
| 644 | final_entry.encountered_overflow, | |
| 645 | UpdateParentGoalCtxt::Ordinary(&final_entry.nested_goals), | |
| 675 | step_kind_from_parent, | |
| 676 | evaluation_result.required_depth, | |
| 677 | &evaluation_result.heads, | |
| 678 | evaluation_result.encountered_overflow, | |
| 679 | UpdateParentGoalCtxt::Ordinary(&evaluation_result.nested_goals), | |
| 646 | 680 | ); |
| 681 | let result = evaluation_result.result; | |
| 647 | 682 | |
| 648 | 683 | // We're now done with this goal. We only add the root of cycles to the global cache. |
| 649 | 684 | // In case this goal is involved in a larger cycle add it to the provisional cache. |
| 650 | if final_entry.heads.is_empty() { | |
| 685 | if evaluation_result.heads.is_empty() { | |
| 651 | 686 | if let Some((_scope, expected)) = validate_cache { |
| 652 | 687 | // Do not try to move a goal into the cache again if we're testing |
| 653 | 688 | // the global cache. |
| 654 | assert_eq!(result, expected, "input={input:?}"); | |
| 689 | assert_eq!(evaluation_result.result, expected, "input={input:?}"); | |
| 655 | 690 | } else if D::inspect_is_noop(inspect) { |
| 656 | self.insert_global_cache(cx, final_entry, result, dep_node) | |
| 691 | self.insert_global_cache(cx, input, evaluation_result, dep_node) | |
| 657 | 692 | } |
| 658 | 693 | } else if D::ENABLE_PROVISIONAL_CACHE { |
| 659 | 694 | debug_assert!(validate_cache.is_none(), "unexpected non-root: {input:?}"); |
| 660 | 695 | let entry = self.provisional_cache.entry(input).or_default(); |
| 661 | let StackEntry { heads, encountered_overflow, .. } = final_entry; | |
| 696 | let EvaluationResult { | |
| 697 | encountered_overflow, | |
| 698 | required_depth: _, | |
| 699 | heads, | |
| 700 | nested_goals: _, | |
| 701 | result, | |
| 702 | } = evaluation_result; | |
| 662 | 703 | let path_from_head = Self::cycle_path_kind( |
| 663 | 704 | &self.stack, |
| 664 | 705 | step_kind_from_parent, |
| ... | ... | @@ -1023,19 +1064,25 @@ impl<D: Delegate<Cx = X>, X: Cx> SearchGraph<D> { |
| 1023 | 1064 | cx: X, |
| 1024 | 1065 | input: X::Input, |
| 1025 | 1066 | inspect: &mut D::ProofTreeBuilder, |
| 1026 | mut evaluate_goal: impl FnMut(&mut Self, &mut D::ProofTreeBuilder) -> X::Result, | |
| 1027 | ) -> (StackEntry<X>, X::Result) { | |
| 1067 | evaluate_goal: impl Fn(&mut Self, X, X::Input, &mut D::ProofTreeBuilder) -> X::Result + Copy, | |
| 1068 | ) -> EvaluationResult<X> { | |
| 1069 | // We reset `encountered_overflow` each time we rerun this goal | |
| 1070 | // but need to make sure we currently propagate it to the global | |
| 1071 | // cache even if only some of the evaluations actually reach the | |
| 1072 | // recursion limit. | |
| 1073 | let mut encountered_overflow = false; | |
| 1028 | 1074 | let mut i = 0; |
| 1029 | 1075 | loop { |
| 1030 | let result = evaluate_goal(self, inspect); | |
| 1076 | let result = evaluate_goal(self, cx, input, inspect); | |
| 1031 | 1077 | let stack_entry = self.stack.pop(); |
| 1078 | encountered_overflow |= stack_entry.encountered_overflow; | |
| 1032 | 1079 | debug_assert_eq!(stack_entry.input, input); |
| 1033 | 1080 | |
| 1034 | 1081 | // If the current goal is not the root of a cycle, we are done. |
| 1035 | 1082 | // |
| 1036 | 1083 | // There are no provisional cache entries which depend on this goal. |
| 1037 | 1084 | let Some(usage_kind) = stack_entry.has_been_used else { |
| 1038 | return (stack_entry, result); | |
| 1085 | return EvaluationResult::finalize(stack_entry, encountered_overflow, result); | |
| 1039 | 1086 | }; |
| 1040 | 1087 | |
| 1041 | 1088 | // If it is a cycle head, we have to keep trying to prove it until |
| ... | ... | @@ -1051,7 +1098,7 @@ impl<D: Delegate<Cx = X>, X: Cx> SearchGraph<D> { |
| 1051 | 1098 | // final result is equal to the initial response for that case. |
| 1052 | 1099 | if self.reached_fixpoint(cx, &stack_entry, usage_kind, result) { |
| 1053 | 1100 | self.rebase_provisional_cache_entries(&stack_entry, |_, result| result); |
| 1054 | return (stack_entry, result); | |
| 1101 | return EvaluationResult::finalize(stack_entry, encountered_overflow, result); | |
| 1055 | 1102 | } |
| 1056 | 1103 | |
| 1057 | 1104 | // If computing this goal results in ambiguity with no constraints, |
| ... | ... | @@ -1070,7 +1117,7 @@ impl<D: Delegate<Cx = X>, X: Cx> SearchGraph<D> { |
| 1070 | 1117 | self.rebase_provisional_cache_entries(&stack_entry, |input, _| { |
| 1071 | 1118 | D::propagate_ambiguity(cx, input, result) |
| 1072 | 1119 | }); |
| 1073 | return (stack_entry, result); | |
| 1120 | return EvaluationResult::finalize(stack_entry, encountered_overflow, result); | |
| 1074 | 1121 | }; |
| 1075 | 1122 | |
| 1076 | 1123 | // If we've reached the fixpoint step limit, we bail with overflow and taint all |
| ... | ... | @@ -1082,7 +1129,7 @@ impl<D: Delegate<Cx = X>, X: Cx> SearchGraph<D> { |
| 1082 | 1129 | self.rebase_provisional_cache_entries(&stack_entry, |input, _| { |
| 1083 | 1130 | D::on_fixpoint_overflow(cx, input) |
| 1084 | 1131 | }); |
| 1085 | return (stack_entry, result); | |
| 1132 | return EvaluationResult::finalize(stack_entry, encountered_overflow, result); | |
| 1086 | 1133 | } |
| 1087 | 1134 | |
| 1088 | 1135 | // Clear all provisional cache entries which depend on a previous provisional |
| ... | ... | @@ -1091,9 +1138,22 @@ impl<D: Delegate<Cx = X>, X: Cx> SearchGraph<D> { |
| 1091 | 1138 | |
| 1092 | 1139 | debug!(?result, "fixpoint changed provisional results"); |
| 1093 | 1140 | self.stack.push(StackEntry { |
| 1094 | has_been_used: None, | |
| 1141 | input, | |
| 1142 | step_kind_from_parent: stack_entry.step_kind_from_parent, | |
| 1143 | available_depth: stack_entry.available_depth, | |
| 1095 | 1144 | provisional_result: Some(result), |
| 1096 | ..stack_entry | |
| 1145 | // We can keep these goals from previous iterations as they are only | |
| 1146 | // ever read after finalizing this evaluation. | |
| 1147 | required_depth: stack_entry.required_depth, | |
| 1148 | heads: stack_entry.heads, | |
| 1149 | nested_goals: stack_entry.nested_goals, | |
| 1150 | // We reset these two fields when rerunning this goal. We could | |
| 1151 | // keep `encountered_overflow` as it's only used as a performance | |
| 1152 | // optimization. However, given that the proof tree will likely look | |
| 1153 | // similar to the previous iterations when reevaluating, it's better | |
| 1154 | // for caching if the reevaluation also starts out with `false`. | |
| 1155 | encountered_overflow: false, | |
| 1156 | has_been_used: None, | |
| 1097 | 1157 | }); |
| 1098 | 1158 | } |
| 1099 | 1159 | } |
| ... | ... | @@ -1109,21 +1169,11 @@ impl<D: Delegate<Cx = X>, X: Cx> SearchGraph<D> { |
| 1109 | 1169 | fn insert_global_cache( |
| 1110 | 1170 | &mut self, |
| 1111 | 1171 | cx: X, |
| 1112 | final_entry: StackEntry<X>, | |
| 1113 | result: X::Result, | |
| 1172 | input: X::Input, | |
| 1173 | evaluation_result: EvaluationResult<X>, | |
| 1114 | 1174 | dep_node: X::DepNodeIndex, |
| 1115 | 1175 | ) { |
| 1116 | debug!(?final_entry, ?result, "insert global cache"); | |
| 1117 | cx.with_global_cache(|cache| { | |
| 1118 | cache.insert( | |
| 1119 | cx, | |
| 1120 | final_entry.input, | |
| 1121 | result, | |
| 1122 | dep_node, | |
| 1123 | final_entry.required_depth, | |
| 1124 | final_entry.encountered_overflow, | |
| 1125 | final_entry.nested_goals, | |
| 1126 | ) | |
| 1127 | }) | |
| 1176 | debug!(?evaluation_result, "insert global cache"); | |
| 1177 | cx.with_global_cache(|cache| cache.insert(cx, input, evaluation_result, dep_node)) | |
| 1128 | 1178 | } |
| 1129 | 1179 | } |
compiler/rustc_type_ir/src/search_graph/stack.rs+4-4| ... | ... | @@ -26,6 +26,10 @@ pub(super) struct StackEntry<X: Cx> { |
| 26 | 26 | /// The available depth of a given goal, immutable. |
| 27 | 27 | pub available_depth: AvailableDepth, |
| 28 | 28 | |
| 29 | /// Starts out as `None` and gets set when rerunning this | |
| 30 | /// goal in case we encounter a cycle. | |
| 31 | pub provisional_result: Option<X::Result>, | |
| 32 | ||
| 29 | 33 | /// The maximum depth required while evaluating this goal. |
| 30 | 34 | pub required_depth: usize, |
| 31 | 35 | |
| ... | ... | @@ -42,10 +46,6 @@ pub(super) struct StackEntry<X: Cx> { |
| 42 | 46 | |
| 43 | 47 | /// The nested goals of this goal, see the doc comment of the type. |
| 44 | 48 | pub nested_goals: NestedGoals<X>, |
| 45 | ||
| 46 | /// Starts out as `None` and gets set when rerunning this | |
| 47 | /// goal in case we encounter a cycle. | |
| 48 | pub provisional_result: Option<X::Result>, | |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | #[derive_where(Default; X: Cx)] |
library/Cargo.toml+10| ... | ... | @@ -1,3 +1,5 @@ |
| 1 | cargo-features = ["profile-rustflags"] | |
| 2 | ||
| 1 | 3 | [workspace] |
| 2 | 4 | resolver = "1" |
| 3 | 5 | members = [ |
| ... | ... | @@ -44,6 +46,14 @@ object.debug = 0 |
| 44 | 46 | rustc-demangle.debug = 0 |
| 45 | 47 | rustc-demangle.opt-level = "s" |
| 46 | 48 | |
| 49 | # panic_abort must always be compiled with panic=abort, even when the rest of the | |
| 50 | # sysroot is panic=unwind. | |
| 51 | [profile.dev.package.panic_abort] | |
| 52 | rustflags = ["-Cpanic=abort"] | |
| 53 | ||
| 54 | [profile.release.package.panic_abort] | |
| 55 | rustflags = ["-Cpanic=abort"] | |
| 56 | ||
| 47 | 57 | [patch.crates-io] |
| 48 | 58 | # See comments in `library/rustc-std-workspace-core/README.md` for what's going on |
| 49 | 59 | # here |
library/core/src/num/int_macros.rs-208| ... | ... | @@ -29,8 +29,6 @@ macro_rules! int_impl { |
| 29 | 29 | /// |
| 30 | 30 | /// # Examples |
| 31 | 31 | /// |
| 32 | /// Basic usage: | |
| 33 | /// | |
| 34 | 32 | /// ``` |
| 35 | 33 | #[doc = concat!("assert_eq!(", stringify!($SelfT), "::MIN, ", stringify!($Min), ");")] |
| 36 | 34 | /// ``` |
| ... | ... | @@ -42,8 +40,6 @@ macro_rules! int_impl { |
| 42 | 40 | /// |
| 43 | 41 | /// # Examples |
| 44 | 42 | /// |
| 45 | /// Basic usage: | |
| 46 | /// | |
| 47 | 43 | /// ``` |
| 48 | 44 | #[doc = concat!("assert_eq!(", stringify!($SelfT), "::MAX, ", stringify!($Max), ");")] |
| 49 | 45 | /// ``` |
| ... | ... | @@ -64,8 +60,6 @@ macro_rules! int_impl { |
| 64 | 60 | /// |
| 65 | 61 | /// # Examples |
| 66 | 62 | /// |
| 67 | /// Basic usage: | |
| 68 | /// | |
| 69 | 63 | /// ``` |
| 70 | 64 | #[doc = concat!("let n = 0b100_0000", stringify!($SelfT), ";")] |
| 71 | 65 | /// |
| ... | ... | @@ -85,8 +79,6 @@ macro_rules! int_impl { |
| 85 | 79 | /// |
| 86 | 80 | /// # Examples |
| 87 | 81 | /// |
| 88 | /// Basic usage: | |
| 89 | /// | |
| 90 | 82 | /// ``` |
| 91 | 83 | #[doc = concat!("assert_eq!(", stringify!($SelfT), "::MAX.count_zeros(), 1);")] |
| 92 | 84 | /// ``` |
| ... | ... | @@ -106,8 +98,6 @@ macro_rules! int_impl { |
| 106 | 98 | /// |
| 107 | 99 | /// # Examples |
| 108 | 100 | /// |
| 109 | /// Basic usage: | |
| 110 | /// | |
| 111 | 101 | /// ``` |
| 112 | 102 | #[doc = concat!("let n = -1", stringify!($SelfT), ";")] |
| 113 | 103 | /// |
| ... | ... | @@ -127,8 +117,6 @@ macro_rules! int_impl { |
| 127 | 117 | /// |
| 128 | 118 | /// # Examples |
| 129 | 119 | /// |
| 130 | /// Basic usage: | |
| 131 | /// | |
| 132 | 120 | /// ``` |
| 133 | 121 | #[doc = concat!("let n = -4", stringify!($SelfT), ";")] |
| 134 | 122 | /// |
| ... | ... | @@ -147,8 +135,6 @@ macro_rules! int_impl { |
| 147 | 135 | /// |
| 148 | 136 | /// # Examples |
| 149 | 137 | /// |
| 150 | /// Basic usage: | |
| 151 | /// | |
| 152 | 138 | /// ``` |
| 153 | 139 | #[doc = concat!("let n = -1", stringify!($SelfT), ";")] |
| 154 | 140 | /// |
| ... | ... | @@ -167,8 +153,6 @@ macro_rules! int_impl { |
| 167 | 153 | /// |
| 168 | 154 | /// # Examples |
| 169 | 155 | /// |
| 170 | /// Basic usage: | |
| 171 | /// | |
| 172 | 156 | /// ``` |
| 173 | 157 | #[doc = concat!("let n = 3", stringify!($SelfT), ";")] |
| 174 | 158 | /// |
| ... | ... | @@ -188,8 +172,6 @@ macro_rules! int_impl { |
| 188 | 172 | /// |
| 189 | 173 | /// # Examples |
| 190 | 174 | /// |
| 191 | /// Basic usage: | |
| 192 | /// | |
| 193 | 175 | /// ``` |
| 194 | 176 | /// #![feature(isolate_most_least_significant_one)] |
| 195 | 177 | /// |
| ... | ... | @@ -211,8 +193,6 @@ macro_rules! int_impl { |
| 211 | 193 | /// |
| 212 | 194 | /// # Examples |
| 213 | 195 | /// |
| 214 | /// Basic usage: | |
| 215 | /// | |
| 216 | 196 | /// ``` |
| 217 | 197 | /// #![feature(isolate_most_least_significant_one)] |
| 218 | 198 | /// |
| ... | ... | @@ -236,8 +216,6 @@ macro_rules! int_impl { |
| 236 | 216 | /// |
| 237 | 217 | /// # Examples |
| 238 | 218 | /// |
| 239 | /// Basic usage: | |
| 240 | /// | |
| 241 | 219 | /// ``` |
| 242 | 220 | #[doc = concat!("let n = -1", stringify!($SelfT), ";")] |
| 243 | 221 | /// |
| ... | ... | @@ -259,8 +237,6 @@ macro_rules! int_impl { |
| 259 | 237 | /// |
| 260 | 238 | /// # Examples |
| 261 | 239 | /// |
| 262 | /// Basic usage: | |
| 263 | /// | |
| 264 | 240 | /// ``` |
| 265 | 241 | #[doc = concat!("let n = ", $rot_op, stringify!($SelfT), ";")] |
| 266 | 242 | #[doc = concat!("let m = ", $rot_result, ";")] |
| ... | ... | @@ -284,8 +260,6 @@ macro_rules! int_impl { |
| 284 | 260 | /// |
| 285 | 261 | /// # Examples |
| 286 | 262 | /// |
| 287 | /// Basic usage: | |
| 288 | /// | |
| 289 | 263 | /// ``` |
| 290 | 264 | #[doc = concat!("let n = ", $rot_result, stringify!($SelfT), ";")] |
| 291 | 265 | #[doc = concat!("let m = ", $rot_op, ";")] |
| ... | ... | @@ -305,8 +279,6 @@ macro_rules! int_impl { |
| 305 | 279 | /// |
| 306 | 280 | /// # Examples |
| 307 | 281 | /// |
| 308 | /// Basic usage: | |
| 309 | /// | |
| 310 | 282 | /// ``` |
| 311 | 283 | #[doc = concat!("let n = ", $swap_op, stringify!($SelfT), ";")] |
| 312 | 284 | /// |
| ... | ... | @@ -328,8 +300,6 @@ macro_rules! int_impl { |
| 328 | 300 | /// |
| 329 | 301 | /// # Examples |
| 330 | 302 | /// |
| 331 | /// Basic usage: | |
| 332 | /// | |
| 333 | 303 | /// ``` |
| 334 | 304 | #[doc = concat!("let n = ", $swap_op, stringify!($SelfT), ";")] |
| 335 | 305 | /// let m = n.reverse_bits(); |
| ... | ... | @@ -352,8 +322,6 @@ macro_rules! int_impl { |
| 352 | 322 | /// |
| 353 | 323 | /// # Examples |
| 354 | 324 | /// |
| 355 | /// Basic usage: | |
| 356 | /// | |
| 357 | 325 | /// ``` |
| 358 | 326 | #[doc = concat!("let n = 0x1A", stringify!($SelfT), ";")] |
| 359 | 327 | /// |
| ... | ... | @@ -384,8 +352,6 @@ macro_rules! int_impl { |
| 384 | 352 | /// |
| 385 | 353 | /// # Examples |
| 386 | 354 | /// |
| 387 | /// Basic usage: | |
| 388 | /// | |
| 389 | 355 | /// ``` |
| 390 | 356 | #[doc = concat!("let n = 0x1A", stringify!($SelfT), ";")] |
| 391 | 357 | /// |
| ... | ... | @@ -416,8 +382,6 @@ macro_rules! int_impl { |
| 416 | 382 | /// |
| 417 | 383 | /// # Examples |
| 418 | 384 | /// |
| 419 | /// Basic usage: | |
| 420 | /// | |
| 421 | 385 | /// ``` |
| 422 | 386 | #[doc = concat!("let n = 0x1A", stringify!($SelfT), ";")] |
| 423 | 387 | /// |
| ... | ... | @@ -449,8 +413,6 @@ macro_rules! int_impl { |
| 449 | 413 | /// |
| 450 | 414 | /// # Examples |
| 451 | 415 | /// |
| 452 | /// Basic usage: | |
| 453 | /// | |
| 454 | 416 | /// ``` |
| 455 | 417 | #[doc = concat!("let n = 0x1A", stringify!($SelfT), ";")] |
| 456 | 418 | /// |
| ... | ... | @@ -481,8 +443,6 @@ macro_rules! int_impl { |
| 481 | 443 | /// |
| 482 | 444 | /// # Examples |
| 483 | 445 | /// |
| 484 | /// Basic usage: | |
| 485 | /// | |
| 486 | 446 | /// ``` |
| 487 | 447 | #[doc = concat!("assert_eq!((", stringify!($SelfT), "::MAX - 2).checked_add(1), Some(", stringify!($SelfT), "::MAX - 1));")] |
| 488 | 448 | #[doc = concat!("assert_eq!((", stringify!($SelfT), "::MAX - 2).checked_add(3), None);")] |
| ... | ... | @@ -508,8 +468,6 @@ macro_rules! int_impl { |
| 508 | 468 | /// |
| 509 | 469 | /// # Examples |
| 510 | 470 | /// |
| 511 | /// Basic usage: | |
| 512 | /// | |
| 513 | 471 | /// ``` |
| 514 | 472 | /// #![feature(strict_overflow_ops)] |
| 515 | 473 | #[doc = concat!("assert_eq!((", stringify!($SelfT), "::MAX - 2).strict_add(1), ", stringify!($SelfT), "::MAX - 1);")] |
| ... | ... | @@ -576,8 +534,6 @@ macro_rules! int_impl { |
| 576 | 534 | /// |
| 577 | 535 | /// # Examples |
| 578 | 536 | /// |
| 579 | /// Basic usage: | |
| 580 | /// | |
| 581 | 537 | /// ``` |
| 582 | 538 | #[doc = concat!("assert_eq!(1", stringify!($SelfT), ".checked_add_unsigned(2), Some(3));")] |
| 583 | 539 | #[doc = concat!("assert_eq!((", stringify!($SelfT), "::MAX - 2).checked_add_unsigned(3), None);")] |
| ... | ... | @@ -603,8 +559,6 @@ macro_rules! int_impl { |
| 603 | 559 | /// |
| 604 | 560 | /// # Examples |
| 605 | 561 | /// |
| 606 | /// Basic usage: | |
| 607 | /// | |
| 608 | 562 | /// ``` |
| 609 | 563 | /// #![feature(strict_overflow_ops)] |
| 610 | 564 | #[doc = concat!("assert_eq!(1", stringify!($SelfT), ".strict_add_unsigned(2), 3);")] |
| ... | ... | @@ -631,8 +585,6 @@ macro_rules! int_impl { |
| 631 | 585 | /// |
| 632 | 586 | /// # Examples |
| 633 | 587 | /// |
| 634 | /// Basic usage: | |
| 635 | /// | |
| 636 | 588 | /// ``` |
| 637 | 589 | #[doc = concat!("assert_eq!((", stringify!($SelfT), "::MIN + 2).checked_sub(1), Some(", stringify!($SelfT), "::MIN + 1));")] |
| 638 | 590 | #[doc = concat!("assert_eq!((", stringify!($SelfT), "::MIN + 2).checked_sub(3), None);")] |
| ... | ... | @@ -658,8 +610,6 @@ macro_rules! int_impl { |
| 658 | 610 | /// |
| 659 | 611 | /// # Examples |
| 660 | 612 | /// |
| 661 | /// Basic usage: | |
| 662 | /// | |
| 663 | 613 | /// ``` |
| 664 | 614 | /// #![feature(strict_overflow_ops)] |
| 665 | 615 | #[doc = concat!("assert_eq!((", stringify!($SelfT), "::MIN + 2).strict_sub(1), ", stringify!($SelfT), "::MIN + 1);")] |
| ... | ... | @@ -726,8 +676,6 @@ macro_rules! int_impl { |
| 726 | 676 | /// |
| 727 | 677 | /// # Examples |
| 728 | 678 | /// |
| 729 | /// Basic usage: | |
| 730 | /// | |
| 731 | 679 | /// ``` |
| 732 | 680 | #[doc = concat!("assert_eq!(1", stringify!($SelfT), ".checked_sub_unsigned(2), Some(-1));")] |
| 733 | 681 | #[doc = concat!("assert_eq!((", stringify!($SelfT), "::MIN + 2).checked_sub_unsigned(3), None);")] |
| ... | ... | @@ -753,8 +701,6 @@ macro_rules! int_impl { |
| 753 | 701 | /// |
| 754 | 702 | /// # Examples |
| 755 | 703 | /// |
| 756 | /// Basic usage: | |
| 757 | /// | |
| 758 | 704 | /// ``` |
| 759 | 705 | /// #![feature(strict_overflow_ops)] |
| 760 | 706 | #[doc = concat!("assert_eq!(1", stringify!($SelfT), ".strict_sub_unsigned(2), -1);")] |
| ... | ... | @@ -781,8 +727,6 @@ macro_rules! int_impl { |
| 781 | 727 | /// |
| 782 | 728 | /// # Examples |
| 783 | 729 | /// |
| 784 | /// Basic usage: | |
| 785 | /// | |
| 786 | 730 | /// ``` |
| 787 | 731 | #[doc = concat!("assert_eq!(", stringify!($SelfT), "::MAX.checked_mul(1), Some(", stringify!($SelfT), "::MAX));")] |
| 788 | 732 | #[doc = concat!("assert_eq!(", stringify!($SelfT), "::MAX.checked_mul(2), None);")] |
| ... | ... | @@ -808,8 +752,6 @@ macro_rules! int_impl { |
| 808 | 752 | /// |
| 809 | 753 | /// # Examples |
| 810 | 754 | /// |
| 811 | /// Basic usage: | |
| 812 | /// | |
| 813 | 755 | /// ``` |
| 814 | 756 | /// #![feature(strict_overflow_ops)] |
| 815 | 757 | #[doc = concat!("assert_eq!(", stringify!($SelfT), "::MAX.strict_mul(1), ", stringify!($SelfT), "::MAX);")] |
| ... | ... | @@ -876,8 +818,6 @@ macro_rules! int_impl { |
| 876 | 818 | /// |
| 877 | 819 | /// # Examples |
| 878 | 820 | /// |
| 879 | /// Basic usage: | |
| 880 | /// | |
| 881 | 821 | /// ``` |
| 882 | 822 | #[doc = concat!("assert_eq!((", stringify!($SelfT), "::MIN + 1).checked_div(-1), Some(", stringify!($Max), "));")] |
| 883 | 823 | #[doc = concat!("assert_eq!(", stringify!($SelfT), "::MIN.checked_div(-1), None);")] |
| ... | ... | @@ -914,8 +854,6 @@ macro_rules! int_impl { |
| 914 | 854 | /// |
| 915 | 855 | /// # Examples |
| 916 | 856 | /// |
| 917 | /// Basic usage: | |
| 918 | /// | |
| 919 | 857 | /// ``` |
| 920 | 858 | /// #![feature(strict_overflow_ops)] |
| 921 | 859 | #[doc = concat!("assert_eq!((", stringify!($SelfT), "::MIN + 1).strict_div(-1), ", stringify!($Max), ");")] |
| ... | ... | @@ -949,8 +887,6 @@ macro_rules! int_impl { |
| 949 | 887 | /// |
| 950 | 888 | /// # Examples |
| 951 | 889 | /// |
| 952 | /// Basic usage: | |
| 953 | /// | |
| 954 | 890 | /// ``` |
| 955 | 891 | #[doc = concat!("assert_eq!((", stringify!($SelfT), "::MIN + 1).checked_div_euclid(-1), Some(", stringify!($Max), "));")] |
| 956 | 892 | #[doc = concat!("assert_eq!(", stringify!($SelfT), "::MIN.checked_div_euclid(-1), None);")] |
| ... | ... | @@ -987,8 +923,6 @@ macro_rules! int_impl { |
| 987 | 923 | /// |
| 988 | 924 | /// # Examples |
| 989 | 925 | /// |
| 990 | /// Basic usage: | |
| 991 | /// | |
| 992 | 926 | /// ``` |
| 993 | 927 | /// #![feature(strict_overflow_ops)] |
| 994 | 928 | #[doc = concat!("assert_eq!((", stringify!($SelfT), "::MIN + 1).strict_div_euclid(-1), ", stringify!($Max), ");")] |
| ... | ... | @@ -1023,8 +957,6 @@ macro_rules! int_impl { |
| 1023 | 957 | /// |
| 1024 | 958 | /// # Examples |
| 1025 | 959 | /// |
| 1026 | /// Basic usage: | |
| 1027 | /// | |
| 1028 | 960 | /// ``` |
| 1029 | 961 | /// #![feature(exact_div)] |
| 1030 | 962 | #[doc = concat!("assert_eq!((", stringify!($SelfT), "::MIN + 1).checked_exact_div(-1), Some(", stringify!($Max), "));")] |
| ... | ... | @@ -1063,8 +995,6 @@ macro_rules! int_impl { |
| 1063 | 995 | /// |
| 1064 | 996 | /// # Examples |
| 1065 | 997 | /// |
| 1066 | /// Basic usage: | |
| 1067 | /// | |
| 1068 | 998 | /// ``` |
| 1069 | 999 | /// #![feature(exact_div)] |
| 1070 | 1000 | #[doc = concat!("assert_eq!(64", stringify!($SelfT), ".exact_div(2), 32);")] |
| ... | ... | @@ -1126,8 +1056,6 @@ macro_rules! int_impl { |
| 1126 | 1056 | /// |
| 1127 | 1057 | /// # Examples |
| 1128 | 1058 | /// |
| 1129 | /// Basic usage: | |
| 1130 | /// | |
| 1131 | 1059 | /// ``` |
| 1132 | 1060 | #[doc = concat!("assert_eq!(5", stringify!($SelfT), ".checked_rem(2), Some(1));")] |
| 1133 | 1061 | #[doc = concat!("assert_eq!(5", stringify!($SelfT), ".checked_rem(0), None);")] |
| ... | ... | @@ -1163,8 +1091,6 @@ macro_rules! int_impl { |
| 1163 | 1091 | /// |
| 1164 | 1092 | /// # Examples |
| 1165 | 1093 | /// |
| 1166 | /// Basic usage: | |
| 1167 | /// | |
| 1168 | 1094 | /// ``` |
| 1169 | 1095 | /// #![feature(strict_overflow_ops)] |
| 1170 | 1096 | #[doc = concat!("assert_eq!(5", stringify!($SelfT), ".strict_rem(2), 1);")] |
| ... | ... | @@ -1198,8 +1124,6 @@ macro_rules! int_impl { |
| 1198 | 1124 | /// |
| 1199 | 1125 | /// # Examples |
| 1200 | 1126 | /// |
| 1201 | /// Basic usage: | |
| 1202 | /// | |
| 1203 | 1127 | /// ``` |
| 1204 | 1128 | #[doc = concat!("assert_eq!(5", stringify!($SelfT), ".checked_rem_euclid(2), Some(1));")] |
| 1205 | 1129 | #[doc = concat!("assert_eq!(5", stringify!($SelfT), ".checked_rem_euclid(0), None);")] |
| ... | ... | @@ -1235,8 +1159,6 @@ macro_rules! int_impl { |
| 1235 | 1159 | /// |
| 1236 | 1160 | /// # Examples |
| 1237 | 1161 | /// |
| 1238 | /// Basic usage: | |
| 1239 | /// | |
| 1240 | 1162 | /// ``` |
| 1241 | 1163 | /// #![feature(strict_overflow_ops)] |
| 1242 | 1164 | #[doc = concat!("assert_eq!(5", stringify!($SelfT), ".strict_rem_euclid(2), 1);")] |
| ... | ... | @@ -1269,8 +1191,6 @@ macro_rules! int_impl { |
| 1269 | 1191 | /// |
| 1270 | 1192 | /// # Examples |
| 1271 | 1193 | /// |
| 1272 | /// Basic usage: | |
| 1273 | /// | |
| 1274 | 1194 | /// ``` |
| 1275 | 1195 | #[doc = concat!("assert_eq!(5", stringify!($SelfT), ".checked_neg(), Some(-5));")] |
| 1276 | 1196 | #[doc = concat!("assert_eq!(", stringify!($SelfT), "::MIN.checked_neg(), None);")] |
| ... | ... | @@ -1328,8 +1248,6 @@ macro_rules! int_impl { |
| 1328 | 1248 | /// |
| 1329 | 1249 | /// # Examples |
| 1330 | 1250 | /// |
| 1331 | /// Basic usage: | |
| 1332 | /// | |
| 1333 | 1251 | /// ``` |
| 1334 | 1252 | /// #![feature(strict_overflow_ops)] |
| 1335 | 1253 | #[doc = concat!("assert_eq!(5", stringify!($SelfT), ".strict_neg(), -5);")] |
| ... | ... | @@ -1356,8 +1274,6 @@ macro_rules! int_impl { |
| 1356 | 1274 | /// |
| 1357 | 1275 | /// # Examples |
| 1358 | 1276 | /// |
| 1359 | /// Basic usage: | |
| 1360 | /// | |
| 1361 | 1277 | /// ``` |
| 1362 | 1278 | #[doc = concat!("assert_eq!(0x1", stringify!($SelfT), ".checked_shl(4), Some(0x10));")] |
| 1363 | 1279 | #[doc = concat!("assert_eq!(0x1", stringify!($SelfT), ".checked_shl(129), None);")] |
| ... | ... | @@ -1389,8 +1305,6 @@ macro_rules! int_impl { |
| 1389 | 1305 | /// |
| 1390 | 1306 | /// # Examples |
| 1391 | 1307 | /// |
| 1392 | /// Basic usage: | |
| 1393 | /// | |
| 1394 | 1308 | /// ``` |
| 1395 | 1309 | /// #![feature(strict_overflow_ops)] |
| 1396 | 1310 | #[doc = concat!("assert_eq!(0x1", stringify!($SelfT), ".strict_shl(4), 0x10);")] |
| ... | ... | @@ -1453,7 +1367,6 @@ macro_rules! int_impl { |
| 1453 | 1367 | /// |
| 1454 | 1368 | /// # Examples |
| 1455 | 1369 | /// |
| 1456 | /// Basic usage: | |
| 1457 | 1370 | /// ``` |
| 1458 | 1371 | #[doc = concat!("assert_eq!(0x1", stringify!($SelfT), ".unbounded_shl(4), 0x10);")] |
| 1459 | 1372 | #[doc = concat!("assert_eq!(0x1", stringify!($SelfT), ".unbounded_shl(129), 0);")] |
| ... | ... | @@ -1478,8 +1391,6 @@ macro_rules! int_impl { |
| 1478 | 1391 | /// |
| 1479 | 1392 | /// # Examples |
| 1480 | 1393 | /// |
| 1481 | /// Basic usage: | |
| 1482 | /// | |
| 1483 | 1394 | /// ``` |
| 1484 | 1395 | #[doc = concat!("assert_eq!(0x10", stringify!($SelfT), ".checked_shr(4), Some(0x1));")] |
| 1485 | 1396 | #[doc = concat!("assert_eq!(0x10", stringify!($SelfT), ".checked_shr(128), None);")] |
| ... | ... | @@ -1510,8 +1421,6 @@ macro_rules! int_impl { |
| 1510 | 1421 | /// |
| 1511 | 1422 | /// # Examples |
| 1512 | 1423 | /// |
| 1513 | /// Basic usage: | |
| 1514 | /// | |
| 1515 | 1424 | /// ``` |
| 1516 | 1425 | /// #![feature(strict_overflow_ops)] |
| 1517 | 1426 | #[doc = concat!("assert_eq!(0x10", stringify!($SelfT), ".strict_shr(4), 0x1);")] |
| ... | ... | @@ -1575,7 +1484,6 @@ macro_rules! int_impl { |
| 1575 | 1484 | /// |
| 1576 | 1485 | /// # Examples |
| 1577 | 1486 | /// |
| 1578 | /// Basic usage: | |
| 1579 | 1487 | /// ``` |
| 1580 | 1488 | #[doc = concat!("assert_eq!(0x10", stringify!($SelfT), ".unbounded_shr(4), 0x1);")] |
| 1581 | 1489 | #[doc = concat!("assert_eq!(0x10", stringify!($SelfT), ".unbounded_shr(129), 0);")] |
| ... | ... | @@ -1605,8 +1513,6 @@ macro_rules! int_impl { |
| 1605 | 1513 | /// |
| 1606 | 1514 | /// # Examples |
| 1607 | 1515 | /// |
| 1608 | /// Basic usage: | |
| 1609 | /// | |
| 1610 | 1516 | /// ``` |
| 1611 | 1517 | #[doc = concat!("assert_eq!((-5", stringify!($SelfT), ").checked_abs(), Some(5));")] |
| 1612 | 1518 | #[doc = concat!("assert_eq!(", stringify!($SelfT), "::MIN.checked_abs(), None);")] |
| ... | ... | @@ -1635,8 +1541,6 @@ macro_rules! int_impl { |
| 1635 | 1541 | /// |
| 1636 | 1542 | /// # Examples |
| 1637 | 1543 | /// |
| 1638 | /// Basic usage: | |
| 1639 | /// | |
| 1640 | 1544 | /// ``` |
| 1641 | 1545 | /// #![feature(strict_overflow_ops)] |
| 1642 | 1546 | #[doc = concat!("assert_eq!((-5", stringify!($SelfT), ").strict_abs(), 5);")] |
| ... | ... | @@ -1666,8 +1570,6 @@ macro_rules! int_impl { |
| 1666 | 1570 | /// |
| 1667 | 1571 | /// # Examples |
| 1668 | 1572 | /// |
| 1669 | /// Basic usage: | |
| 1670 | /// | |
| 1671 | 1573 | /// ``` |
| 1672 | 1574 | #[doc = concat!("assert_eq!(8", stringify!($SelfT), ".checked_pow(2), Some(64));")] |
| 1673 | 1575 | #[doc = concat!("assert_eq!(", stringify!($SelfT), "::MAX.checked_pow(2), None);")] |
| ... | ... | @@ -1709,8 +1611,6 @@ macro_rules! int_impl { |
| 1709 | 1611 | /// |
| 1710 | 1612 | /// # Examples |
| 1711 | 1613 | /// |
| 1712 | /// Basic usage: | |
| 1713 | /// | |
| 1714 | 1614 | /// ``` |
| 1715 | 1615 | /// #![feature(strict_overflow_ops)] |
| 1716 | 1616 | #[doc = concat!("assert_eq!(8", stringify!($SelfT), ".strict_pow(2), 64);")] |
| ... | ... | @@ -1753,7 +1653,6 @@ macro_rules! int_impl { |
| 1753 | 1653 | /// |
| 1754 | 1654 | /// # Examples |
| 1755 | 1655 | /// |
| 1756 | /// Basic usage: | |
| 1757 | 1656 | /// ``` |
| 1758 | 1657 | #[doc = concat!("assert_eq!(10", stringify!($SelfT), ".checked_isqrt(), Some(3));")] |
| 1759 | 1658 | /// ``` |
| ... | ... | @@ -1801,8 +1700,6 @@ macro_rules! int_impl { |
| 1801 | 1700 | /// |
| 1802 | 1701 | /// # Examples |
| 1803 | 1702 | /// |
| 1804 | /// Basic usage: | |
| 1805 | /// | |
| 1806 | 1703 | /// ``` |
| 1807 | 1704 | #[doc = concat!("assert_eq!(100", stringify!($SelfT), ".saturating_add(1), 101);")] |
| 1808 | 1705 | #[doc = concat!("assert_eq!(", stringify!($SelfT), "::MAX.saturating_add(100), ", stringify!($SelfT), "::MAX);")] |
| ... | ... | @@ -1823,8 +1720,6 @@ macro_rules! int_impl { |
| 1823 | 1720 | /// |
| 1824 | 1721 | /// # Examples |
| 1825 | 1722 | /// |
| 1826 | /// Basic usage: | |
| 1827 | /// | |
| 1828 | 1723 | /// ``` |
| 1829 | 1724 | #[doc = concat!("assert_eq!(1", stringify!($SelfT), ".saturating_add_unsigned(2), 3);")] |
| 1830 | 1725 | #[doc = concat!("assert_eq!(", stringify!($SelfT), "::MAX.saturating_add_unsigned(100), ", stringify!($SelfT), "::MAX);")] |
| ... | ... | @@ -1848,8 +1743,6 @@ macro_rules! int_impl { |
| 1848 | 1743 | /// |
| 1849 | 1744 | /// # Examples |
| 1850 | 1745 | /// |
| 1851 | /// Basic usage: | |
| 1852 | /// | |
| 1853 | 1746 | /// ``` |
| 1854 | 1747 | #[doc = concat!("assert_eq!(100", stringify!($SelfT), ".saturating_sub(127), -27);")] |
| 1855 | 1748 | #[doc = concat!("assert_eq!(", stringify!($SelfT), "::MIN.saturating_sub(100), ", stringify!($SelfT), "::MIN);")] |
| ... | ... | @@ -1869,8 +1762,6 @@ macro_rules! int_impl { |
| 1869 | 1762 | /// |
| 1870 | 1763 | /// # Examples |
| 1871 | 1764 | /// |
| 1872 | /// Basic usage: | |
| 1873 | /// | |
| 1874 | 1765 | /// ``` |
| 1875 | 1766 | #[doc = concat!("assert_eq!(100", stringify!($SelfT), ".saturating_sub_unsigned(127), -27);")] |
| 1876 | 1767 | #[doc = concat!("assert_eq!(", stringify!($SelfT), "::MIN.saturating_sub_unsigned(100), ", stringify!($SelfT), "::MIN);")] |
| ... | ... | @@ -1894,8 +1785,6 @@ macro_rules! int_impl { |
| 1894 | 1785 | /// |
| 1895 | 1786 | /// # Examples |
| 1896 | 1787 | /// |
| 1897 | /// Basic usage: | |
| 1898 | /// | |
| 1899 | 1788 | /// ``` |
| 1900 | 1789 | #[doc = concat!("assert_eq!(100", stringify!($SelfT), ".saturating_neg(), -100);")] |
| 1901 | 1790 | #[doc = concat!("assert_eq!((-100", stringify!($SelfT), ").saturating_neg(), 100);")] |
| ... | ... | @@ -1917,8 +1806,6 @@ macro_rules! int_impl { |
| 1917 | 1806 | /// |
| 1918 | 1807 | /// # Examples |
| 1919 | 1808 | /// |
| 1920 | /// Basic usage: | |
| 1921 | /// | |
| 1922 | 1809 | /// ``` |
| 1923 | 1810 | #[doc = concat!("assert_eq!(100", stringify!($SelfT), ".saturating_abs(), 100);")] |
| 1924 | 1811 | #[doc = concat!("assert_eq!((-100", stringify!($SelfT), ").saturating_abs(), 100);")] |
| ... | ... | @@ -1944,8 +1831,6 @@ macro_rules! int_impl { |
| 1944 | 1831 | /// |
| 1945 | 1832 | /// # Examples |
| 1946 | 1833 | /// |
| 1947 | /// Basic usage: | |
| 1948 | /// | |
| 1949 | 1834 | /// ``` |
| 1950 | 1835 | #[doc = concat!("assert_eq!(10", stringify!($SelfT), ".saturating_mul(12), 120);")] |
| 1951 | 1836 | #[doc = concat!("assert_eq!(", stringify!($SelfT), "::MAX.saturating_mul(10), ", stringify!($SelfT), "::MAX);")] |
| ... | ... | @@ -1976,8 +1861,6 @@ macro_rules! int_impl { |
| 1976 | 1861 | /// |
| 1977 | 1862 | /// # Examples |
| 1978 | 1863 | /// |
| 1979 | /// Basic usage: | |
| 1980 | /// | |
| 1981 | 1864 | /// ``` |
| 1982 | 1865 | #[doc = concat!("assert_eq!(5", stringify!($SelfT), ".saturating_div(2), 2);")] |
| 1983 | 1866 | #[doc = concat!("assert_eq!(", stringify!($SelfT), "::MAX.saturating_div(-1), ", stringify!($SelfT), "::MIN + 1);")] |
| ... | ... | @@ -2001,8 +1884,6 @@ macro_rules! int_impl { |
| 2001 | 1884 | /// |
| 2002 | 1885 | /// # Examples |
| 2003 | 1886 | /// |
| 2004 | /// Basic usage: | |
| 2005 | /// | |
| 2006 | 1887 | /// ``` |
| 2007 | 1888 | #[doc = concat!("assert_eq!((-4", stringify!($SelfT), ").saturating_pow(3), -64);")] |
| 2008 | 1889 | #[doc = concat!("assert_eq!(", stringify!($SelfT), "::MIN.saturating_pow(2), ", stringify!($SelfT), "::MAX);")] |
| ... | ... | @@ -2026,8 +1907,6 @@ macro_rules! int_impl { |
| 2026 | 1907 | /// |
| 2027 | 1908 | /// # Examples |
| 2028 | 1909 | /// |
| 2029 | /// Basic usage: | |
| 2030 | /// | |
| 2031 | 1910 | /// ``` |
| 2032 | 1911 | #[doc = concat!("assert_eq!(100", stringify!($SelfT), ".wrapping_add(27), 127);")] |
| 2033 | 1912 | #[doc = concat!("assert_eq!(", stringify!($SelfT), "::MAX.wrapping_add(2), ", stringify!($SelfT), "::MIN + 1);")] |
| ... | ... | @@ -2046,8 +1925,6 @@ macro_rules! int_impl { |
| 2046 | 1925 | /// |
| 2047 | 1926 | /// # Examples |
| 2048 | 1927 | /// |
| 2049 | /// Basic usage: | |
| 2050 | /// | |
| 2051 | 1928 | /// ``` |
| 2052 | 1929 | #[doc = concat!("assert_eq!(100", stringify!($SelfT), ".wrapping_add_unsigned(27), 127);")] |
| 2053 | 1930 | #[doc = concat!("assert_eq!(", stringify!($SelfT), "::MAX.wrapping_add_unsigned(2), ", stringify!($SelfT), "::MIN + 1);")] |
| ... | ... | @@ -2066,8 +1943,6 @@ macro_rules! int_impl { |
| 2066 | 1943 | /// |
| 2067 | 1944 | /// # Examples |
| 2068 | 1945 | /// |
| 2069 | /// Basic usage: | |
| 2070 | /// | |
| 2071 | 1946 | /// ``` |
| 2072 | 1947 | #[doc = concat!("assert_eq!(0", stringify!($SelfT), ".wrapping_sub(127), -127);")] |
| 2073 | 1948 | #[doc = concat!("assert_eq!((-2", stringify!($SelfT), ").wrapping_sub(", stringify!($SelfT), "::MAX), ", stringify!($SelfT), "::MAX);")] |
| ... | ... | @@ -2086,8 +1961,6 @@ macro_rules! int_impl { |
| 2086 | 1961 | /// |
| 2087 | 1962 | /// # Examples |
| 2088 | 1963 | /// |
| 2089 | /// Basic usage: | |
| 2090 | /// | |
| 2091 | 1964 | /// ``` |
| 2092 | 1965 | #[doc = concat!("assert_eq!(0", stringify!($SelfT), ".wrapping_sub_unsigned(127), -127);")] |
| 2093 | 1966 | #[doc = concat!("assert_eq!((-2", stringify!($SelfT), ").wrapping_sub_unsigned(", stringify!($UnsignedT), "::MAX), -1);")] |
| ... | ... | @@ -2106,8 +1979,6 @@ macro_rules! int_impl { |
| 2106 | 1979 | /// |
| 2107 | 1980 | /// # Examples |
| 2108 | 1981 | /// |
| 2109 | /// Basic usage: | |
| 2110 | /// | |
| 2111 | 1982 | /// ``` |
| 2112 | 1983 | #[doc = concat!("assert_eq!(10", stringify!($SelfT), ".wrapping_mul(12), 120);")] |
| 2113 | 1984 | /// assert_eq!(11i8.wrapping_mul(12), -124); |
| ... | ... | @@ -2134,8 +2005,6 @@ macro_rules! int_impl { |
| 2134 | 2005 | /// |
| 2135 | 2006 | /// # Examples |
| 2136 | 2007 | /// |
| 2137 | /// Basic usage: | |
| 2138 | /// | |
| 2139 | 2008 | /// ``` |
| 2140 | 2009 | #[doc = concat!("assert_eq!(100", stringify!($SelfT), ".wrapping_div(10), 10);")] |
| 2141 | 2010 | /// assert_eq!((-128i8).wrapping_div(-1), -128); |
| ... | ... | @@ -2162,8 +2031,6 @@ macro_rules! int_impl { |
| 2162 | 2031 | /// |
| 2163 | 2032 | /// # Examples |
| 2164 | 2033 | /// |
| 2165 | /// Basic usage: | |
| 2166 | /// | |
| 2167 | 2034 | /// ``` |
| 2168 | 2035 | #[doc = concat!("assert_eq!(100", stringify!($SelfT), ".wrapping_div_euclid(10), 10);")] |
| 2169 | 2036 | /// assert_eq!((-128i8).wrapping_div_euclid(-1), -128); |
| ... | ... | @@ -2190,8 +2057,6 @@ macro_rules! int_impl { |
| 2190 | 2057 | /// |
| 2191 | 2058 | /// # Examples |
| 2192 | 2059 | /// |
| 2193 | /// Basic usage: | |
| 2194 | /// | |
| 2195 | 2060 | /// ``` |
| 2196 | 2061 | #[doc = concat!("assert_eq!(100", stringify!($SelfT), ".wrapping_rem(10), 0);")] |
| 2197 | 2062 | /// assert_eq!((-128i8).wrapping_rem(-1), 0); |
| ... | ... | @@ -2217,8 +2082,6 @@ macro_rules! int_impl { |
| 2217 | 2082 | /// |
| 2218 | 2083 | /// # Examples |
| 2219 | 2084 | /// |
| 2220 | /// Basic usage: | |
| 2221 | /// | |
| 2222 | 2085 | /// ``` |
| 2223 | 2086 | #[doc = concat!("assert_eq!(100", stringify!($SelfT), ".wrapping_rem_euclid(10), 0);")] |
| 2224 | 2087 | /// assert_eq!((-128i8).wrapping_rem_euclid(-1), 0); |
| ... | ... | @@ -2241,8 +2104,6 @@ macro_rules! int_impl { |
| 2241 | 2104 | /// |
| 2242 | 2105 | /// # Examples |
| 2243 | 2106 | /// |
| 2244 | /// Basic usage: | |
| 2245 | /// | |
| 2246 | 2107 | /// ``` |
| 2247 | 2108 | #[doc = concat!("assert_eq!(100", stringify!($SelfT), ".wrapping_neg(), -100);")] |
| 2248 | 2109 | #[doc = concat!("assert_eq!((-100", stringify!($SelfT), ").wrapping_neg(), 100);")] |
| ... | ... | @@ -2267,8 +2128,6 @@ macro_rules! int_impl { |
| 2267 | 2128 | /// |
| 2268 | 2129 | /// # Examples |
| 2269 | 2130 | /// |
| 2270 | /// Basic usage: | |
| 2271 | /// | |
| 2272 | 2131 | /// ``` |
| 2273 | 2132 | #[doc = concat!("assert_eq!((-1", stringify!($SelfT), ").wrapping_shl(7), -128);")] |
| 2274 | 2133 | #[doc = concat!("assert_eq!((-1", stringify!($SelfT), ").wrapping_shl(128), -1);")] |
| ... | ... | @@ -2296,8 +2155,6 @@ macro_rules! int_impl { |
| 2296 | 2155 | /// |
| 2297 | 2156 | /// # Examples |
| 2298 | 2157 | /// |
| 2299 | /// Basic usage: | |
| 2300 | /// | |
| 2301 | 2158 | /// ``` |
| 2302 | 2159 | #[doc = concat!("assert_eq!((-128", stringify!($SelfT), ").wrapping_shr(7), -1);")] |
| 2303 | 2160 | /// assert_eq!((-128i16).wrapping_shr(64), -128); |
| ... | ... | @@ -2324,8 +2181,6 @@ macro_rules! int_impl { |
| 2324 | 2181 | /// |
| 2325 | 2182 | /// # Examples |
| 2326 | 2183 | /// |
| 2327 | /// Basic usage: | |
| 2328 | /// | |
| 2329 | 2184 | /// ``` |
| 2330 | 2185 | #[doc = concat!("assert_eq!(100", stringify!($SelfT), ".wrapping_abs(), 100);")] |
| 2331 | 2186 | #[doc = concat!("assert_eq!((-100", stringify!($SelfT), ").wrapping_abs(), 100);")] |
| ... | ... | @@ -2352,8 +2207,6 @@ macro_rules! int_impl { |
| 2352 | 2207 | /// |
| 2353 | 2208 | /// # Examples |
| 2354 | 2209 | /// |
| 2355 | /// Basic usage: | |
| 2356 | /// | |
| 2357 | 2210 | /// ``` |
| 2358 | 2211 | #[doc = concat!("assert_eq!(100", stringify!($SelfT), ".unsigned_abs(), 100", stringify!($UnsignedT), ");")] |
| 2359 | 2212 | #[doc = concat!("assert_eq!((-100", stringify!($SelfT), ").unsigned_abs(), 100", stringify!($UnsignedT), ");")] |
| ... | ... | @@ -2373,8 +2226,6 @@ macro_rules! int_impl { |
| 2373 | 2226 | /// |
| 2374 | 2227 | /// # Examples |
| 2375 | 2228 | /// |
| 2376 | /// Basic usage: | |
| 2377 | /// | |
| 2378 | 2229 | /// ``` |
| 2379 | 2230 | #[doc = concat!("assert_eq!(3", stringify!($SelfT), ".wrapping_pow(4), 81);")] |
| 2380 | 2231 | /// assert_eq!(3i8.wrapping_pow(5), -13); |
| ... | ... | @@ -2432,8 +2283,6 @@ macro_rules! int_impl { |
| 2432 | 2283 | /// |
| 2433 | 2284 | /// # Examples |
| 2434 | 2285 | /// |
| 2435 | /// Basic usage: | |
| 2436 | /// | |
| 2437 | 2286 | /// ``` |
| 2438 | 2287 | #[doc = concat!("assert_eq!(5", stringify!($SelfT), ".overflowing_add(2), (7, false));")] |
| 2439 | 2288 | #[doc = concat!("assert_eq!(", stringify!($SelfT), "::MAX.overflowing_add(1), (", stringify!($SelfT), "::MIN, true));")] |
| ... | ... | @@ -2513,8 +2362,6 @@ macro_rules! int_impl { |
| 2513 | 2362 | /// |
| 2514 | 2363 | /// # Examples |
| 2515 | 2364 | /// |
| 2516 | /// Basic usage: | |
| 2517 | /// | |
| 2518 | 2365 | /// ``` |
| 2519 | 2366 | #[doc = concat!("assert_eq!(1", stringify!($SelfT), ".overflowing_add_unsigned(2), (3, false));")] |
| 2520 | 2367 | #[doc = concat!("assert_eq!((", stringify!($SelfT), "::MIN).overflowing_add_unsigned(", stringify!($UnsignedT), "::MAX), (", stringify!($SelfT), "::MAX, false));")] |
| ... | ... | @@ -2538,8 +2385,6 @@ macro_rules! int_impl { |
| 2538 | 2385 | /// |
| 2539 | 2386 | /// # Examples |
| 2540 | 2387 | /// |
| 2541 | /// Basic usage: | |
| 2542 | /// | |
| 2543 | 2388 | /// ``` |
| 2544 | 2389 | #[doc = concat!("assert_eq!(5", stringify!($SelfT), ".overflowing_sub(2), (3, false));")] |
| 2545 | 2390 | #[doc = concat!("assert_eq!(", stringify!($SelfT), "::MIN.overflowing_sub(1), (", stringify!($SelfT), "::MAX, true));")] |
| ... | ... | @@ -2620,8 +2465,6 @@ macro_rules! int_impl { |
| 2620 | 2465 | /// |
| 2621 | 2466 | /// # Examples |
| 2622 | 2467 | /// |
| 2623 | /// Basic usage: | |
| 2624 | /// | |
| 2625 | 2468 | /// ``` |
| 2626 | 2469 | #[doc = concat!("assert_eq!(1", stringify!($SelfT), ".overflowing_sub_unsigned(2), (-1, false));")] |
| 2627 | 2470 | #[doc = concat!("assert_eq!((", stringify!($SelfT), "::MAX).overflowing_sub_unsigned(", stringify!($UnsignedT), "::MAX), (", stringify!($SelfT), "::MIN, false));")] |
| ... | ... | @@ -2645,8 +2488,6 @@ macro_rules! int_impl { |
| 2645 | 2488 | /// |
| 2646 | 2489 | /// # Examples |
| 2647 | 2490 | /// |
| 2648 | /// Basic usage: | |
| 2649 | /// | |
| 2650 | 2491 | /// ``` |
| 2651 | 2492 | #[doc = concat!("assert_eq!(5", stringify!($SelfT), ".overflowing_mul(2), (10, false));")] |
| 2652 | 2493 | /// assert_eq!(1_000_000_000i32.overflowing_mul(10), (1410065408, true)); |
| ... | ... | @@ -2671,8 +2512,6 @@ macro_rules! int_impl { |
| 2671 | 2512 | /// |
| 2672 | 2513 | /// # Examples |
| 2673 | 2514 | /// |
| 2674 | /// Basic usage: | |
| 2675 | /// | |
| 2676 | 2515 | /// Please note that this example is shared between integer types. |
| 2677 | 2516 | /// Which explains why `i32` is used here. |
| 2678 | 2517 | /// |
| ... | ... | @@ -2704,8 +2543,6 @@ macro_rules! int_impl { |
| 2704 | 2543 | /// |
| 2705 | 2544 | /// # Examples |
| 2706 | 2545 | /// |
| 2707 | /// Basic usage: | |
| 2708 | /// | |
| 2709 | 2546 | /// Please note that this example is shared between integer types. |
| 2710 | 2547 | /// Which explains why `i32` is used here. |
| 2711 | 2548 | /// |
| ... | ... | @@ -2744,8 +2581,6 @@ macro_rules! int_impl { |
| 2744 | 2581 | /// |
| 2745 | 2582 | /// # Examples |
| 2746 | 2583 | /// |
| 2747 | /// Basic usage: | |
| 2748 | /// | |
| 2749 | 2584 | /// Please note that this example is shared between integer types. |
| 2750 | 2585 | /// Which explains why `i32` is used here. |
| 2751 | 2586 | /// |
| ... | ... | @@ -2780,8 +2615,6 @@ macro_rules! int_impl { |
| 2780 | 2615 | /// |
| 2781 | 2616 | /// # Examples |
| 2782 | 2617 | /// |
| 2783 | /// Basic usage: | |
| 2784 | /// | |
| 2785 | 2618 | /// ``` |
| 2786 | 2619 | #[doc = concat!("assert_eq!(5", stringify!($SelfT), ".overflowing_div(2), (2, false));")] |
| 2787 | 2620 | #[doc = concat!("assert_eq!(", stringify!($SelfT), "::MIN.overflowing_div(-1), (", stringify!($SelfT), "::MIN, true));")] |
| ... | ... | @@ -2811,8 +2644,6 @@ macro_rules! int_impl { |
| 2811 | 2644 | /// |
| 2812 | 2645 | /// # Examples |
| 2813 | 2646 | /// |
| 2814 | /// Basic usage: | |
| 2815 | /// | |
| 2816 | 2647 | /// ``` |
| 2817 | 2648 | #[doc = concat!("assert_eq!(5", stringify!($SelfT), ".overflowing_div_euclid(2), (2, false));")] |
| 2818 | 2649 | #[doc = concat!("assert_eq!(", stringify!($SelfT), "::MIN.overflowing_div_euclid(-1), (", stringify!($SelfT), "::MIN, true));")] |
| ... | ... | @@ -2842,8 +2673,6 @@ macro_rules! int_impl { |
| 2842 | 2673 | /// |
| 2843 | 2674 | /// # Examples |
| 2844 | 2675 | /// |
| 2845 | /// Basic usage: | |
| 2846 | /// | |
| 2847 | 2676 | /// ``` |
| 2848 | 2677 | #[doc = concat!("assert_eq!(5", stringify!($SelfT), ".overflowing_rem(2), (1, false));")] |
| 2849 | 2678 | #[doc = concat!("assert_eq!(", stringify!($SelfT), "::MIN.overflowing_rem(-1), (0, true));")] |
| ... | ... | @@ -2873,8 +2702,6 @@ macro_rules! int_impl { |
| 2873 | 2702 | /// |
| 2874 | 2703 | /// # Examples |
| 2875 | 2704 | /// |
| 2876 | /// Basic usage: | |
| 2877 | /// | |
| 2878 | 2705 | /// ``` |
| 2879 | 2706 | #[doc = concat!("assert_eq!(5", stringify!($SelfT), ".overflowing_rem_euclid(2), (1, false));")] |
| 2880 | 2707 | #[doc = concat!("assert_eq!(", stringify!($SelfT), "::MIN.overflowing_rem_euclid(-1), (0, true));")] |
| ... | ... | @@ -2902,8 +2729,6 @@ macro_rules! int_impl { |
| 2902 | 2729 | /// |
| 2903 | 2730 | /// # Examples |
| 2904 | 2731 | /// |
| 2905 | /// Basic usage: | |
| 2906 | /// | |
| 2907 | 2732 | /// ``` |
| 2908 | 2733 | #[doc = concat!("assert_eq!(2", stringify!($SelfT), ".overflowing_neg(), (-2, false));")] |
| 2909 | 2734 | #[doc = concat!("assert_eq!(", stringify!($SelfT), "::MIN.overflowing_neg(), (", stringify!($SelfT), "::MIN, true));")] |
| ... | ... | @@ -2930,8 +2755,6 @@ macro_rules! int_impl { |
| 2930 | 2755 | /// |
| 2931 | 2756 | /// # Examples |
| 2932 | 2757 | /// |
| 2933 | /// Basic usage: | |
| 2934 | /// | |
| 2935 | 2758 | /// ``` |
| 2936 | 2759 | #[doc = concat!("assert_eq!(0x1", stringify!($SelfT),".overflowing_shl(4), (0x10, false));")] |
| 2937 | 2760 | /// assert_eq!(0x1i32.overflowing_shl(36), (0x10, true)); |
| ... | ... | @@ -2954,8 +2777,6 @@ macro_rules! int_impl { |
| 2954 | 2777 | /// |
| 2955 | 2778 | /// # Examples |
| 2956 | 2779 | /// |
| 2957 | /// Basic usage: | |
| 2958 | /// | |
| 2959 | 2780 | /// ``` |
| 2960 | 2781 | #[doc = concat!("assert_eq!(0x10", stringify!($SelfT), ".overflowing_shr(4), (0x1, false));")] |
| 2961 | 2782 | /// assert_eq!(0x10i32.overflowing_shr(36), (0x1, true)); |
| ... | ... | @@ -2979,8 +2800,6 @@ macro_rules! int_impl { |
| 2979 | 2800 | /// |
| 2980 | 2801 | /// # Examples |
| 2981 | 2802 | /// |
| 2982 | /// Basic usage: | |
| 2983 | /// | |
| 2984 | 2803 | /// ``` |
| 2985 | 2804 | #[doc = concat!("assert_eq!(10", stringify!($SelfT), ".overflowing_abs(), (10, false));")] |
| 2986 | 2805 | #[doc = concat!("assert_eq!((-10", stringify!($SelfT), ").overflowing_abs(), (10, false));")] |
| ... | ... | @@ -3002,8 +2821,6 @@ macro_rules! int_impl { |
| 3002 | 2821 | /// |
| 3003 | 2822 | /// # Examples |
| 3004 | 2823 | /// |
| 3005 | /// Basic usage: | |
| 3006 | /// | |
| 3007 | 2824 | /// ``` |
| 3008 | 2825 | #[doc = concat!("assert_eq!(3", stringify!($SelfT), ".overflowing_pow(4), (81, false));")] |
| 3009 | 2826 | /// assert_eq!(3i8.overflowing_pow(5), (-13, true)); |
| ... | ... | @@ -3045,8 +2862,6 @@ macro_rules! int_impl { |
| 3045 | 2862 | /// |
| 3046 | 2863 | /// # Examples |
| 3047 | 2864 | /// |
| 3048 | /// Basic usage: | |
| 3049 | /// | |
| 3050 | 2865 | /// ``` |
| 3051 | 2866 | #[doc = concat!("let x: ", stringify!($SelfT), " = 2; // or any other integer type")] |
| 3052 | 2867 | /// |
| ... | ... | @@ -3106,7 +2921,6 @@ macro_rules! int_impl { |
| 3106 | 2921 | /// |
| 3107 | 2922 | /// # Examples |
| 3108 | 2923 | /// |
| 3109 | /// Basic usage: | |
| 3110 | 2924 | /// ``` |
| 3111 | 2925 | #[doc = concat!("assert_eq!(10", stringify!($SelfT), ".isqrt(), 3);")] |
| 3112 | 2926 | /// ``` |
| ... | ... | @@ -3142,8 +2956,6 @@ macro_rules! int_impl { |
| 3142 | 2956 | /// |
| 3143 | 2957 | /// # Examples |
| 3144 | 2958 | /// |
| 3145 | /// Basic usage: | |
| 3146 | /// | |
| 3147 | 2959 | /// ``` |
| 3148 | 2960 | #[doc = concat!("let a: ", stringify!($SelfT), " = 7; // or any other integer type")] |
| 3149 | 2961 | /// let b = 4; |
| ... | ... | @@ -3181,8 +2993,6 @@ macro_rules! int_impl { |
| 3181 | 2993 | /// |
| 3182 | 2994 | /// # Examples |
| 3183 | 2995 | /// |
| 3184 | /// Basic usage: | |
| 3185 | /// | |
| 3186 | 2996 | /// ``` |
| 3187 | 2997 | #[doc = concat!("let a: ", stringify!($SelfT), " = 7; // or any other integer type")] |
| 3188 | 2998 | /// let b = 4; |
| ... | ... | @@ -3230,8 +3040,6 @@ macro_rules! int_impl { |
| 3230 | 3040 | /// |
| 3231 | 3041 | /// # Examples |
| 3232 | 3042 | /// |
| 3233 | /// Basic usage: | |
| 3234 | /// | |
| 3235 | 3043 | /// ``` |
| 3236 | 3044 | /// #![feature(int_roundings)] |
| 3237 | 3045 | #[doc = concat!("let a: ", stringify!($SelfT)," = 8;")] |
| ... | ... | @@ -3274,8 +3082,6 @@ macro_rules! int_impl { |
| 3274 | 3082 | /// |
| 3275 | 3083 | /// # Examples |
| 3276 | 3084 | /// |
| 3277 | /// Basic usage: | |
| 3278 | /// | |
| 3279 | 3085 | /// ``` |
| 3280 | 3086 | /// #![feature(int_roundings)] |
| 3281 | 3087 | #[doc = concat!("let a: ", stringify!($SelfT)," = 8;")] |
| ... | ... | @@ -3321,8 +3127,6 @@ macro_rules! int_impl { |
| 3321 | 3127 | /// |
| 3322 | 3128 | /// # Examples |
| 3323 | 3129 | /// |
| 3324 | /// Basic usage: | |
| 3325 | /// | |
| 3326 | 3130 | /// ``` |
| 3327 | 3131 | /// #![feature(int_roundings)] |
| 3328 | 3132 | #[doc = concat!("assert_eq!(16_", stringify!($SelfT), ".next_multiple_of(8), 16);")] |
| ... | ... | @@ -3367,8 +3171,6 @@ macro_rules! int_impl { |
| 3367 | 3171 | /// |
| 3368 | 3172 | /// # Examples |
| 3369 | 3173 | /// |
| 3370 | /// Basic usage: | |
| 3371 | /// | |
| 3372 | 3174 | /// ``` |
| 3373 | 3175 | /// #![feature(int_roundings)] |
| 3374 | 3176 | #[doc = concat!("assert_eq!(16_", stringify!($SelfT), ".checked_next_multiple_of(8), Some(16));")] |
| ... | ... | @@ -3582,8 +3384,6 @@ macro_rules! int_impl { |
| 3582 | 3384 | /// |
| 3583 | 3385 | /// # Examples |
| 3584 | 3386 | /// |
| 3585 | /// Basic usage: | |
| 3586 | /// | |
| 3587 | 3387 | /// ``` |
| 3588 | 3388 | #[doc = concat!("assert_eq!(10", stringify!($SelfT), ".abs(), 10);")] |
| 3589 | 3389 | #[doc = concat!("assert_eq!((-10", stringify!($SelfT), ").abs(), 10);")] |
| ... | ... | @@ -3613,8 +3413,6 @@ macro_rules! int_impl { |
| 3613 | 3413 | /// |
| 3614 | 3414 | /// # Examples |
| 3615 | 3415 | /// |
| 3616 | /// Basic usage: | |
| 3617 | /// | |
| 3618 | 3416 | /// ``` |
| 3619 | 3417 | #[doc = concat!("assert_eq!(100", stringify!($SelfT), ".abs_diff(80), 20", stringify!($UnsignedT), ");")] |
| 3620 | 3418 | #[doc = concat!("assert_eq!(100", stringify!($SelfT), ".abs_diff(110), 10", stringify!($UnsignedT), ");")] |
| ... | ... | @@ -3656,8 +3454,6 @@ macro_rules! int_impl { |
| 3656 | 3454 | /// |
| 3657 | 3455 | /// # Examples |
| 3658 | 3456 | /// |
| 3659 | /// Basic usage: | |
| 3660 | /// | |
| 3661 | 3457 | /// ``` |
| 3662 | 3458 | #[doc = concat!("assert_eq!(10", stringify!($SelfT), ".signum(), 1);")] |
| 3663 | 3459 | #[doc = concat!("assert_eq!(0", stringify!($SelfT), ".signum(), 0);")] |
| ... | ... | @@ -3682,8 +3478,6 @@ macro_rules! int_impl { |
| 3682 | 3478 | /// |
| 3683 | 3479 | /// # Examples |
| 3684 | 3480 | /// |
| 3685 | /// Basic usage: | |
| 3686 | /// | |
| 3687 | 3481 | /// ``` |
| 3688 | 3482 | #[doc = concat!("assert!(10", stringify!($SelfT), ".is_positive());")] |
| 3689 | 3483 | #[doc = concat!("assert!(!(-10", stringify!($SelfT), ").is_positive());")] |
| ... | ... | @@ -3699,8 +3493,6 @@ macro_rules! int_impl { |
| 3699 | 3493 | /// |
| 3700 | 3494 | /// # Examples |
| 3701 | 3495 | /// |
| 3702 | /// Basic usage: | |
| 3703 | /// | |
| 3704 | 3496 | /// ``` |
| 3705 | 3497 | #[doc = concat!("assert!((-10", stringify!($SelfT), ").is_negative());")] |
| 3706 | 3498 | #[doc = concat!("assert!(!10", stringify!($SelfT), ".is_negative());")] |
library/core/src/num/mod.rs-4| ... | ... | @@ -1399,7 +1399,6 @@ macro_rules! from_str_int_impl { |
| 1399 | 1399 | /// |
| 1400 | 1400 | /// # Examples |
| 1401 | 1401 | /// |
| 1402 | /// Basic usage: | |
| 1403 | 1402 | /// ``` |
| 1404 | 1403 | /// use std::str::FromStr; |
| 1405 | 1404 | /// |
| ... | ... | @@ -1445,7 +1444,6 @@ macro_rules! from_str_int_impl { |
| 1445 | 1444 | /// |
| 1446 | 1445 | /// # Examples |
| 1447 | 1446 | /// |
| 1448 | /// Basic usage: | |
| 1449 | 1447 | /// ``` |
| 1450 | 1448 | #[doc = concat!("assert_eq!(", stringify!($int_ty), "::from_str_radix(\"A\", 16), Ok(10));")] |
| 1451 | 1449 | /// ``` |
| ... | ... | @@ -1478,7 +1476,6 @@ macro_rules! from_str_int_impl { |
| 1478 | 1476 | /// |
| 1479 | 1477 | /// # Examples |
| 1480 | 1478 | /// |
| 1481 | /// Basic usage: | |
| 1482 | 1479 | /// ``` |
| 1483 | 1480 | /// #![feature(int_from_ascii)] |
| 1484 | 1481 | /// |
| ... | ... | @@ -1523,7 +1520,6 @@ macro_rules! from_str_int_impl { |
| 1523 | 1520 | /// |
| 1524 | 1521 | /// # Examples |
| 1525 | 1522 | /// |
| 1526 | /// Basic usage: | |
| 1527 | 1523 | /// ``` |
| 1528 | 1524 | /// #![feature(int_from_ascii)] |
| 1529 | 1525 | /// |
library/core/src/num/saturating.rs-46| ... | ... | @@ -300,8 +300,6 @@ macro_rules! saturating_impl { |
| 300 | 300 | |
| 301 | 301 | /// # Examples |
| 302 | 302 | /// |
| 303 | /// Basic usage: | |
| 304 | /// | |
| 305 | 303 | /// ``` |
| 306 | 304 | /// use std::num::Saturating; |
| 307 | 305 | /// |
| ... | ... | @@ -490,8 +488,6 @@ macro_rules! saturating_int_impl { |
| 490 | 488 | /// |
| 491 | 489 | /// # Examples |
| 492 | 490 | /// |
| 493 | /// Basic usage: | |
| 494 | /// | |
| 495 | 491 | /// ``` |
| 496 | 492 | /// use std::num::Saturating; |
| 497 | 493 | /// |
| ... | ... | @@ -504,8 +500,6 @@ macro_rules! saturating_int_impl { |
| 504 | 500 | /// |
| 505 | 501 | /// # Examples |
| 506 | 502 | /// |
| 507 | /// Basic usage: | |
| 508 | /// | |
| 509 | 503 | /// ``` |
| 510 | 504 | /// use std::num::Saturating; |
| 511 | 505 | /// |
| ... | ... | @@ -518,8 +512,6 @@ macro_rules! saturating_int_impl { |
| 518 | 512 | /// |
| 519 | 513 | /// # Examples |
| 520 | 514 | /// |
| 521 | /// Basic usage: | |
| 522 | /// | |
| 523 | 515 | /// ``` |
| 524 | 516 | /// use std::num::Saturating; |
| 525 | 517 | /// |
| ... | ... | @@ -532,8 +524,6 @@ macro_rules! saturating_int_impl { |
| 532 | 524 | /// |
| 533 | 525 | /// # Examples |
| 534 | 526 | /// |
| 535 | /// Basic usage: | |
| 536 | /// | |
| 537 | 527 | /// ``` |
| 538 | 528 | /// use std::num::Saturating; |
| 539 | 529 | /// |
| ... | ... | @@ -556,8 +546,6 @@ macro_rules! saturating_int_impl { |
| 556 | 546 | /// |
| 557 | 547 | /// # Examples |
| 558 | 548 | /// |
| 559 | /// Basic usage: | |
| 560 | /// | |
| 561 | 549 | /// ``` |
| 562 | 550 | /// use std::num::Saturating; |
| 563 | 551 | /// |
| ... | ... | @@ -576,8 +564,6 @@ macro_rules! saturating_int_impl { |
| 576 | 564 | /// |
| 577 | 565 | /// # Examples |
| 578 | 566 | /// |
| 579 | /// Basic usage: | |
| 580 | /// | |
| 581 | 567 | /// ``` |
| 582 | 568 | /// use std::num::Saturating; |
| 583 | 569 | /// |
| ... | ... | @@ -603,8 +589,6 @@ macro_rules! saturating_int_impl { |
| 603 | 589 | /// |
| 604 | 590 | /// # Examples |
| 605 | 591 | /// |
| 606 | /// Basic usage: | |
| 607 | /// | |
| 608 | 592 | /// ``` |
| 609 | 593 | /// use std::num::Saturating; |
| 610 | 594 | /// |
| ... | ... | @@ -631,8 +615,6 @@ macro_rules! saturating_int_impl { |
| 631 | 615 | /// |
| 632 | 616 | /// # Examples |
| 633 | 617 | /// |
| 634 | /// Basic usage: | |
| 635 | /// | |
| 636 | 618 | /// ``` |
| 637 | 619 | /// use std::num::Saturating; |
| 638 | 620 | /// |
| ... | ... | @@ -654,8 +636,6 @@ macro_rules! saturating_int_impl { |
| 654 | 636 | /// |
| 655 | 637 | /// # Examples |
| 656 | 638 | /// |
| 657 | /// Basic usage: | |
| 658 | /// | |
| 659 | 639 | /// ``` |
| 660 | 640 | /// use std::num::Saturating; |
| 661 | 641 | /// |
| ... | ... | @@ -683,8 +663,6 @@ macro_rules! saturating_int_impl { |
| 683 | 663 | /// Please note that this example is shared between integer types. |
| 684 | 664 | /// Which explains why `i16` is used here. |
| 685 | 665 | /// |
| 686 | /// Basic usage: | |
| 687 | /// | |
| 688 | 666 | /// ``` |
| 689 | 667 | /// use std::num::Saturating; |
| 690 | 668 | /// |
| ... | ... | @@ -712,8 +690,6 @@ macro_rules! saturating_int_impl { |
| 712 | 690 | /// |
| 713 | 691 | /// # Examples |
| 714 | 692 | /// |
| 715 | /// Basic usage: | |
| 716 | /// | |
| 717 | 693 | /// ``` |
| 718 | 694 | /// use std::num::Saturating; |
| 719 | 695 | /// |
| ... | ... | @@ -740,8 +716,6 @@ macro_rules! saturating_int_impl { |
| 740 | 716 | /// |
| 741 | 717 | /// # Examples |
| 742 | 718 | /// |
| 743 | /// Basic usage: | |
| 744 | /// | |
| 745 | 719 | /// ``` |
| 746 | 720 | /// use std::num::Saturating; |
| 747 | 721 | /// |
| ... | ... | @@ -768,8 +742,6 @@ macro_rules! saturating_int_impl { |
| 768 | 742 | /// |
| 769 | 743 | /// # Examples |
| 770 | 744 | /// |
| 771 | /// Basic usage: | |
| 772 | /// | |
| 773 | 745 | /// ``` |
| 774 | 746 | /// use std::num::Saturating; |
| 775 | 747 | /// |
| ... | ... | @@ -797,8 +769,6 @@ macro_rules! saturating_int_impl { |
| 797 | 769 | /// |
| 798 | 770 | /// # Examples |
| 799 | 771 | /// |
| 800 | /// Basic usage: | |
| 801 | /// | |
| 802 | 772 | /// ``` |
| 803 | 773 | /// use std::num::Saturating; |
| 804 | 774 | /// |
| ... | ... | @@ -823,8 +793,6 @@ macro_rules! saturating_int_impl { |
| 823 | 793 | /// |
| 824 | 794 | /// # Examples |
| 825 | 795 | /// |
| 826 | /// Basic usage: | |
| 827 | /// | |
| 828 | 796 | /// ``` |
| 829 | 797 | /// use std::num::Saturating; |
| 830 | 798 | /// |
| ... | ... | @@ -860,8 +828,6 @@ macro_rules! saturating_int_impl_signed { |
| 860 | 828 | /// |
| 861 | 829 | /// # Examples |
| 862 | 830 | /// |
| 863 | /// Basic usage: | |
| 864 | /// | |
| 865 | 831 | /// ``` |
| 866 | 832 | /// use std::num::Saturating; |
| 867 | 833 | /// |
| ... | ... | @@ -883,8 +849,6 @@ macro_rules! saturating_int_impl_signed { |
| 883 | 849 | /// |
| 884 | 850 | /// # Examples |
| 885 | 851 | /// |
| 886 | /// Basic usage: | |
| 887 | /// | |
| 888 | 852 | /// ``` |
| 889 | 853 | /// use std::num::Saturating; |
| 890 | 854 | /// |
| ... | ... | @@ -911,8 +875,6 @@ macro_rules! saturating_int_impl_signed { |
| 911 | 875 | /// |
| 912 | 876 | /// # Examples |
| 913 | 877 | /// |
| 914 | /// Basic usage: | |
| 915 | /// | |
| 916 | 878 | /// ``` |
| 917 | 879 | /// use std::num::Saturating; |
| 918 | 880 | /// |
| ... | ... | @@ -934,8 +896,6 @@ macro_rules! saturating_int_impl_signed { |
| 934 | 896 | /// |
| 935 | 897 | /// # Examples |
| 936 | 898 | /// |
| 937 | /// Basic usage: | |
| 938 | /// | |
| 939 | 899 | /// ``` |
| 940 | 900 | /// use std::num::Saturating; |
| 941 | 901 | /// |
| ... | ... | @@ -955,8 +915,6 @@ macro_rules! saturating_int_impl_signed { |
| 955 | 915 | /// |
| 956 | 916 | /// # Examples |
| 957 | 917 | /// |
| 958 | /// Basic usage: | |
| 959 | /// | |
| 960 | 918 | /// ``` |
| 961 | 919 | /// use std::num::Saturating; |
| 962 | 920 | /// |
| ... | ... | @@ -994,8 +952,6 @@ macro_rules! saturating_int_impl_unsigned { |
| 994 | 952 | /// |
| 995 | 953 | /// # Examples |
| 996 | 954 | /// |
| 997 | /// Basic usage: | |
| 998 | /// | |
| 999 | 955 | /// ``` |
| 1000 | 956 | /// use std::num::Saturating; |
| 1001 | 957 | /// |
| ... | ... | @@ -1016,8 +972,6 @@ macro_rules! saturating_int_impl_unsigned { |
| 1016 | 972 | /// |
| 1017 | 973 | /// # Examples |
| 1018 | 974 | /// |
| 1019 | /// Basic usage: | |
| 1020 | /// | |
| 1021 | 975 | /// ``` |
| 1022 | 976 | /// use std::num::Saturating; |
| 1023 | 977 | /// |
library/core/src/num/uint_macros.rs-197| ... | ... | @@ -27,8 +27,6 @@ macro_rules! uint_impl { |
| 27 | 27 | /// |
| 28 | 28 | /// # Examples |
| 29 | 29 | /// |
| 30 | /// Basic usage: | |
| 31 | /// | |
| 32 | 30 | /// ``` |
| 33 | 31 | #[doc = concat!("assert_eq!(", stringify!($SelfT), "::MIN, 0);")] |
| 34 | 32 | /// ``` |
| ... | ... | @@ -40,8 +38,6 @@ macro_rules! uint_impl { |
| 40 | 38 | /// |
| 41 | 39 | /// # Examples |
| 42 | 40 | /// |
| 43 | /// Basic usage: | |
| 44 | /// | |
| 45 | 41 | /// ``` |
| 46 | 42 | #[doc = concat!("assert_eq!(", stringify!($SelfT), "::MAX, ", stringify!($MaxV), ");")] |
| 47 | 43 | /// ``` |
| ... | ... | @@ -62,8 +58,6 @@ macro_rules! uint_impl { |
| 62 | 58 | /// |
| 63 | 59 | /// # Examples |
| 64 | 60 | /// |
| 65 | /// Basic usage: | |
| 66 | /// | |
| 67 | 61 | /// ``` |
| 68 | 62 | #[doc = concat!("let n = 0b01001100", stringify!($SelfT), ";")] |
| 69 | 63 | /// assert_eq!(n.count_ones(), 3); |
| ... | ... | @@ -89,8 +83,6 @@ macro_rules! uint_impl { |
| 89 | 83 | /// |
| 90 | 84 | /// # Examples |
| 91 | 85 | /// |
| 92 | /// Basic usage: | |
| 93 | /// | |
| 94 | 86 | /// ``` |
| 95 | 87 | #[doc = concat!("let zero = 0", stringify!($SelfT), ";")] |
| 96 | 88 | #[doc = concat!("assert_eq!(zero.count_zeros(), ", stringify!($BITS), ");")] |
| ... | ... | @@ -114,8 +106,6 @@ macro_rules! uint_impl { |
| 114 | 106 | /// |
| 115 | 107 | /// # Examples |
| 116 | 108 | /// |
| 117 | /// Basic usage: | |
| 118 | /// | |
| 119 | 109 | /// ``` |
| 120 | 110 | #[doc = concat!("let n = ", stringify!($SelfT), "::MAX >> 2;")] |
| 121 | 111 | /// assert_eq!(n.leading_zeros(), 2); |
| ... | ... | @@ -141,8 +131,6 @@ macro_rules! uint_impl { |
| 141 | 131 | /// |
| 142 | 132 | /// # Examples |
| 143 | 133 | /// |
| 144 | /// Basic usage: | |
| 145 | /// | |
| 146 | 134 | /// ``` |
| 147 | 135 | #[doc = concat!("let n = 0b0101000", stringify!($SelfT), ";")] |
| 148 | 136 | /// assert_eq!(n.trailing_zeros(), 3); |
| ... | ... | @@ -166,8 +154,6 @@ macro_rules! uint_impl { |
| 166 | 154 | /// |
| 167 | 155 | /// # Examples |
| 168 | 156 | /// |
| 169 | /// Basic usage: | |
| 170 | /// | |
| 171 | 157 | /// ``` |
| 172 | 158 | #[doc = concat!("let n = !(", stringify!($SelfT), "::MAX >> 2);")] |
| 173 | 159 | /// assert_eq!(n.leading_ones(), 2); |
| ... | ... | @@ -192,8 +178,6 @@ macro_rules! uint_impl { |
| 192 | 178 | /// |
| 193 | 179 | /// # Examples |
| 194 | 180 | /// |
| 195 | /// Basic usage: | |
| 196 | /// | |
| 197 | 181 | /// ``` |
| 198 | 182 | #[doc = concat!("let n = 0b1010111", stringify!($SelfT), ";")] |
| 199 | 183 | /// assert_eq!(n.trailing_ones(), 3); |
| ... | ... | @@ -219,8 +203,6 @@ macro_rules! uint_impl { |
| 219 | 203 | /// |
| 220 | 204 | /// # Examples |
| 221 | 205 | /// |
| 222 | /// Basic usage: | |
| 223 | /// | |
| 224 | 206 | /// ``` |
| 225 | 207 | /// #![feature(uint_bit_width)] |
| 226 | 208 | /// |
| ... | ... | @@ -242,8 +224,6 @@ macro_rules! uint_impl { |
| 242 | 224 | /// |
| 243 | 225 | /// # Examples |
| 244 | 226 | /// |
| 245 | /// Basic usage: | |
| 246 | /// | |
| 247 | 227 | /// ``` |
| 248 | 228 | /// #![feature(isolate_most_least_significant_one)] |
| 249 | 229 | /// |
| ... | ... | @@ -265,8 +245,6 @@ macro_rules! uint_impl { |
| 265 | 245 | /// |
| 266 | 246 | /// # Examples |
| 267 | 247 | /// |
| 268 | /// Basic usage: | |
| 269 | /// | |
| 270 | 248 | /// ``` |
| 271 | 249 | /// #![feature(isolate_most_least_significant_one)] |
| 272 | 250 | /// |
| ... | ... | @@ -290,8 +268,6 @@ macro_rules! uint_impl { |
| 290 | 268 | /// |
| 291 | 269 | /// # Examples |
| 292 | 270 | /// |
| 293 | /// Basic usage: | |
| 294 | /// | |
| 295 | 271 | /// ``` |
| 296 | 272 | #[doc = concat!("let n = ", stringify!($SelfT), "::MAX;")] |
| 297 | 273 | /// |
| ... | ... | @@ -313,8 +289,6 @@ macro_rules! uint_impl { |
| 313 | 289 | /// |
| 314 | 290 | /// # Examples |
| 315 | 291 | /// |
| 316 | /// Basic usage: | |
| 317 | /// | |
| 318 | 292 | /// ``` |
| 319 | 293 | #[doc = concat!("let n = ", $rot_op, stringify!($SelfT), ";")] |
| 320 | 294 | #[doc = concat!("let m = ", $rot_result, ";")] |
| ... | ... | @@ -338,8 +312,6 @@ macro_rules! uint_impl { |
| 338 | 312 | /// |
| 339 | 313 | /// # Examples |
| 340 | 314 | /// |
| 341 | /// Basic usage: | |
| 342 | /// | |
| 343 | 315 | /// ``` |
| 344 | 316 | #[doc = concat!("let n = ", $rot_result, stringify!($SelfT), ";")] |
| 345 | 317 | #[doc = concat!("let m = ", $rot_op, ";")] |
| ... | ... | @@ -359,8 +331,6 @@ macro_rules! uint_impl { |
| 359 | 331 | /// |
| 360 | 332 | /// # Examples |
| 361 | 333 | /// |
| 362 | /// Basic usage: | |
| 363 | /// | |
| 364 | 334 | /// ``` |
| 365 | 335 | #[doc = concat!("let n = ", $swap_op, stringify!($SelfT), ";")] |
| 366 | 336 | /// let m = n.swap_bytes(); |
| ... | ... | @@ -381,8 +351,6 @@ macro_rules! uint_impl { |
| 381 | 351 | /// |
| 382 | 352 | /// # Examples |
| 383 | 353 | /// |
| 384 | /// Basic usage: | |
| 385 | /// | |
| 386 | 354 | /// ``` |
| 387 | 355 | #[doc = concat!("let n = ", $swap_op, stringify!($SelfT), ";")] |
| 388 | 356 | /// let m = n.reverse_bits(); |
| ... | ... | @@ -406,8 +374,6 @@ macro_rules! uint_impl { |
| 406 | 374 | /// |
| 407 | 375 | /// # Examples |
| 408 | 376 | /// |
| 409 | /// Basic usage: | |
| 410 | /// | |
| 411 | 377 | /// ``` |
| 412 | 378 | #[doc = concat!("let n = 0x1A", stringify!($SelfT), ";")] |
| 413 | 379 | /// |
| ... | ... | @@ -439,8 +405,6 @@ macro_rules! uint_impl { |
| 439 | 405 | /// |
| 440 | 406 | /// # Examples |
| 441 | 407 | /// |
| 442 | /// Basic usage: | |
| 443 | /// | |
| 444 | 408 | /// ``` |
| 445 | 409 | #[doc = concat!("let n = 0x1A", stringify!($SelfT), ";")] |
| 446 | 410 | /// |
| ... | ... | @@ -472,8 +436,6 @@ macro_rules! uint_impl { |
| 472 | 436 | /// |
| 473 | 437 | /// # Examples |
| 474 | 438 | /// |
| 475 | /// Basic usage: | |
| 476 | /// | |
| 477 | 439 | /// ``` |
| 478 | 440 | #[doc = concat!("let n = 0x1A", stringify!($SelfT), ";")] |
| 479 | 441 | /// |
| ... | ... | @@ -506,8 +468,6 @@ macro_rules! uint_impl { |
| 506 | 468 | /// |
| 507 | 469 | /// # Examples |
| 508 | 470 | /// |
| 509 | /// Basic usage: | |
| 510 | /// | |
| 511 | 471 | /// ``` |
| 512 | 472 | #[doc = concat!("let n = 0x1A", stringify!($SelfT), ";")] |
| 513 | 473 | /// |
| ... | ... | @@ -538,8 +498,6 @@ macro_rules! uint_impl { |
| 538 | 498 | /// |
| 539 | 499 | /// # Examples |
| 540 | 500 | /// |
| 541 | /// Basic usage: | |
| 542 | /// | |
| 543 | 501 | /// ``` |
| 544 | 502 | #[doc = concat!( |
| 545 | 503 | "assert_eq!((", stringify!($SelfT), "::MAX - 2).checked_add(1), ", |
| ... | ... | @@ -579,8 +537,6 @@ macro_rules! uint_impl { |
| 579 | 537 | /// |
| 580 | 538 | /// # Examples |
| 581 | 539 | /// |
| 582 | /// Basic usage: | |
| 583 | /// | |
| 584 | 540 | /// ``` |
| 585 | 541 | /// #![feature(strict_overflow_ops)] |
| 586 | 542 | #[doc = concat!("assert_eq!((", stringify!($SelfT), "::MAX - 2).strict_add(1), ", stringify!($SelfT), "::MAX - 1);")] |
| ... | ... | @@ -647,8 +603,6 @@ macro_rules! uint_impl { |
| 647 | 603 | /// |
| 648 | 604 | /// # Examples |
| 649 | 605 | /// |
| 650 | /// Basic usage: | |
| 651 | /// | |
| 652 | 606 | /// ``` |
| 653 | 607 | #[doc = concat!("assert_eq!(1", stringify!($SelfT), ".checked_add_signed(2), Some(3));")] |
| 654 | 608 | #[doc = concat!("assert_eq!(1", stringify!($SelfT), ".checked_add_signed(-2), None);")] |
| ... | ... | @@ -675,8 +629,6 @@ macro_rules! uint_impl { |
| 675 | 629 | /// |
| 676 | 630 | /// # Examples |
| 677 | 631 | /// |
| 678 | /// Basic usage: | |
| 679 | /// | |
| 680 | 632 | /// ``` |
| 681 | 633 | /// #![feature(strict_overflow_ops)] |
| 682 | 634 | #[doc = concat!("assert_eq!(1", stringify!($SelfT), ".strict_add_signed(2), 3);")] |
| ... | ... | @@ -708,8 +660,6 @@ macro_rules! uint_impl { |
| 708 | 660 | /// |
| 709 | 661 | /// # Examples |
| 710 | 662 | /// |
| 711 | /// Basic usage: | |
| 712 | /// | |
| 713 | 663 | /// ``` |
| 714 | 664 | #[doc = concat!("assert_eq!(1", stringify!($SelfT), ".checked_sub(1), Some(0));")] |
| 715 | 665 | #[doc = concat!("assert_eq!(0", stringify!($SelfT), ".checked_sub(1), None);")] |
| ... | ... | @@ -744,8 +694,6 @@ macro_rules! uint_impl { |
| 744 | 694 | /// |
| 745 | 695 | /// # Examples |
| 746 | 696 | /// |
| 747 | /// Basic usage: | |
| 748 | /// | |
| 749 | 697 | /// ``` |
| 750 | 698 | /// #![feature(strict_overflow_ops)] |
| 751 | 699 | #[doc = concat!("assert_eq!(1", stringify!($SelfT), ".strict_sub(1), 0);")] |
| ... | ... | @@ -837,8 +785,6 @@ macro_rules! uint_impl { |
| 837 | 785 | /// |
| 838 | 786 | /// # Examples |
| 839 | 787 | /// |
| 840 | /// Basic usage: | |
| 841 | /// | |
| 842 | 788 | /// ``` |
| 843 | 789 | /// #![feature(mixed_integer_ops_unsigned_sub)] |
| 844 | 790 | #[doc = concat!("assert_eq!(1", stringify!($SelfT), ".checked_sub_signed(2), None);")] |
| ... | ... | @@ -866,8 +812,6 @@ macro_rules! uint_impl { |
| 866 | 812 | /// |
| 867 | 813 | /// # Examples |
| 868 | 814 | /// |
| 869 | /// Basic usage: | |
| 870 | /// | |
| 871 | 815 | /// ``` |
| 872 | 816 | /// #![feature(unsigned_signed_diff)] |
| 873 | 817 | #[doc = concat!("assert_eq!(10", stringify!($SelfT), ".checked_signed_diff(2), Some(8));")] |
| ... | ... | @@ -925,8 +869,6 @@ macro_rules! uint_impl { |
| 925 | 869 | /// |
| 926 | 870 | /// # Examples |
| 927 | 871 | /// |
| 928 | /// Basic usage: | |
| 929 | /// | |
| 930 | 872 | /// ``` |
| 931 | 873 | #[doc = concat!("assert_eq!(5", stringify!($SelfT), ".checked_mul(1), Some(5));")] |
| 932 | 874 | #[doc = concat!("assert_eq!(", stringify!($SelfT), "::MAX.checked_mul(2), None);")] |
| ... | ... | @@ -952,8 +894,6 @@ macro_rules! uint_impl { |
| 952 | 894 | /// |
| 953 | 895 | /// # Examples |
| 954 | 896 | /// |
| 955 | /// Basic usage: | |
| 956 | /// | |
| 957 | 897 | /// ``` |
| 958 | 898 | /// #![feature(strict_overflow_ops)] |
| 959 | 899 | #[doc = concat!("assert_eq!(5", stringify!($SelfT), ".strict_mul(1), 5);")] |
| ... | ... | @@ -1020,8 +960,6 @@ macro_rules! uint_impl { |
| 1020 | 960 | /// |
| 1021 | 961 | /// # Examples |
| 1022 | 962 | /// |
| 1023 | /// Basic usage: | |
| 1024 | /// | |
| 1025 | 963 | /// ``` |
| 1026 | 964 | #[doc = concat!("assert_eq!(128", stringify!($SelfT), ".checked_div(2), Some(64));")] |
| 1027 | 965 | #[doc = concat!("assert_eq!(1", stringify!($SelfT), ".checked_div(0), None);")] |
| ... | ... | @@ -1053,8 +991,6 @@ macro_rules! uint_impl { |
| 1053 | 991 | /// |
| 1054 | 992 | /// # Examples |
| 1055 | 993 | /// |
| 1056 | /// Basic usage: | |
| 1057 | /// | |
| 1058 | 994 | /// ``` |
| 1059 | 995 | /// #![feature(strict_overflow_ops)] |
| 1060 | 996 | #[doc = concat!("assert_eq!(100", stringify!($SelfT), ".strict_div(10), 10);")] |
| ... | ... | @@ -1080,8 +1016,6 @@ macro_rules! uint_impl { |
| 1080 | 1016 | /// |
| 1081 | 1017 | /// # Examples |
| 1082 | 1018 | /// |
| 1083 | /// Basic usage: | |
| 1084 | /// | |
| 1085 | 1019 | /// ``` |
| 1086 | 1020 | #[doc = concat!("assert_eq!(128", stringify!($SelfT), ".checked_div_euclid(2), Some(64));")] |
| 1087 | 1021 | #[doc = concat!("assert_eq!(1", stringify!($SelfT), ".checked_div_euclid(0), None);")] |
| ... | ... | @@ -1113,8 +1047,6 @@ macro_rules! uint_impl { |
| 1113 | 1047 | /// |
| 1114 | 1048 | /// # Examples |
| 1115 | 1049 | /// |
| 1116 | /// Basic usage: | |
| 1117 | /// | |
| 1118 | 1050 | /// ``` |
| 1119 | 1051 | /// #![feature(strict_overflow_ops)] |
| 1120 | 1052 | #[doc = concat!("assert_eq!(100", stringify!($SelfT), ".strict_div_euclid(10), 10);")] |
| ... | ... | @@ -1142,8 +1074,6 @@ macro_rules! uint_impl { |
| 1142 | 1074 | /// |
| 1143 | 1075 | /// # Examples |
| 1144 | 1076 | /// |
| 1145 | /// Basic usage: | |
| 1146 | /// | |
| 1147 | 1077 | /// ``` |
| 1148 | 1078 | /// #![feature(exact_div)] |
| 1149 | 1079 | #[doc = concat!("assert_eq!(64", stringify!($SelfT), ".exact_div(2), 32);")] |
| ... | ... | @@ -1184,8 +1114,6 @@ macro_rules! uint_impl { |
| 1184 | 1114 | /// |
| 1185 | 1115 | /// # Examples |
| 1186 | 1116 | /// |
| 1187 | /// Basic usage: | |
| 1188 | /// | |
| 1189 | 1117 | /// ``` |
| 1190 | 1118 | /// #![feature(exact_div)] |
| 1191 | 1119 | #[doc = concat!("assert_eq!(64", stringify!($SelfT), ".exact_div(2), 32);")] |
| ... | ... | @@ -1241,8 +1169,6 @@ macro_rules! uint_impl { |
| 1241 | 1169 | /// |
| 1242 | 1170 | /// # Examples |
| 1243 | 1171 | /// |
| 1244 | /// Basic usage: | |
| 1245 | /// | |
| 1246 | 1172 | /// ``` |
| 1247 | 1173 | #[doc = concat!("assert_eq!(5", stringify!($SelfT), ".checked_rem(2), Some(1));")] |
| 1248 | 1174 | #[doc = concat!("assert_eq!(5", stringify!($SelfT), ".checked_rem(0), None);")] |
| ... | ... | @@ -1275,8 +1201,6 @@ macro_rules! uint_impl { |
| 1275 | 1201 | /// |
| 1276 | 1202 | /// # Examples |
| 1277 | 1203 | /// |
| 1278 | /// Basic usage: | |
| 1279 | /// | |
| 1280 | 1204 | /// ``` |
| 1281 | 1205 | /// #![feature(strict_overflow_ops)] |
| 1282 | 1206 | #[doc = concat!("assert_eq!(100", stringify!($SelfT), ".strict_rem(10), 0);")] |
| ... | ... | @@ -1302,8 +1226,6 @@ macro_rules! uint_impl { |
| 1302 | 1226 | /// |
| 1303 | 1227 | /// # Examples |
| 1304 | 1228 | /// |
| 1305 | /// Basic usage: | |
| 1306 | /// | |
| 1307 | 1229 | /// ``` |
| 1308 | 1230 | #[doc = concat!("assert_eq!(5", stringify!($SelfT), ".checked_rem_euclid(2), Some(1));")] |
| 1309 | 1231 | #[doc = concat!("assert_eq!(5", stringify!($SelfT), ".checked_rem_euclid(0), None);")] |
| ... | ... | @@ -1336,8 +1258,6 @@ macro_rules! uint_impl { |
| 1336 | 1258 | /// |
| 1337 | 1259 | /// # Examples |
| 1338 | 1260 | /// |
| 1339 | /// Basic usage: | |
| 1340 | /// | |
| 1341 | 1261 | /// ``` |
| 1342 | 1262 | /// #![feature(strict_overflow_ops)] |
| 1343 | 1263 | #[doc = concat!("assert_eq!(100", stringify!($SelfT), ".strict_rem_euclid(10), 0);")] |
| ... | ... | @@ -1583,8 +1503,6 @@ macro_rules! uint_impl { |
| 1583 | 1503 | /// |
| 1584 | 1504 | /// # Examples |
| 1585 | 1505 | /// |
| 1586 | /// Basic usage: | |
| 1587 | /// | |
| 1588 | 1506 | /// ``` |
| 1589 | 1507 | #[doc = concat!("assert_eq!(0", stringify!($SelfT), ".checked_neg(), Some(0));")] |
| 1590 | 1508 | #[doc = concat!("assert_eq!(1", stringify!($SelfT), ".checked_neg(), None);")] |
| ... | ... | @@ -1612,8 +1530,6 @@ macro_rules! uint_impl { |
| 1612 | 1530 | /// |
| 1613 | 1531 | /// # Examples |
| 1614 | 1532 | /// |
| 1615 | /// Basic usage: | |
| 1616 | /// | |
| 1617 | 1533 | /// ``` |
| 1618 | 1534 | /// #![feature(strict_overflow_ops)] |
| 1619 | 1535 | #[doc = concat!("assert_eq!(0", stringify!($SelfT), ".strict_neg(), 0);")] |
| ... | ... | @@ -1640,8 +1556,6 @@ macro_rules! uint_impl { |
| 1640 | 1556 | /// |
| 1641 | 1557 | /// # Examples |
| 1642 | 1558 | /// |
| 1643 | /// Basic usage: | |
| 1644 | /// | |
| 1645 | 1559 | /// ``` |
| 1646 | 1560 | #[doc = concat!("assert_eq!(0x1", stringify!($SelfT), ".checked_shl(4), Some(0x10));")] |
| 1647 | 1561 | #[doc = concat!("assert_eq!(0x10", stringify!($SelfT), ".checked_shl(129), None);")] |
| ... | ... | @@ -1673,8 +1587,6 @@ macro_rules! uint_impl { |
| 1673 | 1587 | /// |
| 1674 | 1588 | /// # Examples |
| 1675 | 1589 | /// |
| 1676 | /// Basic usage: | |
| 1677 | /// | |
| 1678 | 1590 | /// ``` |
| 1679 | 1591 | /// #![feature(strict_overflow_ops)] |
| 1680 | 1592 | #[doc = concat!("assert_eq!(0x1", stringify!($SelfT), ".strict_shl(4), 0x10);")] |
| ... | ... | @@ -1737,7 +1649,6 @@ macro_rules! uint_impl { |
| 1737 | 1649 | /// |
| 1738 | 1650 | /// # Examples |
| 1739 | 1651 | /// |
| 1740 | /// Basic usage: | |
| 1741 | 1652 | /// ``` |
| 1742 | 1653 | #[doc = concat!("assert_eq!(0x1", stringify!($SelfT), ".unbounded_shl(4), 0x10);")] |
| 1743 | 1654 | #[doc = concat!("assert_eq!(0x1", stringify!($SelfT), ".unbounded_shl(129), 0);")] |
| ... | ... | @@ -1762,8 +1673,6 @@ macro_rules! uint_impl { |
| 1762 | 1673 | /// |
| 1763 | 1674 | /// # Examples |
| 1764 | 1675 | /// |
| 1765 | /// Basic usage: | |
| 1766 | /// | |
| 1767 | 1676 | /// ``` |
| 1768 | 1677 | #[doc = concat!("assert_eq!(0x10", stringify!($SelfT), ".checked_shr(4), Some(0x1));")] |
| 1769 | 1678 | #[doc = concat!("assert_eq!(0x10", stringify!($SelfT), ".checked_shr(129), None);")] |
| ... | ... | @@ -1794,8 +1703,6 @@ macro_rules! uint_impl { |
| 1794 | 1703 | /// |
| 1795 | 1704 | /// # Examples |
| 1796 | 1705 | /// |
| 1797 | /// Basic usage: | |
| 1798 | /// | |
| 1799 | 1706 | /// ``` |
| 1800 | 1707 | /// #![feature(strict_overflow_ops)] |
| 1801 | 1708 | #[doc = concat!("assert_eq!(0x10", stringify!($SelfT), ".strict_shr(4), 0x1);")] |
| ... | ... | @@ -1858,7 +1765,6 @@ macro_rules! uint_impl { |
| 1858 | 1765 | /// |
| 1859 | 1766 | /// # Examples |
| 1860 | 1767 | /// |
| 1861 | /// Basic usage: | |
| 1862 | 1768 | /// ``` |
| 1863 | 1769 | #[doc = concat!("assert_eq!(0x10", stringify!($SelfT), ".unbounded_shr(4), 0x1);")] |
| 1864 | 1770 | #[doc = concat!("assert_eq!(0x10", stringify!($SelfT), ".unbounded_shr(129), 0);")] |
| ... | ... | @@ -1883,8 +1789,6 @@ macro_rules! uint_impl { |
| 1883 | 1789 | /// |
| 1884 | 1790 | /// # Examples |
| 1885 | 1791 | /// |
| 1886 | /// Basic usage: | |
| 1887 | /// | |
| 1888 | 1792 | /// ``` |
| 1889 | 1793 | #[doc = concat!("assert_eq!(2", stringify!($SelfT), ".checked_pow(5), Some(32));")] |
| 1890 | 1794 | #[doc = concat!("assert_eq!(", stringify!($SelfT), "::MAX.checked_pow(2), None);")] |
| ... | ... | @@ -1925,8 +1829,6 @@ macro_rules! uint_impl { |
| 1925 | 1829 | /// |
| 1926 | 1830 | /// # Examples |
| 1927 | 1831 | /// |
| 1928 | /// Basic usage: | |
| 1929 | /// | |
| 1930 | 1832 | /// ``` |
| 1931 | 1833 | /// #![feature(strict_overflow_ops)] |
| 1932 | 1834 | #[doc = concat!("assert_eq!(2", stringify!($SelfT), ".strict_pow(5), 32);")] |
| ... | ... | @@ -1968,8 +1870,6 @@ macro_rules! uint_impl { |
| 1968 | 1870 | /// |
| 1969 | 1871 | /// # Examples |
| 1970 | 1872 | /// |
| 1971 | /// Basic usage: | |
| 1972 | /// | |
| 1973 | 1873 | /// ``` |
| 1974 | 1874 | #[doc = concat!("assert_eq!(100", stringify!($SelfT), ".saturating_add(1), 101);")] |
| 1975 | 1875 | #[doc = concat!("assert_eq!(", stringify!($SelfT), "::MAX.saturating_add(127), ", stringify!($SelfT), "::MAX);")] |
| ... | ... | @@ -1988,8 +1888,6 @@ macro_rules! uint_impl { |
| 1988 | 1888 | /// |
| 1989 | 1889 | /// # Examples |
| 1990 | 1890 | /// |
| 1991 | /// Basic usage: | |
| 1992 | /// | |
| 1993 | 1891 | /// ``` |
| 1994 | 1892 | #[doc = concat!("assert_eq!(1", stringify!($SelfT), ".saturating_add_signed(2), 3);")] |
| 1995 | 1893 | #[doc = concat!("assert_eq!(1", stringify!($SelfT), ".saturating_add_signed(-2), 0);")] |
| ... | ... | @@ -2016,8 +1914,6 @@ macro_rules! uint_impl { |
| 2016 | 1914 | /// |
| 2017 | 1915 | /// # Examples |
| 2018 | 1916 | /// |
| 2019 | /// Basic usage: | |
| 2020 | /// | |
| 2021 | 1917 | /// ``` |
| 2022 | 1918 | #[doc = concat!("assert_eq!(100", stringify!($SelfT), ".saturating_sub(27), 73);")] |
| 2023 | 1919 | #[doc = concat!("assert_eq!(13", stringify!($SelfT), ".saturating_sub(127), 0);")] |
| ... | ... | @@ -2036,8 +1932,6 @@ macro_rules! uint_impl { |
| 2036 | 1932 | /// |
| 2037 | 1933 | /// # Examples |
| 2038 | 1934 | /// |
| 2039 | /// Basic usage: | |
| 2040 | /// | |
| 2041 | 1935 | /// ``` |
| 2042 | 1936 | /// #![feature(mixed_integer_ops_unsigned_sub)] |
| 2043 | 1937 | #[doc = concat!("assert_eq!(1", stringify!($SelfT), ".saturating_sub_signed(2), 0);")] |
| ... | ... | @@ -2065,8 +1959,6 @@ macro_rules! uint_impl { |
| 2065 | 1959 | /// |
| 2066 | 1960 | /// # Examples |
| 2067 | 1961 | /// |
| 2068 | /// Basic usage: | |
| 2069 | /// | |
| 2070 | 1962 | /// ``` |
| 2071 | 1963 | #[doc = concat!("assert_eq!(2", stringify!($SelfT), ".saturating_mul(10), 20);")] |
| 2072 | 1964 | #[doc = concat!("assert_eq!((", stringify!($SelfT), "::MAX).saturating_mul(10), ", stringify!($SelfT),"::MAX);")] |
| ... | ... | @@ -2092,8 +1984,6 @@ macro_rules! uint_impl { |
| 2092 | 1984 | /// |
| 2093 | 1985 | /// # Examples |
| 2094 | 1986 | /// |
| 2095 | /// Basic usage: | |
| 2096 | /// | |
| 2097 | 1987 | /// ``` |
| 2098 | 1988 | #[doc = concat!("assert_eq!(5", stringify!($SelfT), ".saturating_div(2), 2);")] |
| 2099 | 1989 | /// |
| ... | ... | @@ -2114,8 +2004,6 @@ macro_rules! uint_impl { |
| 2114 | 2004 | /// |
| 2115 | 2005 | /// # Examples |
| 2116 | 2006 | /// |
| 2117 | /// Basic usage: | |
| 2118 | /// | |
| 2119 | 2007 | /// ``` |
| 2120 | 2008 | #[doc = concat!("assert_eq!(4", stringify!($SelfT), ".saturating_pow(3), 64);")] |
| 2121 | 2009 | #[doc = concat!("assert_eq!(", stringify!($SelfT), "::MAX.saturating_pow(2), ", stringify!($SelfT), "::MAX);")] |
| ... | ... | @@ -2137,8 +2025,6 @@ macro_rules! uint_impl { |
| 2137 | 2025 | /// |
| 2138 | 2026 | /// # Examples |
| 2139 | 2027 | /// |
| 2140 | /// Basic usage: | |
| 2141 | /// | |
| 2142 | 2028 | /// ``` |
| 2143 | 2029 | #[doc = concat!("assert_eq!(200", stringify!($SelfT), ".wrapping_add(55), 255);")] |
| 2144 | 2030 | #[doc = concat!("assert_eq!(200", stringify!($SelfT), ".wrapping_add(", stringify!($SelfT), "::MAX), 199);")] |
| ... | ... | @@ -2157,8 +2043,6 @@ macro_rules! uint_impl { |
| 2157 | 2043 | /// |
| 2158 | 2044 | /// # Examples |
| 2159 | 2045 | /// |
| 2160 | /// Basic usage: | |
| 2161 | /// | |
| 2162 | 2046 | /// ``` |
| 2163 | 2047 | #[doc = concat!("assert_eq!(1", stringify!($SelfT), ".wrapping_add_signed(2), 3);")] |
| 2164 | 2048 | #[doc = concat!("assert_eq!(1", stringify!($SelfT), ".wrapping_add_signed(-2), ", stringify!($SelfT), "::MAX);")] |
| ... | ... | @@ -2178,8 +2062,6 @@ macro_rules! uint_impl { |
| 2178 | 2062 | /// |
| 2179 | 2063 | /// # Examples |
| 2180 | 2064 | /// |
| 2181 | /// Basic usage: | |
| 2182 | /// | |
| 2183 | 2065 | /// ``` |
| 2184 | 2066 | #[doc = concat!("assert_eq!(100", stringify!($SelfT), ".wrapping_sub(100), 0);")] |
| 2185 | 2067 | #[doc = concat!("assert_eq!(100", stringify!($SelfT), ".wrapping_sub(", stringify!($SelfT), "::MAX), 101);")] |
| ... | ... | @@ -2198,8 +2080,6 @@ macro_rules! uint_impl { |
| 2198 | 2080 | /// |
| 2199 | 2081 | /// # Examples |
| 2200 | 2082 | /// |
| 2201 | /// Basic usage: | |
| 2202 | /// | |
| 2203 | 2083 | /// ``` |
| 2204 | 2084 | /// #![feature(mixed_integer_ops_unsigned_sub)] |
| 2205 | 2085 | #[doc = concat!("assert_eq!(1", stringify!($SelfT), ".wrapping_sub_signed(2), ", stringify!($SelfT), "::MAX);")] |
| ... | ... | @@ -2219,8 +2099,6 @@ macro_rules! uint_impl { |
| 2219 | 2099 | /// |
| 2220 | 2100 | /// # Examples |
| 2221 | 2101 | /// |
| 2222 | /// Basic usage: | |
| 2223 | /// | |
| 2224 | 2102 | /// Please note that this example is shared between integer types. |
| 2225 | 2103 | /// Which explains why `u8` is used here. |
| 2226 | 2104 | /// |
| ... | ... | @@ -2249,8 +2127,6 @@ macro_rules! uint_impl { |
| 2249 | 2127 | /// |
| 2250 | 2128 | /// # Examples |
| 2251 | 2129 | /// |
| 2252 | /// Basic usage: | |
| 2253 | /// | |
| 2254 | 2130 | /// ``` |
| 2255 | 2131 | #[doc = concat!("assert_eq!(100", stringify!($SelfT), ".wrapping_div(10), 10);")] |
| 2256 | 2132 | /// ``` |
| ... | ... | @@ -2278,8 +2154,6 @@ macro_rules! uint_impl { |
| 2278 | 2154 | /// |
| 2279 | 2155 | /// # Examples |
| 2280 | 2156 | /// |
| 2281 | /// Basic usage: | |
| 2282 | /// | |
| 2283 | 2157 | /// ``` |
| 2284 | 2158 | #[doc = concat!("assert_eq!(100", stringify!($SelfT), ".wrapping_div_euclid(10), 10);")] |
| 2285 | 2159 | /// ``` |
| ... | ... | @@ -2306,8 +2180,6 @@ macro_rules! uint_impl { |
| 2306 | 2180 | /// |
| 2307 | 2181 | /// # Examples |
| 2308 | 2182 | /// |
| 2309 | /// Basic usage: | |
| 2310 | /// | |
| 2311 | 2183 | /// ``` |
| 2312 | 2184 | #[doc = concat!("assert_eq!(100", stringify!($SelfT), ".wrapping_rem(10), 0);")] |
| 2313 | 2185 | /// ``` |
| ... | ... | @@ -2336,8 +2208,6 @@ macro_rules! uint_impl { |
| 2336 | 2208 | /// |
| 2337 | 2209 | /// # Examples |
| 2338 | 2210 | /// |
| 2339 | /// Basic usage: | |
| 2340 | /// | |
| 2341 | 2211 | /// ``` |
| 2342 | 2212 | #[doc = concat!("assert_eq!(100", stringify!($SelfT), ".wrapping_rem_euclid(10), 0);")] |
| 2343 | 2213 | /// ``` |
| ... | ... | @@ -2363,8 +2233,6 @@ macro_rules! uint_impl { |
| 2363 | 2233 | /// |
| 2364 | 2234 | /// # Examples |
| 2365 | 2235 | /// |
| 2366 | /// Basic usage: | |
| 2367 | /// | |
| 2368 | 2236 | /// ``` |
| 2369 | 2237 | #[doc = concat!("assert_eq!(0_", stringify!($SelfT), ".wrapping_neg(), 0);")] |
| 2370 | 2238 | #[doc = concat!("assert_eq!(", stringify!($SelfT), "::MAX.wrapping_neg(), 1);")] |
| ... | ... | @@ -2393,8 +2261,6 @@ macro_rules! uint_impl { |
| 2393 | 2261 | /// |
| 2394 | 2262 | /// # Examples |
| 2395 | 2263 | /// |
| 2396 | /// Basic usage: | |
| 2397 | /// | |
| 2398 | 2264 | /// ``` |
| 2399 | 2265 | #[doc = concat!("assert_eq!(1", stringify!($SelfT), ".wrapping_shl(7), 128);")] |
| 2400 | 2266 | #[doc = concat!("assert_eq!(1", stringify!($SelfT), ".wrapping_shl(128), 1);")] |
| ... | ... | @@ -2425,8 +2291,6 @@ macro_rules! uint_impl { |
| 2425 | 2291 | /// |
| 2426 | 2292 | /// # Examples |
| 2427 | 2293 | /// |
| 2428 | /// Basic usage: | |
| 2429 | /// | |
| 2430 | 2294 | /// ``` |
| 2431 | 2295 | #[doc = concat!("assert_eq!(128", stringify!($SelfT), ".wrapping_shr(7), 1);")] |
| 2432 | 2296 | #[doc = concat!("assert_eq!(128", stringify!($SelfT), ".wrapping_shr(128), 128);")] |
| ... | ... | @@ -2449,8 +2313,6 @@ macro_rules! uint_impl { |
| 2449 | 2313 | /// |
| 2450 | 2314 | /// # Examples |
| 2451 | 2315 | /// |
| 2452 | /// Basic usage: | |
| 2453 | /// | |
| 2454 | 2316 | /// ``` |
| 2455 | 2317 | #[doc = concat!("assert_eq!(3", stringify!($SelfT), ".wrapping_pow(5), 243);")] |
| 2456 | 2318 | /// assert_eq!(3u8.wrapping_pow(6), 217); |
| ... | ... | @@ -2507,8 +2369,6 @@ macro_rules! uint_impl { |
| 2507 | 2369 | /// |
| 2508 | 2370 | /// # Examples |
| 2509 | 2371 | /// |
| 2510 | /// Basic usage: | |
| 2511 | /// | |
| 2512 | 2372 | /// ``` |
| 2513 | 2373 | #[doc = concat!("assert_eq!(5", stringify!($SelfT), ".overflowing_add(2), (7, false));")] |
| 2514 | 2374 | #[doc = concat!("assert_eq!(", stringify!($SelfT), "::MAX.overflowing_add(1), (0, true));")] |
| ... | ... | @@ -2587,8 +2447,6 @@ macro_rules! uint_impl { |
| 2587 | 2447 | /// |
| 2588 | 2448 | /// # Examples |
| 2589 | 2449 | /// |
| 2590 | /// Basic usage: | |
| 2591 | /// | |
| 2592 | 2450 | /// ``` |
| 2593 | 2451 | #[doc = concat!("assert_eq!(1", stringify!($SelfT), ".overflowing_add_signed(2), (3, false));")] |
| 2594 | 2452 | #[doc = concat!("assert_eq!(1", stringify!($SelfT), ".overflowing_add_signed(-2), (", stringify!($SelfT), "::MAX, true));")] |
| ... | ... | @@ -2612,8 +2470,6 @@ macro_rules! uint_impl { |
| 2612 | 2470 | /// |
| 2613 | 2471 | /// # Examples |
| 2614 | 2472 | /// |
| 2615 | /// Basic usage: | |
| 2616 | /// | |
| 2617 | 2473 | /// ``` |
| 2618 | 2474 | #[doc = concat!("assert_eq!(5", stringify!($SelfT), ".overflowing_sub(2), (3, false));")] |
| 2619 | 2475 | #[doc = concat!("assert_eq!(0", stringify!($SelfT), ".overflowing_sub(1), (", stringify!($SelfT), "::MAX, true));")] |
| ... | ... | @@ -2683,8 +2539,6 @@ macro_rules! uint_impl { |
| 2683 | 2539 | /// |
| 2684 | 2540 | /// # Examples |
| 2685 | 2541 | /// |
| 2686 | /// Basic usage: | |
| 2687 | /// | |
| 2688 | 2542 | /// ``` |
| 2689 | 2543 | /// #![feature(mixed_integer_ops_unsigned_sub)] |
| 2690 | 2544 | #[doc = concat!("assert_eq!(1", stringify!($SelfT), ".overflowing_sub_signed(2), (", stringify!($SelfT), "::MAX, true));")] |
| ... | ... | @@ -2705,8 +2559,6 @@ macro_rules! uint_impl { |
| 2705 | 2559 | /// |
| 2706 | 2560 | /// # Examples |
| 2707 | 2561 | /// |
| 2708 | /// Basic usage: | |
| 2709 | /// | |
| 2710 | 2562 | /// ``` |
| 2711 | 2563 | #[doc = concat!("assert_eq!(100", stringify!($SelfT), ".abs_diff(80), 20", stringify!($SelfT), ");")] |
| 2712 | 2564 | #[doc = concat!("assert_eq!(100", stringify!($SelfT), ".abs_diff(110), 10", stringify!($SelfT), ");")] |
| ... | ... | @@ -2738,8 +2590,6 @@ macro_rules! uint_impl { |
| 2738 | 2590 | /// |
| 2739 | 2591 | /// # Examples |
| 2740 | 2592 | /// |
| 2741 | /// Basic usage: | |
| 2742 | /// | |
| 2743 | 2593 | /// Please note that this example is shared between integer types. |
| 2744 | 2594 | /// Which explains why `u32` is used here. |
| 2745 | 2595 | /// |
| ... | ... | @@ -2767,8 +2617,6 @@ macro_rules! uint_impl { |
| 2767 | 2617 | /// |
| 2768 | 2618 | /// # Examples |
| 2769 | 2619 | /// |
| 2770 | /// Basic usage: | |
| 2771 | /// | |
| 2772 | 2620 | /// Please note that this example is shared between integer types. |
| 2773 | 2621 | /// Which explains why `u32` is used here. |
| 2774 | 2622 | /// |
| ... | ... | @@ -2800,8 +2648,6 @@ macro_rules! uint_impl { |
| 2800 | 2648 | /// |
| 2801 | 2649 | /// # Examples |
| 2802 | 2650 | /// |
| 2803 | /// Basic usage: | |
| 2804 | /// | |
| 2805 | 2651 | /// Please note that this example is shared between integer types. |
| 2806 | 2652 | /// Which explains why `u32` is used here. |
| 2807 | 2653 | /// |
| ... | ... | @@ -2888,8 +2734,6 @@ macro_rules! uint_impl { |
| 2888 | 2734 | /// |
| 2889 | 2735 | /// # Examples |
| 2890 | 2736 | /// |
| 2891 | /// Basic usage: | |
| 2892 | /// | |
| 2893 | 2737 | /// Please note that this example is shared between integer types, |
| 2894 | 2738 | /// which explains why `u32` is used here. |
| 2895 | 2739 | /// |
| ... | ... | @@ -2955,8 +2799,6 @@ macro_rules! uint_impl { |
| 2955 | 2799 | /// |
| 2956 | 2800 | /// # Examples |
| 2957 | 2801 | /// |
| 2958 | /// Basic usage: | |
| 2959 | /// | |
| 2960 | 2802 | /// ``` |
| 2961 | 2803 | #[doc = concat!("assert_eq!(5", stringify!($SelfT), ".overflowing_div(2), (2, false));")] |
| 2962 | 2804 | /// ``` |
| ... | ... | @@ -2986,8 +2828,6 @@ macro_rules! uint_impl { |
| 2986 | 2828 | /// |
| 2987 | 2829 | /// # Examples |
| 2988 | 2830 | /// |
| 2989 | /// Basic usage: | |
| 2990 | /// | |
| 2991 | 2831 | /// ``` |
| 2992 | 2832 | #[doc = concat!("assert_eq!(5", stringify!($SelfT), ".overflowing_div_euclid(2), (2, false));")] |
| 2993 | 2833 | /// ``` |
| ... | ... | @@ -3014,8 +2854,6 @@ macro_rules! uint_impl { |
| 3014 | 2854 | /// |
| 3015 | 2855 | /// # Examples |
| 3016 | 2856 | /// |
| 3017 | /// Basic usage: | |
| 3018 | /// | |
| 3019 | 2857 | /// ``` |
| 3020 | 2858 | #[doc = concat!("assert_eq!(5", stringify!($SelfT), ".overflowing_rem(2), (1, false));")] |
| 3021 | 2859 | /// ``` |
| ... | ... | @@ -3045,8 +2883,6 @@ macro_rules! uint_impl { |
| 3045 | 2883 | /// |
| 3046 | 2884 | /// # Examples |
| 3047 | 2885 | /// |
| 3048 | /// Basic usage: | |
| 3049 | /// | |
| 3050 | 2886 | /// ``` |
| 3051 | 2887 | #[doc = concat!("assert_eq!(5", stringify!($SelfT), ".overflowing_rem_euclid(2), (1, false));")] |
| 3052 | 2888 | /// ``` |
| ... | ... | @@ -3069,8 +2905,6 @@ macro_rules! uint_impl { |
| 3069 | 2905 | /// |
| 3070 | 2906 | /// # Examples |
| 3071 | 2907 | /// |
| 3072 | /// Basic usage: | |
| 3073 | /// | |
| 3074 | 2908 | /// ``` |
| 3075 | 2909 | #[doc = concat!("assert_eq!(0", stringify!($SelfT), ".overflowing_neg(), (0, false));")] |
| 3076 | 2910 | #[doc = concat!("assert_eq!(2", stringify!($SelfT), ".overflowing_neg(), (-2i32 as ", stringify!($SelfT), ", true));")] |
| ... | ... | @@ -3094,8 +2928,6 @@ macro_rules! uint_impl { |
| 3094 | 2928 | /// |
| 3095 | 2929 | /// # Examples |
| 3096 | 2930 | /// |
| 3097 | /// Basic usage: | |
| 3098 | /// | |
| 3099 | 2931 | /// ``` |
| 3100 | 2932 | #[doc = concat!("assert_eq!(0x1", stringify!($SelfT), ".overflowing_shl(4), (0x10, false));")] |
| 3101 | 2933 | #[doc = concat!("assert_eq!(0x1", stringify!($SelfT), ".overflowing_shl(132), (0x10, true));")] |
| ... | ... | @@ -3120,8 +2952,6 @@ macro_rules! uint_impl { |
| 3120 | 2952 | /// |
| 3121 | 2953 | /// # Examples |
| 3122 | 2954 | /// |
| 3123 | /// Basic usage: | |
| 3124 | /// | |
| 3125 | 2955 | /// ``` |
| 3126 | 2956 | #[doc = concat!("assert_eq!(0x10", stringify!($SelfT), ".overflowing_shr(4), (0x1, false));")] |
| 3127 | 2957 | #[doc = concat!("assert_eq!(0x10", stringify!($SelfT), ".overflowing_shr(132), (0x1, true));")] |
| ... | ... | @@ -3142,8 +2972,6 @@ macro_rules! uint_impl { |
| 3142 | 2972 | /// |
| 3143 | 2973 | /// # Examples |
| 3144 | 2974 | /// |
| 3145 | /// Basic usage: | |
| 3146 | /// | |
| 3147 | 2975 | /// ``` |
| 3148 | 2976 | #[doc = concat!("assert_eq!(3", stringify!($SelfT), ".overflowing_pow(5), (243, false));")] |
| 3149 | 2977 | /// assert_eq!(3u8.overflowing_pow(6), (217, true)); |
| ... | ... | @@ -3185,8 +3013,6 @@ macro_rules! uint_impl { |
| 3185 | 3013 | /// |
| 3186 | 3014 | /// # Examples |
| 3187 | 3015 | /// |
| 3188 | /// Basic usage: | |
| 3189 | /// | |
| 3190 | 3016 | /// ``` |
| 3191 | 3017 | #[doc = concat!("assert_eq!(2", stringify!($SelfT), ".pow(5), 32);")] |
| 3192 | 3018 | /// ``` |
| ... | ... | @@ -3240,7 +3066,6 @@ macro_rules! uint_impl { |
| 3240 | 3066 | /// |
| 3241 | 3067 | /// # Examples |
| 3242 | 3068 | /// |
| 3243 | /// Basic usage: | |
| 3244 | 3069 | /// ``` |
| 3245 | 3070 | #[doc = concat!("assert_eq!(10", stringify!($SelfT), ".isqrt(), 3);")] |
| 3246 | 3071 | /// ``` |
| ... | ... | @@ -3282,8 +3107,6 @@ macro_rules! uint_impl { |
| 3282 | 3107 | /// |
| 3283 | 3108 | /// # Examples |
| 3284 | 3109 | /// |
| 3285 | /// Basic usage: | |
| 3286 | /// | |
| 3287 | 3110 | /// ``` |
| 3288 | 3111 | #[doc = concat!("assert_eq!(7", stringify!($SelfT), ".div_euclid(4), 1); // or any other integer type")] |
| 3289 | 3112 | /// ``` |
| ... | ... | @@ -3310,8 +3133,6 @@ macro_rules! uint_impl { |
| 3310 | 3133 | /// |
| 3311 | 3134 | /// # Examples |
| 3312 | 3135 | /// |
| 3313 | /// Basic usage: | |
| 3314 | /// | |
| 3315 | 3136 | /// ``` |
| 3316 | 3137 | #[doc = concat!("assert_eq!(7", stringify!($SelfT), ".rem_euclid(4), 3); // or any other integer type")] |
| 3317 | 3138 | /// ``` |
| ... | ... | @@ -3336,8 +3157,6 @@ macro_rules! uint_impl { |
| 3336 | 3157 | /// |
| 3337 | 3158 | /// # Examples |
| 3338 | 3159 | /// |
| 3339 | /// Basic usage: | |
| 3340 | /// | |
| 3341 | 3160 | /// ``` |
| 3342 | 3161 | /// #![feature(int_roundings)] |
| 3343 | 3162 | #[doc = concat!("assert_eq!(7_", stringify!($SelfT), ".div_floor(4), 1);")] |
| ... | ... | @@ -3359,8 +3178,6 @@ macro_rules! uint_impl { |
| 3359 | 3178 | /// |
| 3360 | 3179 | /// # Examples |
| 3361 | 3180 | /// |
| 3362 | /// Basic usage: | |
| 3363 | /// | |
| 3364 | 3181 | /// ``` |
| 3365 | 3182 | #[doc = concat!("assert_eq!(7_", stringify!($SelfT), ".div_ceil(4), 2);")] |
| 3366 | 3183 | /// ``` |
| ... | ... | @@ -3394,8 +3211,6 @@ macro_rules! uint_impl { |
| 3394 | 3211 | /// |
| 3395 | 3212 | /// # Examples |
| 3396 | 3213 | /// |
| 3397 | /// Basic usage: | |
| 3398 | /// | |
| 3399 | 3214 | /// ``` |
| 3400 | 3215 | #[doc = concat!("assert_eq!(16_", stringify!($SelfT), ".next_multiple_of(8), 16);")] |
| 3401 | 3216 | #[doc = concat!("assert_eq!(23_", stringify!($SelfT), ".next_multiple_of(8), 24);")] |
| ... | ... | @@ -3419,8 +3234,6 @@ macro_rules! uint_impl { |
| 3419 | 3234 | /// |
| 3420 | 3235 | /// # Examples |
| 3421 | 3236 | /// |
| 3422 | /// Basic usage: | |
| 3423 | /// | |
| 3424 | 3237 | /// ``` |
| 3425 | 3238 | #[doc = concat!("assert_eq!(16_", stringify!($SelfT), ".checked_next_multiple_of(8), Some(16));")] |
| 3426 | 3239 | #[doc = concat!("assert_eq!(23_", stringify!($SelfT), ".checked_next_multiple_of(8), Some(24));")] |
| ... | ... | @@ -3448,8 +3261,6 @@ macro_rules! uint_impl { |
| 3448 | 3261 | /// |
| 3449 | 3262 | /// # Examples |
| 3450 | 3263 | /// |
| 3451 | /// Basic usage: | |
| 3452 | /// | |
| 3453 | 3264 | /// ``` |
| 3454 | 3265 | #[doc = concat!("assert!(6_", stringify!($SelfT), ".is_multiple_of(2));")] |
| 3455 | 3266 | #[doc = concat!("assert!(!5_", stringify!($SelfT), ".is_multiple_of(2));")] |
| ... | ... | @@ -3473,8 +3284,6 @@ macro_rules! uint_impl { |
| 3473 | 3284 | /// |
| 3474 | 3285 | /// # Examples |
| 3475 | 3286 | /// |
| 3476 | /// Basic usage: | |
| 3477 | /// | |
| 3478 | 3287 | /// ``` |
| 3479 | 3288 | #[doc = concat!("assert!(16", stringify!($SelfT), ".is_power_of_two());")] |
| 3480 | 3289 | #[doc = concat!("assert!(!10", stringify!($SelfT), ".is_power_of_two());")] |
| ... | ... | @@ -3517,8 +3326,6 @@ macro_rules! uint_impl { |
| 3517 | 3326 | /// |
| 3518 | 3327 | /// # Examples |
| 3519 | 3328 | /// |
| 3520 | /// Basic usage: | |
| 3521 | /// | |
| 3522 | 3329 | /// ``` |
| 3523 | 3330 | #[doc = concat!("assert_eq!(2", stringify!($SelfT), ".next_power_of_two(), 2);")] |
| 3524 | 3331 | #[doc = concat!("assert_eq!(3", stringify!($SelfT), ".next_power_of_two(), 4);")] |
| ... | ... | @@ -3540,8 +3347,6 @@ macro_rules! uint_impl { |
| 3540 | 3347 | /// |
| 3541 | 3348 | /// # Examples |
| 3542 | 3349 | /// |
| 3543 | /// Basic usage: | |
| 3544 | /// | |
| 3545 | 3350 | /// ``` |
| 3546 | 3351 | #[doc = concat!("assert_eq!(2", stringify!($SelfT), ".checked_next_power_of_two(), Some(2));")] |
| 3547 | 3352 | #[doc = concat!("assert_eq!(3", stringify!($SelfT), ".checked_next_power_of_two(), Some(4));")] |
| ... | ... | @@ -3562,8 +3367,6 @@ macro_rules! uint_impl { |
| 3562 | 3367 | /// |
| 3563 | 3368 | /// # Examples |
| 3564 | 3369 | /// |
| 3565 | /// Basic usage: | |
| 3566 | /// | |
| 3567 | 3370 | /// ``` |
| 3568 | 3371 | /// #![feature(wrapping_next_power_of_two)] |
| 3569 | 3372 | /// |
src/bootstrap/src/bin/rustc.rs-12| ... | ... | @@ -151,18 +151,6 @@ fn main() { |
| 151 | 151 | cmd.arg("--sysroot").arg(&sysroot); |
| 152 | 152 | } |
| 153 | 153 | |
| 154 | // If we're compiling specifically the `panic_abort` crate then we pass | |
| 155 | // the `-C panic=abort` option. Note that we do not do this for any | |
| 156 | // other crate intentionally as this is the only crate for now that we | |
| 157 | // ship with panic=abort. | |
| 158 | // | |
| 159 | // This... is a bit of a hack how we detect this. Ideally this | |
| 160 | // information should be encoded in the crate I guess? Would likely | |
| 161 | // require an RFC amendment to RFC 1513, however. | |
| 162 | if crate_name == Some("panic_abort") { | |
| 163 | cmd.arg("-C").arg("panic=abort"); | |
| 164 | } | |
| 165 | ||
| 166 | 154 | let crate_type = parse_value_from_args(&orig_args, "--crate-type"); |
| 167 | 155 | // `-Ztls-model=initial-exec` must not be applied to proc-macros, see |
| 168 | 156 | // issue https://github.com/rust-lang/rust/issues/100530 |
src/librustdoc/clean/types.rs-14| ... | ... | @@ -2432,20 +2432,6 @@ pub(crate) enum ConstantKind { |
| 2432 | 2432 | Infer, |
| 2433 | 2433 | } |
| 2434 | 2434 | |
| 2435 | impl Constant { | |
| 2436 | pub(crate) fn expr(&self, tcx: TyCtxt<'_>) -> String { | |
| 2437 | self.kind.expr(tcx) | |
| 2438 | } | |
| 2439 | ||
| 2440 | pub(crate) fn value(&self, tcx: TyCtxt<'_>) -> Option<String> { | |
| 2441 | self.kind.value(tcx) | |
| 2442 | } | |
| 2443 | ||
| 2444 | pub(crate) fn is_literal(&self, tcx: TyCtxt<'_>) -> bool { | |
| 2445 | self.kind.is_literal(tcx) | |
| 2446 | } | |
| 2447 | } | |
| 2448 | ||
| 2449 | 2435 | impl ConstantKind { |
| 2450 | 2436 | pub(crate) fn expr(&self, tcx: TyCtxt<'_>) -> String { |
| 2451 | 2437 | match *self { |
src/librustdoc/json/conversions.rs+169-175| ... | ... | @@ -11,7 +11,7 @@ use rustc_hir::def::CtorKind; |
| 11 | 11 | use rustc_hir::def_id::DefId; |
| 12 | 12 | use rustc_metadata::rendered_const; |
| 13 | 13 | use rustc_middle::{bug, ty}; |
| 14 | use rustc_span::{Pos, Symbol, kw}; | |
| 14 | use rustc_span::{Pos, kw, sym}; | |
| 15 | 15 | use rustdoc_json_types::*; |
| 16 | 16 | use thin_vec::ThinVec; |
| 17 | 17 | |
| ... | ... | @@ -66,47 +66,16 @@ impl JsonRenderer<'_> { |
| 66 | 66 | id, |
| 67 | 67 | crate_id: item_id.krate().as_u32(), |
| 68 | 68 | name: name.map(|sym| sym.to_string()), |
| 69 | span: span.and_then(|span| self.convert_span(span)), | |
| 70 | visibility: self.convert_visibility(visibility), | |
| 69 | span: span.and_then(|span| span.into_json(self)), | |
| 70 | visibility: visibility.into_json(self), | |
| 71 | 71 | docs, |
| 72 | 72 | attrs, |
| 73 | deprecation: deprecation.map(from_deprecation), | |
| 73 | deprecation: deprecation.into_json(self), | |
| 74 | 74 | inner, |
| 75 | 75 | links, |
| 76 | 76 | }) |
| 77 | 77 | } |
| 78 | 78 | |
| 79 | fn convert_span(&self, span: clean::Span) -> Option<Span> { | |
| 80 | match span.filename(self.sess()) { | |
| 81 | rustc_span::FileName::Real(name) => { | |
| 82 | if let Some(local_path) = name.into_local_path() { | |
| 83 | let hi = span.hi(self.sess()); | |
| 84 | let lo = span.lo(self.sess()); | |
| 85 | Some(Span { | |
| 86 | filename: local_path, | |
| 87 | begin: (lo.line, lo.col.to_usize() + 1), | |
| 88 | end: (hi.line, hi.col.to_usize() + 1), | |
| 89 | }) | |
| 90 | } else { | |
| 91 | None | |
| 92 | } | |
| 93 | } | |
| 94 | _ => None, | |
| 95 | } | |
| 96 | } | |
| 97 | ||
| 98 | fn convert_visibility(&self, v: Option<ty::Visibility<DefId>>) -> Visibility { | |
| 99 | match v { | |
| 100 | None => Visibility::Default, | |
| 101 | Some(ty::Visibility::Public) => Visibility::Public, | |
| 102 | Some(ty::Visibility::Restricted(did)) if did.is_crate_root() => Visibility::Crate, | |
| 103 | Some(ty::Visibility::Restricted(did)) => Visibility::Restricted { | |
| 104 | parent: self.id_from_item_default(did.into()), | |
| 105 | path: self.tcx.def_path(did).to_string_no_crate_verbose(), | |
| 106 | }, | |
| 107 | } | |
| 108 | } | |
| 109 | ||
| 110 | 79 | fn ids(&self, items: &[clean::Item]) -> Vec<Id> { |
| 111 | 80 | items |
| 112 | 81 | .iter() |
| ... | ... | @@ -140,11 +109,29 @@ where |
| 140 | 109 | } |
| 141 | 110 | } |
| 142 | 111 | |
| 112 | impl<T, U> FromClean<Box<T>> for U | |
| 113 | where | |
| 114 | U: FromClean<T>, | |
| 115 | { | |
| 116 | fn from_clean(opt: &Box<T>, renderer: &JsonRenderer<'_>) -> Self { | |
| 117 | opt.as_ref().into_json(renderer) | |
| 118 | } | |
| 119 | } | |
| 120 | ||
| 121 | impl<T, U> FromClean<Option<T>> for Option<U> | |
| 122 | where | |
| 123 | U: FromClean<T>, | |
| 124 | { | |
| 125 | fn from_clean(opt: &Option<T>, renderer: &JsonRenderer<'_>) -> Self { | |
| 126 | opt.as_ref().map(|x| x.into_json(renderer)) | |
| 127 | } | |
| 128 | } | |
| 129 | ||
| 143 | 130 | impl<T, U> FromClean<Vec<T>> for Vec<U> |
| 144 | 131 | where |
| 145 | 132 | U: FromClean<T>, |
| 146 | 133 | { |
| 147 | fn from_clean(items: &Vec<T>, renderer: &JsonRenderer<'_>) -> Vec<U> { | |
| 134 | fn from_clean(items: &Vec<T>, renderer: &JsonRenderer<'_>) -> Self { | |
| 148 | 135 | items.iter().map(|i| i.into_json(renderer)).collect() |
| 149 | 136 | } |
| 150 | 137 | } |
| ... | ... | @@ -153,20 +140,57 @@ impl<T, U> FromClean<ThinVec<T>> for Vec<U> |
| 153 | 140 | where |
| 154 | 141 | U: FromClean<T>, |
| 155 | 142 | { |
| 156 | fn from_clean(items: &ThinVec<T>, renderer: &JsonRenderer<'_>) -> Vec<U> { | |
| 143 | fn from_clean(items: &ThinVec<T>, renderer: &JsonRenderer<'_>) -> Self { | |
| 157 | 144 | items.iter().map(|i| i.into_json(renderer)).collect() |
| 158 | 145 | } |
| 159 | 146 | } |
| 160 | 147 | |
| 161 | pub(crate) fn from_deprecation(deprecation: attrs::Deprecation) -> Deprecation { | |
| 162 | let attrs::Deprecation { since, note, suggestion: _ } = deprecation; | |
| 163 | let since = match since { | |
| 164 | DeprecatedSince::RustcVersion(version) => Some(version.to_string()), | |
| 165 | DeprecatedSince::Future => Some("TBD".to_owned()), | |
| 166 | DeprecatedSince::NonStandard(since) => Some(since.to_string()), | |
| 167 | DeprecatedSince::Unspecified | DeprecatedSince::Err => None, | |
| 168 | }; | |
| 169 | Deprecation { since, note: note.map(|s| s.to_string()) } | |
| 148 | impl FromClean<clean::Span> for Option<Span> { | |
| 149 | fn from_clean(span: &clean::Span, renderer: &JsonRenderer<'_>) -> Self { | |
| 150 | match span.filename(renderer.sess()) { | |
| 151 | rustc_span::FileName::Real(name) => { | |
| 152 | if let Some(local_path) = name.into_local_path() { | |
| 153 | let hi = span.hi(renderer.sess()); | |
| 154 | let lo = span.lo(renderer.sess()); | |
| 155 | Some(Span { | |
| 156 | filename: local_path, | |
| 157 | begin: (lo.line, lo.col.to_usize() + 1), | |
| 158 | end: (hi.line, hi.col.to_usize() + 1), | |
| 159 | }) | |
| 160 | } else { | |
| 161 | None | |
| 162 | } | |
| 163 | } | |
| 164 | _ => None, | |
| 165 | } | |
| 166 | } | |
| 167 | } | |
| 168 | ||
| 169 | impl FromClean<Option<ty::Visibility<DefId>>> for Visibility { | |
| 170 | fn from_clean(v: &Option<ty::Visibility<DefId>>, renderer: &JsonRenderer<'_>) -> Self { | |
| 171 | match v { | |
| 172 | None => Visibility::Default, | |
| 173 | Some(ty::Visibility::Public) => Visibility::Public, | |
| 174 | Some(ty::Visibility::Restricted(did)) if did.is_crate_root() => Visibility::Crate, | |
| 175 | Some(ty::Visibility::Restricted(did)) => Visibility::Restricted { | |
| 176 | parent: renderer.id_from_item_default((*did).into()), | |
| 177 | path: renderer.tcx.def_path(*did).to_string_no_crate_verbose(), | |
| 178 | }, | |
| 179 | } | |
| 180 | } | |
| 181 | } | |
| 182 | ||
| 183 | impl FromClean<attrs::Deprecation> for Deprecation { | |
| 184 | fn from_clean(deprecation: &attrs::Deprecation, _renderer: &JsonRenderer<'_>) -> Self { | |
| 185 | let attrs::Deprecation { since, note, suggestion: _ } = deprecation; | |
| 186 | let since = match since { | |
| 187 | DeprecatedSince::RustcVersion(version) => Some(version.to_string()), | |
| 188 | DeprecatedSince::Future => Some("TBD".to_string()), | |
| 189 | DeprecatedSince::NonStandard(since) => Some(since.to_string()), | |
| 190 | DeprecatedSince::Unspecified | DeprecatedSince::Err => None, | |
| 191 | }; | |
| 192 | Deprecation { since, note: note.map(|sym| sym.to_string()) } | |
| 193 | } | |
| 170 | 194 | } |
| 171 | 195 | |
| 172 | 196 | impl FromClean<clean::GenericArgs> for Option<Box<GenericArgs>> { |
| ... | ... | @@ -182,7 +206,7 @@ impl FromClean<clean::GenericArgs> for Option<Box<GenericArgs>> { |
| 182 | 206 | }, |
| 183 | 207 | Parenthesized { inputs, output } => GenericArgs::Parenthesized { |
| 184 | 208 | inputs: inputs.into_json(renderer), |
| 185 | output: output.as_ref().map(|a| a.as_ref().into_json(renderer)), | |
| 209 | output: output.into_json(renderer), | |
| 186 | 210 | }, |
| 187 | 211 | ReturnTypeNotation => GenericArgs::ReturnTypeNotation, |
| 188 | 212 | })) |
| ... | ... | @@ -193,7 +217,7 @@ impl FromClean<clean::GenericArg> for GenericArg { |
| 193 | 217 | fn from_clean(arg: &clean::GenericArg, renderer: &JsonRenderer<'_>) -> Self { |
| 194 | 218 | use clean::GenericArg::*; |
| 195 | 219 | match arg { |
| 196 | Lifetime(l) => GenericArg::Lifetime(convert_lifetime(l)), | |
| 220 | Lifetime(l) => GenericArg::Lifetime(l.into_json(renderer)), | |
| 197 | 221 | Type(t) => GenericArg::Type(t.into_json(renderer)), |
| 198 | 222 | Const(box c) => GenericArg::Const(c.into_json(renderer)), |
| 199 | 223 | Infer => GenericArg::Infer, |
| ... | ... | @@ -201,17 +225,6 @@ impl FromClean<clean::GenericArg> for GenericArg { |
| 201 | 225 | } |
| 202 | 226 | } |
| 203 | 227 | |
| 204 | impl FromClean<clean::Constant> for Constant { | |
| 205 | // FIXME(generic_const_items): Add support for generic const items. | |
| 206 | fn from_clean(constant: &clean::Constant, renderer: &JsonRenderer<'_>) -> Self { | |
| 207 | let tcx = renderer.tcx; | |
| 208 | let expr = constant.expr(tcx); | |
| 209 | let value = constant.value(tcx); | |
| 210 | let is_literal = constant.is_literal(tcx); | |
| 211 | Constant { expr, value, is_literal } | |
| 212 | } | |
| 213 | } | |
| 214 | ||
| 215 | 228 | impl FromClean<clean::ConstantKind> for Constant { |
| 216 | 229 | // FIXME(generic_const_items): Add support for generic const items. |
| 217 | 230 | fn from_clean(constant: &clean::ConstantKind, renderer: &JsonRenderer<'_>) -> Self { |
| ... | ... | @@ -259,21 +272,25 @@ fn from_clean_item(item: &clean::Item, renderer: &JsonRenderer<'_>) -> ItemEnum |
| 259 | 272 | StructFieldItem(f) => ItemEnum::StructField(f.into_json(renderer)), |
| 260 | 273 | EnumItem(e) => ItemEnum::Enum(e.into_json(renderer)), |
| 261 | 274 | VariantItem(v) => ItemEnum::Variant(v.into_json(renderer)), |
| 262 | FunctionItem(f) => ItemEnum::Function(from_function(f, true, header.unwrap(), renderer)), | |
| 275 | FunctionItem(f) => { | |
| 276 | ItemEnum::Function(from_clean_function(f, true, header.unwrap(), renderer)) | |
| 277 | } | |
| 263 | 278 | ForeignFunctionItem(f, _) => { |
| 264 | ItemEnum::Function(from_function(f, false, header.unwrap(), renderer)) | |
| 279 | ItemEnum::Function(from_clean_function(f, false, header.unwrap(), renderer)) | |
| 265 | 280 | } |
| 266 | TraitItem(t) => ItemEnum::Trait(t.as_ref().into_json(renderer)), | |
| 281 | TraitItem(t) => ItemEnum::Trait(t.into_json(renderer)), | |
| 267 | 282 | TraitAliasItem(t) => ItemEnum::TraitAlias(t.into_json(renderer)), |
| 268 | MethodItem(m, _) => ItemEnum::Function(from_function(m, true, header.unwrap(), renderer)), | |
| 283 | MethodItem(m, _) => { | |
| 284 | ItemEnum::Function(from_clean_function(m, true, header.unwrap(), renderer)) | |
| 285 | } | |
| 269 | 286 | RequiredMethodItem(m) => { |
| 270 | ItemEnum::Function(from_function(m, false, header.unwrap(), renderer)) | |
| 287 | ItemEnum::Function(from_clean_function(m, false, header.unwrap(), renderer)) | |
| 271 | 288 | } |
| 272 | ImplItem(i) => ItemEnum::Impl(i.as_ref().into_json(renderer)), | |
| 273 | StaticItem(s) => ItemEnum::Static(convert_static(s, &rustc_hir::Safety::Safe, renderer)), | |
| 274 | ForeignStaticItem(s, safety) => ItemEnum::Static(convert_static(s, safety, renderer)), | |
| 289 | ImplItem(i) => ItemEnum::Impl(i.into_json(renderer)), | |
| 290 | StaticItem(s) => ItemEnum::Static(from_clean_static(s, rustc_hir::Safety::Safe, renderer)), | |
| 291 | ForeignStaticItem(s, safety) => ItemEnum::Static(from_clean_static(s, *safety, renderer)), | |
| 275 | 292 | ForeignTypeItem => ItemEnum::ExternType, |
| 276 | TypeAliasItem(t) => ItemEnum::TypeAlias(t.as_ref().into_json(renderer)), | |
| 293 | TypeAliasItem(t) => ItemEnum::TypeAlias(t.into_json(renderer)), | |
| 277 | 294 | // FIXME(generic_const_items): Add support for generic free consts |
| 278 | 295 | ConstantItem(ci) => ItemEnum::Constant { |
| 279 | 296 | type_: ci.type_.into_json(renderer), |
| ... | ... | @@ -289,7 +306,7 @@ fn from_clean_item(item: &clean::Item, renderer: &JsonRenderer<'_>) -> ItemEnum |
| 289 | 306 | } |
| 290 | 307 | // FIXME(generic_const_items): Add support for generic associated consts. |
| 291 | 308 | RequiredAssocConstItem(_generics, ty) => { |
| 292 | ItemEnum::AssocConst { type_: ty.as_ref().into_json(renderer), value: None } | |
| 309 | ItemEnum::AssocConst { type_: ty.into_json(renderer), value: None } | |
| 293 | 310 | } |
| 294 | 311 | // FIXME(generic_const_items): Add support for generic associated consts. |
| 295 | 312 | ProvidedAssocConstItem(ci) | ImplAssocConstItem(ci) => ItemEnum::AssocConst { |
| ... | ... | @@ -361,32 +378,38 @@ impl FromClean<clean::Union> for Union { |
| 361 | 378 | } |
| 362 | 379 | } |
| 363 | 380 | |
| 364 | pub(crate) fn from_fn_header(header: &rustc_hir::FnHeader) -> FunctionHeader { | |
| 365 | FunctionHeader { | |
| 366 | is_async: header.is_async(), | |
| 367 | is_const: header.is_const(), | |
| 368 | is_unsafe: header.is_unsafe(), | |
| 369 | abi: convert_abi(header.abi), | |
| 381 | impl FromClean<rustc_hir::FnHeader> for FunctionHeader { | |
| 382 | fn from_clean(header: &rustc_hir::FnHeader, renderer: &JsonRenderer<'_>) -> Self { | |
| 383 | FunctionHeader { | |
| 384 | is_async: header.is_async(), | |
| 385 | is_const: header.is_const(), | |
| 386 | is_unsafe: header.is_unsafe(), | |
| 387 | abi: header.abi.into_json(renderer), | |
| 388 | } | |
| 370 | 389 | } |
| 371 | 390 | } |
| 372 | 391 | |
| 373 | fn convert_abi(a: ExternAbi) -> Abi { | |
| 374 | match a { | |
| 375 | ExternAbi::Rust => Abi::Rust, | |
| 376 | ExternAbi::C { unwind } => Abi::C { unwind }, | |
| 377 | ExternAbi::Cdecl { unwind } => Abi::Cdecl { unwind }, | |
| 378 | ExternAbi::Stdcall { unwind } => Abi::Stdcall { unwind }, | |
| 379 | ExternAbi::Fastcall { unwind } => Abi::Fastcall { unwind }, | |
| 380 | ExternAbi::Aapcs { unwind } => Abi::Aapcs { unwind }, | |
| 381 | ExternAbi::Win64 { unwind } => Abi::Win64 { unwind }, | |
| 382 | ExternAbi::SysV64 { unwind } => Abi::SysV64 { unwind }, | |
| 383 | ExternAbi::System { unwind } => Abi::System { unwind }, | |
| 384 | _ => Abi::Other(a.to_string()), | |
| 392 | impl FromClean<ExternAbi> for Abi { | |
| 393 | fn from_clean(a: &ExternAbi, _renderer: &JsonRenderer<'_>) -> Self { | |
| 394 | match *a { | |
| 395 | ExternAbi::Rust => Abi::Rust, | |
| 396 | ExternAbi::C { unwind } => Abi::C { unwind }, | |
| 397 | ExternAbi::Cdecl { unwind } => Abi::Cdecl { unwind }, | |
| 398 | ExternAbi::Stdcall { unwind } => Abi::Stdcall { unwind }, | |
| 399 | ExternAbi::Fastcall { unwind } => Abi::Fastcall { unwind }, | |
| 400 | ExternAbi::Aapcs { unwind } => Abi::Aapcs { unwind }, | |
| 401 | ExternAbi::Win64 { unwind } => Abi::Win64 { unwind }, | |
| 402 | ExternAbi::SysV64 { unwind } => Abi::SysV64 { unwind }, | |
| 403 | ExternAbi::System { unwind } => Abi::System { unwind }, | |
| 404 | _ => Abi::Other(a.to_string()), | |
| 405 | } | |
| 385 | 406 | } |
| 386 | 407 | } |
| 387 | 408 | |
| 388 | fn convert_lifetime(l: &clean::Lifetime) -> String { | |
| 389 | l.0.to_string() | |
| 409 | impl FromClean<clean::Lifetime> for String { | |
| 410 | fn from_clean(l: &clean::Lifetime, _renderer: &JsonRenderer<'_>) -> String { | |
| 411 | l.0.to_string() | |
| 412 | } | |
| 390 | 413 | } |
| 391 | 414 | |
| 392 | 415 | impl FromClean<clean::Generics> for Generics { |
| ... | ... | @@ -411,16 +434,16 @@ impl FromClean<clean::GenericParamDefKind> for GenericParamDefKind { |
| 411 | 434 | fn from_clean(kind: &clean::GenericParamDefKind, renderer: &JsonRenderer<'_>) -> Self { |
| 412 | 435 | use clean::GenericParamDefKind::*; |
| 413 | 436 | match kind { |
| 414 | Lifetime { outlives } => GenericParamDefKind::Lifetime { | |
| 415 | outlives: outlives.into_iter().map(convert_lifetime).collect(), | |
| 416 | }, | |
| 437 | Lifetime { outlives } => { | |
| 438 | GenericParamDefKind::Lifetime { outlives: outlives.into_json(renderer) } | |
| 439 | } | |
| 417 | 440 | Type { bounds, default, synthetic } => GenericParamDefKind::Type { |
| 418 | 441 | bounds: bounds.into_json(renderer), |
| 419 | default: default.as_ref().map(|x| x.as_ref().into_json(renderer)), | |
| 442 | default: default.into_json(renderer), | |
| 420 | 443 | is_synthetic: *synthetic, |
| 421 | 444 | }, |
| 422 | 445 | Const { ty, default, synthetic: _ } => GenericParamDefKind::Const { |
| 423 | type_: ty.as_ref().into_json(renderer), | |
| 446 | type_: ty.into_json(renderer), | |
| 424 | 447 | default: default.as_ref().map(|x| x.as_ref().clone()), |
| 425 | 448 | }, |
| 426 | 449 | } |
| ... | ... | @@ -434,45 +457,14 @@ impl FromClean<clean::WherePredicate> for WherePredicate { |
| 434 | 457 | BoundPredicate { ty, bounds, bound_params } => WherePredicate::BoundPredicate { |
| 435 | 458 | type_: ty.into_json(renderer), |
| 436 | 459 | bounds: bounds.into_json(renderer), |
| 437 | generic_params: bound_params | |
| 438 | .iter() | |
| 439 | .map(|x| { | |
| 440 | let name = x.name.to_string(); | |
| 441 | let kind = match &x.kind { | |
| 442 | clean::GenericParamDefKind::Lifetime { outlives } => { | |
| 443 | GenericParamDefKind::Lifetime { | |
| 444 | outlives: outlives.iter().map(|lt| lt.0.to_string()).collect(), | |
| 445 | } | |
| 446 | } | |
| 447 | clean::GenericParamDefKind::Type { bounds, default, synthetic } => { | |
| 448 | GenericParamDefKind::Type { | |
| 449 | bounds: bounds | |
| 450 | .into_iter() | |
| 451 | .map(|bound| bound.into_json(renderer)) | |
| 452 | .collect(), | |
| 453 | default: default | |
| 454 | .as_ref() | |
| 455 | .map(|ty| ty.as_ref().into_json(renderer)), | |
| 456 | is_synthetic: *synthetic, | |
| 457 | } | |
| 458 | } | |
| 459 | clean::GenericParamDefKind::Const { ty, default, synthetic: _ } => { | |
| 460 | GenericParamDefKind::Const { | |
| 461 | type_: ty.as_ref().into_json(renderer), | |
| 462 | default: default.as_ref().map(|d| d.as_ref().clone()), | |
| 463 | } | |
| 464 | } | |
| 465 | }; | |
| 466 | GenericParamDef { name, kind } | |
| 467 | }) | |
| 468 | .collect(), | |
| 460 | generic_params: bound_params.into_json(renderer), | |
| 469 | 461 | }, |
| 470 | 462 | RegionPredicate { lifetime, bounds } => WherePredicate::LifetimePredicate { |
| 471 | lifetime: convert_lifetime(lifetime), | |
| 463 | lifetime: lifetime.into_json(renderer), | |
| 472 | 464 | outlives: bounds |
| 473 | 465 | .iter() |
| 474 | 466 | .map(|bound| match bound { |
| 475 | clean::GenericBound::Outlives(lt) => convert_lifetime(lt), | |
| 467 | clean::GenericBound::Outlives(lt) => lt.into_json(renderer), | |
| 476 | 468 | _ => bug!("found non-outlives-bound on lifetime predicate"), |
| 477 | 469 | }) |
| 478 | 470 | .collect(), |
| ... | ... | @@ -496,15 +488,15 @@ impl FromClean<clean::GenericBound> for GenericBound { |
| 496 | 488 | GenericBound::TraitBound { |
| 497 | 489 | trait_: trait_.into_json(renderer), |
| 498 | 490 | generic_params: generic_params.into_json(renderer), |
| 499 | modifier: from_trait_bound_modifier(modifier), | |
| 491 | modifier: modifier.into_json(renderer), | |
| 500 | 492 | } |
| 501 | 493 | } |
| 502 | Outlives(lifetime) => GenericBound::Outlives(convert_lifetime(lifetime)), | |
| 494 | Outlives(lifetime) => GenericBound::Outlives(lifetime.into_json(renderer)), | |
| 503 | 495 | Use(args) => GenericBound::Use( |
| 504 | 496 | args.iter() |
| 505 | 497 | .map(|arg| match arg { |
| 506 | 498 | clean::PreciseCapturingArg::Lifetime(lt) => { |
| 507 | PreciseCapturingArg::Lifetime(convert_lifetime(lt)) | |
| 499 | PreciseCapturingArg::Lifetime(lt.into_json(renderer)) | |
| 508 | 500 | } |
| 509 | 501 | clean::PreciseCapturingArg::Param(param) => { |
| 510 | 502 | PreciseCapturingArg::Param(param.to_string()) |
| ... | ... | @@ -516,19 +508,22 @@ impl FromClean<clean::GenericBound> for GenericBound { |
| 516 | 508 | } |
| 517 | 509 | } |
| 518 | 510 | |
| 519 | pub(crate) fn from_trait_bound_modifier( | |
| 520 | modifiers: &rustc_hir::TraitBoundModifiers, | |
| 521 | ) -> TraitBoundModifier { | |
| 522 | use rustc_hir as hir; | |
| 523 | let hir::TraitBoundModifiers { constness, polarity } = modifiers; | |
| 524 | match (constness, polarity) { | |
| 525 | (hir::BoundConstness::Never, hir::BoundPolarity::Positive) => TraitBoundModifier::None, | |
| 526 | (hir::BoundConstness::Never, hir::BoundPolarity::Maybe(_)) => TraitBoundModifier::Maybe, | |
| 527 | (hir::BoundConstness::Maybe(_), hir::BoundPolarity::Positive) => { | |
| 528 | TraitBoundModifier::MaybeConst | |
| 511 | impl FromClean<rustc_hir::TraitBoundModifiers> for TraitBoundModifier { | |
| 512 | fn from_clean( | |
| 513 | modifiers: &rustc_hir::TraitBoundModifiers, | |
| 514 | _renderer: &JsonRenderer<'_>, | |
| 515 | ) -> Self { | |
| 516 | use rustc_hir as hir; | |
| 517 | let hir::TraitBoundModifiers { constness, polarity } = modifiers; | |
| 518 | match (constness, polarity) { | |
| 519 | (hir::BoundConstness::Never, hir::BoundPolarity::Positive) => TraitBoundModifier::None, | |
| 520 | (hir::BoundConstness::Never, hir::BoundPolarity::Maybe(_)) => TraitBoundModifier::Maybe, | |
| 521 | (hir::BoundConstness::Maybe(_), hir::BoundPolarity::Positive) => { | |
| 522 | TraitBoundModifier::MaybeConst | |
| 523 | } | |
| 524 | // FIXME: Fill out the rest of this matrix. | |
| 525 | _ => TraitBoundModifier::None, | |
| 529 | 526 | } |
| 530 | // FIXME: Fill out the rest of this matrix. | |
| 531 | _ => TraitBoundModifier::None, | |
| 532 | 527 | } |
| 533 | 528 | } |
| 534 | 529 | |
| ... | ... | @@ -542,35 +537,35 @@ impl FromClean<clean::Type> for Type { |
| 542 | 537 | match ty { |
| 543 | 538 | clean::Type::Path { path } => Type::ResolvedPath(path.into_json(renderer)), |
| 544 | 539 | clean::Type::DynTrait(bounds, lt) => Type::DynTrait(DynTrait { |
| 545 | lifetime: lt.as_ref().map(convert_lifetime), | |
| 540 | lifetime: lt.into_json(renderer), | |
| 546 | 541 | traits: bounds.into_json(renderer), |
| 547 | 542 | }), |
| 548 | 543 | Generic(s) => Type::Generic(s.to_string()), |
| 549 | 544 | // FIXME: add dedicated variant to json Type? |
| 550 | 545 | SelfTy => Type::Generic("Self".to_owned()), |
| 551 | 546 | Primitive(p) => Type::Primitive(p.as_sym().to_string()), |
| 552 | BareFunction(f) => Type::FunctionPointer(Box::new(f.as_ref().into_json(renderer))), | |
| 547 | BareFunction(f) => Type::FunctionPointer(Box::new(f.into_json(renderer))), | |
| 553 | 548 | Tuple(t) => Type::Tuple(t.into_json(renderer)), |
| 554 | Slice(t) => Type::Slice(Box::new(t.as_ref().into_json(renderer))), | |
| 549 | Slice(t) => Type::Slice(Box::new(t.into_json(renderer))), | |
| 555 | 550 | Array(t, s) => { |
| 556 | Type::Array { type_: Box::new(t.as_ref().into_json(renderer)), len: s.to_string() } | |
| 551 | Type::Array { type_: Box::new(t.into_json(renderer)), len: s.to_string() } | |
| 557 | 552 | } |
| 558 | 553 | clean::Type::Pat(t, p) => Type::Pat { |
| 559 | type_: Box::new(t.as_ref().into_json(renderer)), | |
| 554 | type_: Box::new(t.into_json(renderer)), | |
| 560 | 555 | __pat_unstable_do_not_use: p.to_string(), |
| 561 | 556 | }, |
| 562 | 557 | ImplTrait(g) => Type::ImplTrait(g.into_json(renderer)), |
| 563 | 558 | Infer => Type::Infer, |
| 564 | 559 | RawPointer(mutability, type_) => Type::RawPointer { |
| 565 | 560 | is_mutable: *mutability == ast::Mutability::Mut, |
| 566 | type_: Box::new(type_.as_ref().into_json(renderer)), | |
| 561 | type_: Box::new(type_.into_json(renderer)), | |
| 567 | 562 | }, |
| 568 | 563 | BorrowedRef { lifetime, mutability, type_ } => Type::BorrowedRef { |
| 569 | lifetime: lifetime.as_ref().map(convert_lifetime), | |
| 564 | lifetime: lifetime.into_json(renderer), | |
| 570 | 565 | is_mutable: *mutability == ast::Mutability::Mut, |
| 571 | type_: Box::new(type_.as_ref().into_json(renderer)), | |
| 566 | type_: Box::new(type_.into_json(renderer)), | |
| 572 | 567 | }, |
| 573 | QPath(qpath) => qpath.as_ref().into_json(renderer), | |
| 568 | QPath(qpath) => qpath.into_json(renderer), | |
| 574 | 569 | // FIXME(unsafe_binder): Implement rustdoc-json. |
| 575 | 570 | UnsafeBinder(_) => todo!(), |
| 576 | 571 | } |
| ... | ... | @@ -578,7 +573,7 @@ impl FromClean<clean::Type> for Type { |
| 578 | 573 | } |
| 579 | 574 | |
| 580 | 575 | impl FromClean<clean::Path> for Path { |
| 581 | fn from_clean(path: &clean::Path, renderer: &JsonRenderer<'_>) -> Path { | |
| 576 | fn from_clean(path: &clean::Path, renderer: &JsonRenderer<'_>) -> Self { | |
| 582 | 577 | Path { |
| 583 | 578 | path: path.whole_name(), |
| 584 | 579 | id: renderer.id_from_item_default(path.def_id().into()), |
| ... | ... | @@ -608,13 +603,13 @@ impl FromClean<clean::QPathData> for Type { |
| 608 | 603 | name: assoc.name.to_string(), |
| 609 | 604 | args: assoc.args.into_json(renderer), |
| 610 | 605 | self_type: Box::new(self_type.into_json(renderer)), |
| 611 | trait_: trait_.as_ref().map(|trait_| trait_.into_json(renderer)), | |
| 606 | trait_: trait_.into_json(renderer), | |
| 612 | 607 | } |
| 613 | 608 | } |
| 614 | 609 | } |
| 615 | 610 | |
| 616 | 611 | impl FromClean<clean::Term> for Term { |
| 617 | fn from_clean(term: &clean::Term, renderer: &JsonRenderer<'_>) -> Term { | |
| 612 | fn from_clean(term: &clean::Term, renderer: &JsonRenderer<'_>) -> Self { | |
| 618 | 613 | match term { |
| 619 | 614 | clean::Term::Type(ty) => Term::Type(ty.into_json(renderer)), |
| 620 | 615 | clean::Term::Constant(c) => Term::Constant(c.into_json(renderer)), |
| ... | ... | @@ -630,7 +625,7 @@ impl FromClean<clean::BareFunctionDecl> for FunctionPointer { |
| 630 | 625 | is_unsafe: safety.is_unsafe(), |
| 631 | 626 | is_const: false, |
| 632 | 627 | is_async: false, |
| 633 | abi: convert_abi(*abi), | |
| 628 | abi: abi.into_json(renderer), | |
| 634 | 629 | }, |
| 635 | 630 | generic_params: generic_params.into_json(renderer), |
| 636 | 631 | sig: decl.into_json(renderer), |
| ... | ... | @@ -709,17 +704,17 @@ impl FromClean<clean::Impl> for Impl { |
| 709 | 704 | .into_iter() |
| 710 | 705 | .map(|x| x.to_string()) |
| 711 | 706 | .collect(), |
| 712 | trait_: trait_.as_ref().map(|path| path.into_json(renderer)), | |
| 707 | trait_: trait_.into_json(renderer), | |
| 713 | 708 | for_: for_.into_json(renderer), |
| 714 | 709 | items: renderer.ids(&items), |
| 715 | 710 | is_negative, |
| 716 | 711 | is_synthetic, |
| 717 | blanket_impl: blanket_impl.map(|x| x.as_ref().into_json(renderer)), | |
| 712 | blanket_impl: blanket_impl.map(|x| x.into_json(renderer)), | |
| 718 | 713 | } |
| 719 | 714 | } |
| 720 | 715 | } |
| 721 | 716 | |
| 722 | pub(crate) fn from_function( | |
| 717 | pub(crate) fn from_clean_function( | |
| 723 | 718 | clean::Function { decl, generics }: &clean::Function, |
| 724 | 719 | has_body: bool, |
| 725 | 720 | header: rustc_hir::FnHeader, |
| ... | ... | @@ -728,7 +723,7 @@ pub(crate) fn from_function( |
| 728 | 723 | Function { |
| 729 | 724 | sig: decl.into_json(renderer), |
| 730 | 725 | generics: generics.into_json(renderer), |
| 731 | header: from_fn_header(&header), | |
| 726 | header: header.into_json(renderer), | |
| 732 | 727 | has_body, |
| 733 | 728 | } |
| 734 | 729 | } |
| ... | ... | @@ -750,7 +745,7 @@ impl FromClean<clean::Variant> for Variant { |
| 750 | 745 | fn from_clean(variant: &clean::Variant, renderer: &JsonRenderer<'_>) -> Self { |
| 751 | 746 | use clean::VariantKind::*; |
| 752 | 747 | |
| 753 | let discriminant = variant.discriminant.as_ref().map(|d| d.into_json(renderer)); | |
| 748 | let discriminant = variant.discriminant.into_json(renderer); | |
| 754 | 749 | |
| 755 | 750 | let kind = match &variant.kind { |
| 756 | 751 | CLike => VariantKind::Plain, |
| ... | ... | @@ -783,10 +778,7 @@ impl FromClean<clean::Import> for Use { |
| 783 | 778 | use clean::ImportKind::*; |
| 784 | 779 | let (name, is_glob) = match import.kind { |
| 785 | 780 | Simple(s) => (s.to_string(), false), |
| 786 | Glob => ( | |
| 787 | import.source.path.last_opt().unwrap_or_else(|| Symbol::intern("*")).to_string(), | |
| 788 | true, | |
| 789 | ), | |
| 781 | Glob => (import.source.path.last_opt().unwrap_or(sym::asterisk).to_string(), true), | |
| 790 | 782 | }; |
| 791 | 783 | Use { |
| 792 | 784 | source: import.source.path.whole_name(), |
| ... | ... | @@ -798,20 +790,22 @@ impl FromClean<clean::Import> for Use { |
| 798 | 790 | } |
| 799 | 791 | |
| 800 | 792 | impl FromClean<clean::ProcMacro> for ProcMacro { |
| 801 | fn from_clean(mac: &clean::ProcMacro, _renderer: &JsonRenderer<'_>) -> Self { | |
| 793 | fn from_clean(mac: &clean::ProcMacro, renderer: &JsonRenderer<'_>) -> Self { | |
| 802 | 794 | ProcMacro { |
| 803 | kind: from_macro_kind(mac.kind), | |
| 795 | kind: mac.kind.into_json(renderer), | |
| 804 | 796 | helpers: mac.helpers.iter().map(|x| x.to_string()).collect(), |
| 805 | 797 | } |
| 806 | 798 | } |
| 807 | 799 | } |
| 808 | 800 | |
| 809 | pub(crate) fn from_macro_kind(kind: rustc_span::hygiene::MacroKind) -> MacroKind { | |
| 810 | use rustc_span::hygiene::MacroKind::*; | |
| 811 | match kind { | |
| 812 | Bang => MacroKind::Bang, | |
| 813 | Attr => MacroKind::Attr, | |
| 814 | Derive => MacroKind::Derive, | |
| 801 | impl FromClean<rustc_span::hygiene::MacroKind> for MacroKind { | |
| 802 | fn from_clean(kind: &rustc_span::hygiene::MacroKind, _renderer: &JsonRenderer<'_>) -> Self { | |
| 803 | use rustc_span::hygiene::MacroKind::*; | |
| 804 | match kind { | |
| 805 | Bang => MacroKind::Bang, | |
| 806 | Attr => MacroKind::Attr, | |
| 807 | Derive => MacroKind::Derive, | |
| 808 | } | |
| 815 | 809 | } |
| 816 | 810 | } |
| 817 | 811 | |
| ... | ... | @@ -822,9 +816,9 @@ impl FromClean<clean::TypeAlias> for TypeAlias { |
| 822 | 816 | } |
| 823 | 817 | } |
| 824 | 818 | |
| 825 | fn convert_static( | |
| 819 | fn from_clean_static( | |
| 826 | 820 | stat: &clean::Static, |
| 827 | safety: &rustc_hir::Safety, | |
| 821 | safety: rustc_hir::Safety, | |
| 828 | 822 | renderer: &JsonRenderer<'_>, |
| 829 | 823 | ) -> Static { |
| 830 | 824 | let tcx = renderer.tcx; |
src/tools/clippy/clippy_lints/src/doc/doc_suspicious_footnotes.rs+10-3| ... | ... | @@ -1,4 +1,5 @@ |
| 1 | 1 | use clippy_utils::diagnostics::span_lint_and_then; |
| 2 | use rustc_ast::attr::AttributeExt as _; | |
| 2 | 3 | use rustc_ast::token::CommentKind; |
| 3 | 4 | use rustc_errors::Applicability; |
| 4 | 5 | use rustc_hir::{AttrStyle, Attribute}; |
| ... | ... | @@ -43,13 +44,19 @@ pub fn check(cx: &LateContext<'_>, doc: &str, range: Range<usize>, fragments: &F |
| 43 | 44 | "looks like a footnote ref, but has no matching footnote", |
| 44 | 45 | |diag| { |
| 45 | 46 | if this_fragment.kind == DocFragmentKind::SugaredDoc { |
| 46 | let (doc_attr, (_, doc_attr_comment_kind)) = attrs | |
| 47 | let (doc_attr, (_, doc_attr_comment_kind), attr_style) = attrs | |
| 47 | 48 | .iter() |
| 48 | 49 | .filter(|attr| attr.span().overlaps(this_fragment.span)) |
| 49 | 50 | .rev() |
| 50 | .find_map(|attr| Some((attr, attr.doc_str_and_comment_kind()?))) | |
| 51 | .find_map(|attr| { | |
| 52 | Some(( | |
| 53 | attr, | |
| 54 | attr.doc_str_and_comment_kind()?, | |
| 55 | attr.doc_resolution_scope()?, | |
| 56 | )) | |
| 57 | }) | |
| 51 | 58 | .unwrap(); |
| 52 | let (to_add, terminator) = match (doc_attr_comment_kind, doc_attr.style()) { | |
| 59 | let (to_add, terminator) = match (doc_attr_comment_kind, attr_style) { | |
| 53 | 60 | (CommentKind::Line, AttrStyle::Outer) => ("\n///\n/// ", ""), |
| 54 | 61 | (CommentKind::Line, AttrStyle::Inner) => ("\n//!\n//! ", ""), |
| 55 | 62 | (CommentKind::Block, AttrStyle::Outer) => ("\n/** ", " */"), |
tests/codegen/asm/critical.rs-1| ... | ... | @@ -1,6 +1,5 @@ |
| 1 | 1 | //@ only-x86_64 |
| 2 | 2 | //@ compile-flags: -C no-prepopulate-passes |
| 3 | #![feature(asm_goto)] | |
| 4 | 3 | #![feature(asm_goto_with_outputs)] |
| 5 | 4 | #![crate_type = "lib"] |
| 6 | 5 | use std::arch::asm; |
tests/run-make/fmt-write-bloat/rmake.rs+2-7| ... | ... | @@ -15,14 +15,9 @@ |
| 15 | 15 | //! `NO_DEBUG_ASSERTIONS=1`). If debug assertions are disabled, then we can check for the absence of |
| 16 | 16 | //! additional `usize` formatting and padding related symbols. |
| 17 | 17 | |
| 18 | //@ ignore-windows | |
| 19 | // Reason: | |
| 20 | // - MSVC targets really need to parse the .pdb file (aka the debug information). | |
| 21 | // On Windows there's an API for that (dbghelp) which maybe we can use | |
| 22 | // - MinGW targets have a lot of symbols included in their runtime which we can't avoid. | |
| 23 | // We would need to make the symbols we're looking for more specific for this test to work. | |
| 24 | 18 | //@ ignore-cross-compile |
| 25 | 19 | |
| 20 | use run_make_support::artifact_names::bin_name; | |
| 26 | 21 | use run_make_support::env::no_debug_assertions; |
| 27 | 22 | use run_make_support::rustc; |
| 28 | 23 | use run_make_support::symbols::any_symbol_contains; |
| ... | ... | @@ -36,5 +31,5 @@ fn main() { |
| 36 | 31 | // otherwise, add them to the list of symbols to deny. |
| 37 | 32 | panic_syms.extend_from_slice(&["panicking", "panic_fmt", "pad_integral", "Display"]); |
| 38 | 33 | } |
| 39 | assert!(!any_symbol_contains("main", &panic_syms)); | |
| 34 | assert!(!any_symbol_contains(bin_name("main"), &panic_syms)); | |
| 40 | 35 | } |
tests/run-make/textrel-on-minimal-lib/rmake.rs+3-5| ... | ... | @@ -6,25 +6,23 @@ |
| 6 | 6 | // See https://github.com/rust-lang/rust/issues/68794 |
| 7 | 7 | |
| 8 | 8 | //@ ignore-cross-compile |
| 9 | //@ ignore-windows | |
| 10 | // Reason: There is no `bar.dll` produced by CC to run readobj on | |
| 11 | 9 | |
| 12 | 10 | use run_make_support::{ |
| 13 | cc, dynamic_lib_name, extra_c_flags, extra_cxx_flags, llvm_readobj, rustc, static_lib_name, | |
| 11 | bin_name, cc, extra_c_flags, extra_cxx_flags, llvm_readobj, rustc, static_lib_name, | |
| 14 | 12 | }; |
| 15 | 13 | |
| 16 | 14 | fn main() { |
| 17 | 15 | rustc().input("foo.rs").run(); |
| 18 | 16 | cc().input("bar.c") |
| 19 | 17 | .input(static_lib_name("foo")) |
| 20 | .out_exe(&dynamic_lib_name("bar")) | |
| 18 | .out_exe(&bin_name("bar")) | |
| 21 | 19 | .arg("-fPIC") |
| 22 | 20 | .arg("-shared") |
| 23 | 21 | .args(extra_c_flags()) |
| 24 | 22 | .args(extra_cxx_flags()) |
| 25 | 23 | .run(); |
| 26 | 24 | llvm_readobj() |
| 27 | .input(dynamic_lib_name("bar")) | |
| 25 | .input(bin_name("bar")) | |
| 28 | 26 | .arg("--dynamic") |
| 29 | 27 | .run() |
| 30 | 28 | .assert_stdout_not_contains("TEXTREL"); |
tests/ui/deprecation/deprecated-expr-precedence.rs created+8| ... | ... | @@ -0,0 +1,8 @@ |
| 1 | //@ check-fail | |
| 2 | //@ compile-flags: --crate-type=lib | |
| 3 | ||
| 4 | // Regression test for issue 142649 | |
| 5 | pub fn public() { | |
| 6 | #[deprecated] 0 | |
| 7 | //~^ ERROR mismatched types | |
| 8 | } |
tests/ui/deprecation/deprecated-expr-precedence.stderr created+11| ... | ... | @@ -0,0 +1,11 @@ |
| 1 | error[E0308]: mismatched types | |
| 2 | --> $DIR/deprecated-expr-precedence.rs:6:19 | |
| 3 | | | |
| 4 | LL | pub fn public() { | |
| 5 | | - help: try adding a return type: `-> i32` | |
| 6 | LL | #[deprecated] 0 | |
| 7 | | ^ expected `()`, found integer | |
| 8 | ||
| 9 | error: aborting due to 1 previous error | |
| 10 | ||
| 11 | For more information about this error, try `rustc --explain E0308`. |
tests/ui/unpretty/deprecated-attr.rs+5| ... | ... | @@ -16,3 +16,8 @@ pub struct SinceAndNote; |
| 16 | 16 | |
| 17 | 17 | #[deprecated(note = "here's why this is deprecated", since = "1.2.3")] |
| 18 | 18 | pub struct FlippedOrder; |
| 19 | ||
| 20 | pub fn f() { | |
| 21 | // Attribute is ignored here (with a warning), but still preserved in HIR | |
| 22 | #[deprecated] 0 | |
| 23 | } |
tests/ui/unpretty/deprecated-attr.stdout+9| ... | ... | @@ -24,3 +24,12 @@ struct SinceAndNote; |
| 24 | 24 | #[attr = Deprecation {deprecation: Deprecation {since: NonStandard("1.2.3"), |
| 25 | 25 | note: "here's why this is deprecated"}}] |
| 26 | 26 | struct FlippedOrder; |
| 27 | ||
| 28 | fn f() { | |
| 29 | ||
| 30 | // Attribute is ignored here (with a warning), but still preserved in HIR | |
| 31 | #[attr = Deprecation {deprecation: | |
| 32 | Deprecation {since: | |
| 33 | Unspecified}}] | |
| 34 | 0 | |
| 35 | } |
tests/ui/unpretty/diagnostic-attr.stdout+1-3| ... | ... | @@ -12,6 +12,4 @@ extern crate std; |
| 12 | 12 | trait ImportantTrait<A> { } |
| 13 | 13 | |
| 14 | 14 | #[diagnostic::do_not_recommend] |
| 15 | impl <T> ImportantTrait<T> for T where T: Clone | |
| 16 | {#![diagnostic::do_not_recommend] | |
| 17 | } | |
| 15 | impl <T> ImportantTrait<T> for T where T: Clone { } |
tests/ui/unpretty/exhaustive-asm.hir.stdout+1-1| ... | ... | @@ -26,7 +26,7 @@ mod expressions { |
| 26 | 26 | |
| 27 | 27 | mod items { |
| 28 | 28 | /// ItemKind::GlobalAsm |
| 29 | mod item_global_asm {/// ItemKind::GlobalAsm | |
| 29 | mod item_global_asm { | |
| 30 | 30 | global_asm! (".globl my_asm_func"); |
| 31 | 31 | } |
| 32 | 32 | } |
tests/ui/unpretty/exhaustive.hir.stdout+28-41| ... | ... | @@ -50,20 +50,14 @@ mod prelude { |
| 50 | 50 | } |
| 51 | 51 | } |
| 52 | 52 | |
| 53 | //! inner single-line doc comment | |
| 54 | /*! | |
| 53 | /// inner single-line doc comment | |
| 54 | /** | |
| 55 | 55 | * inner multi-line doc comment |
| 56 | 56 | */ |
| 57 | 57 | #[doc = "inner doc attribute"] |
| 58 | 58 | #[allow(dead_code, unused_variables)] |
| 59 | 59 | #[no_std] |
| 60 | mod attributes {//! inner single-line doc comment | |
| 61 | /*! | |
| 62 | * inner multi-line doc comment | |
| 63 | */ | |
| 64 | #![doc = "inner doc attribute"] | |
| 65 | #![allow(dead_code, unused_variables)] | |
| 66 | #![no_std] | |
| 60 | mod attributes { | |
| 67 | 61 | |
| 68 | 62 | /// outer single-line doc comment |
| 69 | 63 | /** |
| ... | ... | @@ -413,25 +407,25 @@ mod expressions { |
| 413 | 407 | } |
| 414 | 408 | mod items { |
| 415 | 409 | /// ItemKind::ExternCrate |
| 416 | mod item_extern_crate {/// ItemKind::ExternCrate | |
| 410 | mod item_extern_crate { | |
| 417 | 411 | extern crate core; |
| 418 | 412 | extern crate self as unpretty; |
| 419 | 413 | extern crate core as _; |
| 420 | 414 | } |
| 421 | 415 | /// ItemKind::Use |
| 422 | mod item_use {/// ItemKind::Use | |
| 416 | mod item_use { | |
| 423 | 417 | use ::{}; |
| 424 | 418 | use crate::expressions; |
| 425 | 419 | use crate::items::item_use; |
| 426 | 420 | use core::*; |
| 427 | 421 | } |
| 428 | 422 | /// ItemKind::Static |
| 429 | mod item_static {/// ItemKind::Static | |
| 423 | mod item_static { | |
| 430 | 424 | static A: () = { }; |
| 431 | 425 | static mut B: () = { }; |
| 432 | 426 | } |
| 433 | 427 | /// ItemKind::Const |
| 434 | mod item_const {/// ItemKind::Const | |
| 428 | mod item_const { | |
| 435 | 429 | const A: () = { }; |
| 436 | 430 | trait TraitItems { |
| 437 | 431 | const |
| ... | ... | @@ -445,7 +439,7 @@ mod items { |
| 445 | 439 | } |
| 446 | 440 | } |
| 447 | 441 | /// ItemKind::Fn |
| 448 | mod item_fn {/// ItemKind::Fn | |
| 442 | mod item_fn { | |
| 449 | 443 | const unsafe extern "C" fn f() { } |
| 450 | 444 | async unsafe extern "C" fn g() |
| 451 | 445 | -> |
| ... | ... | @@ -460,21 +454,19 @@ mod items { |
| 460 | 454 | } |
| 461 | 455 | } |
| 462 | 456 | /// ItemKind::Mod |
| 463 | mod item_mod {/// ItemKind::Mod | |
| 464 | } | |
| 457 | mod item_mod { } | |
| 465 | 458 | /// ItemKind::ForeignMod |
| 466 | mod item_foreign_mod {/// ItemKind::ForeignMod | |
| 459 | mod item_foreign_mod { | |
| 467 | 460 | extern "Rust" { } |
| 468 | 461 | extern "C" { } |
| 469 | 462 | } |
| 470 | 463 | /// ItemKind::GlobalAsm: see exhaustive-asm.rs |
| 471 | 464 | /// ItemKind::TyAlias |
| 472 | mod item_ty_alias {/// ItemKind::GlobalAsm: see exhaustive-asm.rs | |
| 473 | /// ItemKind::TyAlias | |
| 465 | mod item_ty_alias { | |
| 474 | 466 | type Type<'a> where T: 'a = T; |
| 475 | 467 | } |
| 476 | 468 | /// ItemKind::Enum |
| 477 | mod item_enum {/// ItemKind::Enum | |
| 469 | mod item_enum { | |
| 478 | 470 | enum Void { } |
| 479 | 471 | enum Empty { |
| 480 | 472 | Unit, |
| ... | ... | @@ -490,7 +482,7 @@ mod items { |
| 490 | 482 | } |
| 491 | 483 | } |
| 492 | 484 | /// ItemKind::Struct |
| 493 | mod item_struct {/// ItemKind::Struct | |
| 485 | mod item_struct { | |
| 494 | 486 | struct Unit; |
| 495 | 487 | struct Tuple(); |
| 496 | 488 | struct Newtype(Unit); |
| ... | ... | @@ -501,45 +493,40 @@ mod items { |
| 501 | 493 | } |
| 502 | 494 | } |
| 503 | 495 | /// ItemKind::Union |
| 504 | mod item_union {/// ItemKind::Union | |
| 496 | mod item_union { | |
| 505 | 497 | union Generic<'a, T> where T: 'a { |
| 506 | 498 | t: T, |
| 507 | 499 | } |
| 508 | 500 | } |
| 509 | 501 | /// ItemKind::Trait |
| 510 | mod item_trait {/// ItemKind::Trait | |
| 502 | mod item_trait { | |
| 511 | 503 | auto unsafe trait Send { } |
| 512 | 504 | trait Trait<'a>: Sized where Self: 'a { } |
| 513 | 505 | } |
| 514 | 506 | /// ItemKind::TraitAlias |
| 515 | mod item_trait_alias {/// ItemKind::TraitAlias | |
| 507 | mod item_trait_alias { | |
| 516 | 508 | trait Trait<T> = Sized where for<'a> T: 'a; |
| 517 | 509 | } |
| 518 | 510 | /// ItemKind::Impl |
| 519 | mod item_impl {/// ItemKind::Impl | |
| 511 | mod item_impl { | |
| 520 | 512 | impl () { } |
| 521 | 513 | impl <T> () { } |
| 522 | 514 | impl Default for () { } |
| 523 | 515 | impl const <T> Default for () { } |
| 524 | 516 | } |
| 525 | 517 | /// ItemKind::MacCall |
| 526 | mod item_mac_call {/// ItemKind::MacCall | |
| 527 | } | |
| 518 | mod item_mac_call { } | |
| 528 | 519 | /// ItemKind::MacroDef |
| 529 | mod item_macro_def {/// ItemKind::MacroDef | |
| 520 | mod item_macro_def { | |
| 530 | 521 | macro_rules! mac { () => {...}; } |
| 531 | 522 | macro stringify { () => {} } |
| 532 | 523 | } |
| 533 | 524 | /// ItemKind::Delegation |
| 534 | /*! FIXME: todo */ | |
| 535 | mod item_delegation {/// ItemKind::Delegation | |
| 536 | /*! FIXME: todo */ | |
| 537 | } | |
| 525 | /** FIXME: todo */ | |
| 526 | mod item_delegation { } | |
| 538 | 527 | /// ItemKind::DelegationMac |
| 539 | /*! FIXME: todo */ | |
| 540 | mod item_delegation_mac {/// ItemKind::DelegationMac | |
| 541 | /*! FIXME: todo */ | |
| 542 | } | |
| 528 | /** FIXME: todo */ | |
| 529 | mod item_delegation_mac { } | |
| 543 | 530 | } |
| 544 | 531 | mod patterns { |
| 545 | 532 | /// PatKind::Missing |
| ... | ... | @@ -690,29 +677,29 @@ mod types { |
| 690 | 677 | /// TyKind::Paren |
| 691 | 678 | fn ty_paren() { let _: T; } |
| 692 | 679 | /// TyKind::Typeof |
| 693 | /*! unused for now */ | |
| 680 | /** unused for now */ | |
| 694 | 681 | fn ty_typeof() { } |
| 695 | 682 | /// TyKind::Infer |
| 696 | 683 | fn ty_infer() { let _: _; } |
| 697 | 684 | /// TyKind::ImplicitSelf |
| 698 | /*! there is no syntax for this */ | |
| 685 | /** there is no syntax for this */ | |
| 699 | 686 | fn ty_implicit_self() { } |
| 700 | 687 | /// TyKind::MacCall |
| 701 | 688 | #[expect(deprecated)] |
| 702 | 689 | fn ty_mac_call() { let _: T; let _: T; let _: T; } |
| 703 | 690 | /// TyKind::CVarArgs |
| 704 | /*! FIXME: todo */ | |
| 691 | /** FIXME: todo */ | |
| 705 | 692 | fn ty_c_var_args() { } |
| 706 | 693 | /// TyKind::Pat |
| 707 | 694 | fn ty_pat() { let _: u32 is 1..=RangeMax; } |
| 708 | 695 | } |
| 709 | 696 | mod visibilities { |
| 710 | 697 | /// VisibilityKind::Public |
| 711 | mod visibility_public {/// VisibilityKind::Public | |
| 698 | mod visibility_public { | |
| 712 | 699 | struct Pub; |
| 713 | 700 | } |
| 714 | 701 | /// VisibilityKind::Restricted |
| 715 | mod visibility_restricted {/// VisibilityKind::Restricted | |
| 702 | mod visibility_restricted { | |
| 716 | 703 | struct PubCrate; |
| 717 | 704 | struct PubSelf; |
| 718 | 705 | struct PubSuper; |
triagebot.toml+4| ... | ... | @@ -1023,6 +1023,10 @@ Otherwise, you can ignore this comment. |
| 1023 | 1023 | [mentions."src/tools/x"] |
| 1024 | 1024 | message = "`src/tools/x` was changed. Bump version of Cargo.toml in `src/tools/x` so tidy will suggest installing the new version." |
| 1025 | 1025 | |
| 1026 | [mentions."src/tools/tidy"] | |
| 1027 | message = "There are changes to the `tidy` tool." | |
| 1028 | cc = ["@jieyouxu"] | |
| 1029 | ||
| 1026 | 1030 | [mentions."src/tools/tidy/src/deps.rs"] |
| 1027 | 1031 | message = "The list of allowed third-party dependencies may have been modified! You must ensure that any new dependencies have compatible licenses before merging." |
| 1028 | 1032 | cc = ["@davidtwco", "@wesleywiser"] |