diff --git a/compiler/rustc_lint/src/array_into_iter.rs b/compiler/rustc_lint/src/array_into_iter.rs index 0b5bd39f7f984..727d9ea353190 100644 --- a/compiler/rustc_lint/src/array_into_iter.rs +++ b/compiler/rustc_lint/src/array_into_iter.rs @@ -3,8 +3,8 @@ use rustc_errors::Applicability; use rustc_hir as hir; use rustc_middle::ty; use rustc_middle::ty::adjustment::{Adjust, Adjustment}; -use rustc_session::lint::FutureBreakage; use rustc_span::symbol::sym; +use rustc_span::Span; declare_lint! { /// The `array_into_iter` lint detects calling `into_iter` on arrays. @@ -20,37 +20,40 @@ declare_lint! { /// /// ### Explanation /// - /// In the future, it is planned to add an `IntoIter` implementation for - /// arrays such that it will iterate over *values* of the array instead of - /// references. Due to how method resolution works, this will change - /// existing code that uses `into_iter` on arrays. The solution to avoid - /// this warning is to use `iter()` instead of `into_iter()`. - /// - /// This is a [future-incompatible] lint to transition this to a hard error - /// in the future. See [issue #66145] for more details and a more thorough - /// description of the lint. - /// - /// [issue #66145]: https://github.com/rust-lang/rust/issues/66145 - /// [future-incompatible]: ../index.md#future-incompatible-lints + /// Since Rust 1.53, arrays implement `IntoIterator`. However, to avoid + /// breakage, `array.into_iter()` in Rust 2015 and 2018 code will still + /// behave as `(&array).into_iter()`, returning an iterator over + /// references, just like in Rust 1.52 and earlier. + /// This only applies to the method call syntax `array.into_iter()`, not to + /// any other syntax such as `for _ in array` or `IntoIterator::into_iter(array)`. pub ARRAY_INTO_ITER, Warn, - "detects calling `into_iter` on arrays", - @future_incompatible = FutureIncompatibleInfo { - reference: "issue #66145 ", - edition: None, - future_breakage: Some(FutureBreakage { - date: None - }) - }; + "detects calling `into_iter` on arrays in Rust 2015 and 2018", +} + +#[derive(Copy, Clone, Default)] +pub struct ArrayIntoIter { + for_expr_span: Span, } -declare_lint_pass!( - /// Checks for instances of calling `into_iter` on arrays. - ArrayIntoIter => [ARRAY_INTO_ITER] -); +impl_lint_pass!(ArrayIntoIter => [ARRAY_INTO_ITER]); impl<'tcx> LateLintPass<'tcx> for ArrayIntoIter { fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx hir::Expr<'tcx>) { + // Save the span of expressions in `for _ in expr` syntax, + // so we can give a better suggestion for those later. + if let hir::ExprKind::Match(arg, [_], hir::MatchSource::ForLoopDesugar) = &expr.kind { + if let hir::ExprKind::Call(path, [arg]) = &arg.kind { + if let hir::ExprKind::Path(hir::QPath::LangItem( + hir::LangItem::IntoIterIntoIter, + _, + )) = &path.kind + { + self.for_expr_span = arg.span; + } + } + } + // We only care about method call expressions. if let hir::ExprKind::MethodCall(call, span, args, _) = &expr.kind { if call.ident.name != sym::into_iter { @@ -106,19 +109,37 @@ impl<'tcx> LateLintPass<'tcx> for ArrayIntoIter { _ => bug!("array type coerced to something other than array or slice"), }; cx.struct_span_lint(ARRAY_INTO_ITER, *span, |lint| { - lint.build(&format!( - "this method call currently resolves to `<&{} as IntoIterator>::into_iter` (due \ - to autoref coercions), but that might change in the future when \ - `IntoIterator` impls for arrays are added.", - target, - )) - .span_suggestion( + let mut diag = lint.build(&format!( + "this method call resolves to `<&{} as IntoIterator>::into_iter` \ + (due to backwards compatibility), \ + but will resolve to <{} as IntoIterator>::into_iter in Rust 2021.", + target, target, + )); + diag.span_suggestion( call.ident.span, "use `.iter()` instead of `.into_iter()` to avoid ambiguity", "iter".into(), Applicability::MachineApplicable, - ) - .emit(); + ); + if self.for_expr_span == expr.span { + let expr_span = expr.span.ctxt().outer_expn_data().call_site; + diag.span_suggestion( + receiver_arg.span.shrink_to_hi().to(expr_span.shrink_to_hi()), + "or remove `.into_iter()` to iterate by value", + String::new(), + Applicability::MaybeIncorrect, + ); + } else { + diag.multipart_suggestion( + "or use `IntoIterator::into_iter(..)` instead of `.into_iter()` to explicitly iterate by value", + vec![ + (expr.span.shrink_to_lo(), "IntoIterator::into_iter(".into()), + (receiver_arg.span.shrink_to_hi().to(expr.span.shrink_to_hi()), ")".into()), + ], + Applicability::MaybeIncorrect, + ); + } + diag.emit(); }) } } diff --git a/compiler/rustc_lint/src/lib.rs b/compiler/rustc_lint/src/lib.rs index 4f59460aa82a4..89f9809d643e0 100644 --- a/compiler/rustc_lint/src/lib.rs +++ b/compiler/rustc_lint/src/lib.rs @@ -163,7 +163,7 @@ macro_rules! late_lint_passes { // FIXME: Turn the computation of types which implement Debug into a query // and change this to a module lint pass MissingDebugImplementations: MissingDebugImplementations::default(), - ArrayIntoIter: ArrayIntoIter, + ArrayIntoIter: ArrayIntoIter::default(), ClashingExternDeclarations: ClashingExternDeclarations::new(), DropTraitConstraints: DropTraitConstraints, TemporaryCStringAsPtr: TemporaryCStringAsPtr, diff --git a/compiler/rustc_middle/src/mir/mod.rs b/compiler/rustc_middle/src/mir/mod.rs index 0daaec272fd90..672686410f9bf 100644 --- a/compiler/rustc_middle/src/mir/mod.rs +++ b/compiler/rustc_middle/src/mir/mod.rs @@ -494,6 +494,8 @@ impl<'tcx> Body<'tcx> { #[derive(Copy, Clone, PartialEq, Eq, Debug, TyEncodable, TyDecodable, HashStable)] pub enum Safety { Safe, + /// Unsafe because of compiler-generated unsafe code, like `await` desugaring + BuiltinUnsafe, /// Unsafe because of an unsafe fn FnUnsafe, /// Unsafe because of an `unsafe` block diff --git a/compiler/rustc_middle/src/thir.rs b/compiler/rustc_middle/src/thir.rs index 2f107e7b96c5c..6b2e542ee7051 100644 --- a/compiler/rustc_middle/src/thir.rs +++ b/compiler/rustc_middle/src/thir.rs @@ -114,6 +114,7 @@ pub struct Adt<'tcx> { #[derive(Copy, Clone, Debug, HashStable)] pub enum BlockSafety { Safe, + BuiltinUnsafe, ExplicitUnsafe(hir::HirId), } diff --git a/compiler/rustc_mir/src/transform/check_unsafety.rs b/compiler/rustc_mir/src/transform/check_unsafety.rs index 324a5257f5dfa..103ddda1a1d26 100644 --- a/compiler/rustc_mir/src/transform/check_unsafety.rs +++ b/compiler/rustc_mir/src/transform/check_unsafety.rs @@ -321,6 +321,7 @@ impl<'a, 'tcx> UnsafetyChecker<'a, 'tcx> { } false } + Safety::BuiltinUnsafe => true, Safety::ExplicitUnsafe(hir_id) => { // mark unsafe block as used if there are any unsafe operations inside if !violations.is_empty() { diff --git a/compiler/rustc_mir_build/src/build/block.rs b/compiler/rustc_mir_build/src/build/block.rs index 4e1983aca9443..df71379c1d886 100644 --- a/compiler/rustc_mir_build/src/build/block.rs +++ b/compiler/rustc_mir_build/src/build/block.rs @@ -214,6 +214,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { debug!("update_source_scope_for({:?}, {:?})", span, safety_mode); let new_unsafety = match safety_mode { BlockSafety::Safe => None, + BlockSafety::BuiltinUnsafe => Some(Safety::BuiltinUnsafe), BlockSafety::ExplicitUnsafe(hir_id) => { match self.in_scope_unsafe { Safety::Safe => {} diff --git a/compiler/rustc_mir_build/src/check_unsafety.rs b/compiler/rustc_mir_build/src/check_unsafety.rs index e4ed5dece8622..4e80931ec0370 100644 --- a/compiler/rustc_mir_build/src/check_unsafety.rs +++ b/compiler/rustc_mir_build/src/check_unsafety.rs @@ -29,11 +29,7 @@ struct UnsafetyVisitor<'a, 'tcx> { } impl<'tcx> UnsafetyVisitor<'_, 'tcx> { - fn in_safety_context( - &mut self, - safety_context: SafetyContext, - f: impl FnOnce(&mut Self) -> R, - ) { + fn in_safety_context(&mut self, safety_context: SafetyContext, f: impl FnOnce(&mut Self)) { if let ( SafetyContext::UnsafeBlock { span: enclosing_span, .. }, SafetyContext::UnsafeBlock { span: block_span, hir_id, .. }, @@ -63,7 +59,6 @@ impl<'tcx> UnsafetyVisitor<'_, 'tcx> { ); } self.safety_context = prev_context; - return; } } @@ -71,6 +66,7 @@ impl<'tcx> UnsafetyVisitor<'_, 'tcx> { let (description, note) = kind.description_and_note(); let unsafe_op_in_unsafe_fn_allowed = self.unsafe_op_in_unsafe_fn_allowed(); match self.safety_context { + SafetyContext::BuiltinUnsafeBlock => {} SafetyContext::UnsafeBlock { ref mut used, .. } => { if !self.body_unsafety.is_unsafe() || !unsafe_op_in_unsafe_fn_allowed { // Mark this block as useful @@ -142,13 +138,23 @@ impl<'a, 'tcx> Visitor<'a, 'tcx> for UnsafetyVisitor<'a, 'tcx> { } fn visit_block(&mut self, block: &Block) { - if let BlockSafety::ExplicitUnsafe(hir_id) = block.safety_mode { - self.in_safety_context( - SafetyContext::UnsafeBlock { span: block.span, hir_id, used: false }, - |this| visit::walk_block(this, block), - ); - } else { - visit::walk_block(self, block); + match block.safety_mode { + // compiler-generated unsafe code should not count towards the usefulness of + // an outer unsafe block + BlockSafety::BuiltinUnsafe => { + self.in_safety_context(SafetyContext::BuiltinUnsafeBlock, |this| { + visit::walk_block(this, block) + }); + } + BlockSafety::ExplicitUnsafe(hir_id) => { + self.in_safety_context( + SafetyContext::UnsafeBlock { span: block.span, hir_id, used: false }, + |this| visit::walk_block(this, block), + ); + } + BlockSafety::Safe => { + visit::walk_block(self, block); + } } } @@ -250,6 +256,7 @@ impl<'a, 'tcx> Visitor<'a, 'tcx> for UnsafetyVisitor<'a, 'tcx> { #[derive(Clone, Copy)] enum SafetyContext { Safe, + BuiltinUnsafeBlock, UnsafeFn, UnsafeBlock { span: Span, hir_id: hir::HirId, used: bool }, } diff --git a/compiler/rustc_mir_build/src/thir/cx/block.rs b/compiler/rustc_mir_build/src/thir/cx/block.rs index 4fe8cd8541aae..2d9b5c1d98aab 100644 --- a/compiler/rustc_mir_build/src/thir/cx/block.rs +++ b/compiler/rustc_mir_build/src/thir/cx/block.rs @@ -26,7 +26,12 @@ impl<'tcx> Cx<'tcx> { expr: block.expr.map(|expr| self.mirror_expr(expr)), safety_mode: match block.rules { hir::BlockCheckMode::DefaultBlock => BlockSafety::Safe, - hir::BlockCheckMode::UnsafeBlock(..) => BlockSafety::ExplicitUnsafe(block.hir_id), + hir::BlockCheckMode::UnsafeBlock(hir::UnsafeSource::CompilerGenerated) => { + BlockSafety::BuiltinUnsafe + } + hir::BlockCheckMode::UnsafeBlock(hir::UnsafeSource::UserProvided) => { + BlockSafety::ExplicitUnsafe(block.hir_id) + } }, } } diff --git a/src/librustdoc/clean/types.rs b/src/librustdoc/clean/types.rs index 6a7c3f8caa49f..66f62d97b047d 100644 --- a/src/librustdoc/clean/types.rs +++ b/src/librustdoc/clean/types.rs @@ -523,6 +523,33 @@ impl Item { .collect() } + /// Find a list of all link names, without finding their href. + /// + /// This is used for generating summary text, which does not include + /// the link text, but does need to know which `[]`-bracketed names + /// are actually links. + crate fn link_names(&self, cache: &Cache) -> Vec { + cache + .intra_doc_links + .get(&self.def_id) + .map_or(&[][..], |v| v.as_slice()) + .iter() + .filter_map(|ItemLink { link: s, link_text, did, fragment }| { + // FIXME(83083): using fragments as a side-channel for + // primitive names is very unfortunate + if did.is_some() || fragment.is_some() { + Some(RenderedLink { + original_text: s.clone(), + new_text: link_text.clone(), + href: String::new(), + }) + } else { + None + } + }) + .collect() + } + crate fn is_crate(&self) -> bool { self.is_mod() && self.def_id.as_real().map_or(false, |did| did.index == CRATE_DEF_INDEX) } diff --git a/src/librustdoc/doctest.rs b/src/librustdoc/doctest.rs index 88e2f6048e9c7..1750f05b4dcff 100644 --- a/src/librustdoc/doctest.rs +++ b/src/librustdoc/doctest.rs @@ -3,6 +3,7 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_data_structures::sync::Lrc; use rustc_errors::{ColorConfig, ErrorReported}; use rustc_hir as hir; +use rustc_hir::def_id::LOCAL_CRATE; use rustc_hir::intravisit; use rustc_hir::{HirId, CRATE_HIR_ID}; use rustc_interface::interface; @@ -13,6 +14,7 @@ use rustc_session::{lint, DiagnosticOutput, Session}; use rustc_span::edition::Edition; use rustc_span::source_map::SourceMap; use rustc_span::symbol::sym; +use rustc_span::Symbol; use rustc_span::{BytePos, FileName, Pos, Span, DUMMY_SP}; use rustc_target::spec::TargetTriple; use tempfile::Builder as TempFileBuilder; @@ -111,8 +113,6 @@ crate fn run(options: Options) -> Result<(), ErrorReported> { let res = interface::run_compiler(config, |compiler| { compiler.enter(|queries| { let _lower_to_hir = queries.lower_to_hir()?; - - let crate_name = queries.crate_name()?.peek().to_string(); let mut global_ctxt = queries.global_ctxt()?.take(); let collector = global_ctxt.enter(|tcx| { @@ -123,7 +123,7 @@ crate fn run(options: Options) -> Result<(), ErrorReported> { opts.display_warnings |= options.display_warnings; let enable_per_target_ignores = options.enable_per_target_ignores; let mut collector = Collector::new( - crate_name, + tcx.crate_name(LOCAL_CRATE), options, false, opts, @@ -293,7 +293,7 @@ struct UnusedExterns { fn run_test( test: &str, - cratename: &str, + crate_name: &str, line: usize, options: Options, should_panic: bool, @@ -312,7 +312,7 @@ fn run_test( report_unused_externs: impl Fn(UnusedExterns), ) -> Result<(), TestFailure> { let (test, line_offset, supports_color) = - make_test(test, Some(cratename), as_test_harness, opts, edition, Some(test_id)); + make_test(test, Some(crate_name), as_test_harness, opts, edition, Some(test_id)); let output_file = outdir.path().join("rust_out"); @@ -479,7 +479,7 @@ fn run_test( /// lines before the test code begins as well as if the output stream supports colors or not. crate fn make_test( s: &str, - cratename: Option<&str>, + crate_name: Option<&str>, dont_insert_main: bool, opts: &TestOptions, edition: Edition, @@ -540,7 +540,7 @@ crate fn make_test( let sess = ParseSess::with_span_handler(handler, sm); let mut found_main = false; - let mut found_extern_crate = cratename.is_none(); + let mut found_extern_crate = crate_name.is_none(); let mut found_macro = false; let mut parser = match maybe_new_parser_from_source_str(&sess, filename, source) { @@ -567,13 +567,13 @@ crate fn make_test( if !found_extern_crate { if let ast::ItemKind::ExternCrate(original) = item.kind { - // This code will never be reached if `cratename` is none because + // This code will never be reached if `crate_name` is none because // `found_extern_crate` is initialized to `true` if it is none. - let cratename = cratename.unwrap(); + let crate_name = crate_name.unwrap(); match original { - Some(name) => found_extern_crate = name.as_str() == cratename, - None => found_extern_crate = item.ident.as_str() == cratename, + Some(name) => found_extern_crate = name.as_str() == crate_name, + None => found_extern_crate = item.ident.as_str() == crate_name, } } } @@ -631,14 +631,14 @@ crate fn make_test( // Don't inject `extern crate std` because it's already injected by the // compiler. - if !already_has_extern_crate && !opts.no_crate_inject && cratename != Some("std") { - if let Some(cratename) = cratename { + if !already_has_extern_crate && !opts.no_crate_inject && crate_name != Some("std") { + if let Some(crate_name) = crate_name { // Don't inject `extern crate` if the crate is never used. // NOTE: this is terribly inaccurate because it doesn't actually // parse the source, but only has false positives, not false // negatives. - if s.contains(cratename) { - prog.push_str(&format!("extern crate r#{};\n", cratename)); + if s.contains(crate_name) { + prog.push_str(&format!("extern crate r#{};\n", crate_name)); line_offset += 1; } } @@ -797,7 +797,7 @@ crate struct Collector { options: Options, use_headers: bool, enable_per_target_ignores: bool, - cratename: String, + crate_name: Symbol, opts: TestOptions, position: Span, source_map: Option>, @@ -809,7 +809,7 @@ crate struct Collector { impl Collector { crate fn new( - cratename: String, + crate_name: Symbol, options: Options, use_headers: bool, opts: TestOptions, @@ -823,7 +823,7 @@ impl Collector { options, use_headers, enable_per_target_ignores, - cratename, + crate_name, opts, position: DUMMY_SP, source_map, @@ -871,7 +871,7 @@ impl Tester for Collector { fn add_test(&mut self, test: String, config: LangString, line: usize) { let filename = self.get_filename(); let name = self.generate_name(line, &filename); - let cratename = self.cratename.to_string(); + let crate_name = self.crate_name.to_string(); let opts = self.opts.clone(); let edition = config.edition.unwrap_or(self.options.edition); let options = self.options.clone(); @@ -954,7 +954,7 @@ impl Tester for Collector { }; let res = run_test( &test, - &cratename, + &crate_name, line, options, config.should_panic, diff --git a/src/librustdoc/formats/cache.rs b/src/librustdoc/formats/cache.rs index 5734a4a98e2b5..811f682920107 100644 --- a/src/librustdoc/formats/cache.rs +++ b/src/librustdoc/formats/cache.rs @@ -292,13 +292,14 @@ impl<'a, 'tcx> DocFolder for CacheBuilder<'a, 'tcx> { // which should not be indexed. The crate-item itself is // inserted later on when serializing the search-index. if item.def_id.index().map_or(false, |idx| idx != CRATE_DEF_INDEX) { + let desc = item.doc_value().map_or_else(String::new, |x| { + short_markdown_summary(&x.as_str(), &item.link_names(&self.cache)) + }); self.cache.search_index.push(IndexItem { ty: item.type_(), name: s.to_string(), path: path.join("::"), - desc: item - .doc_value() - .map_or_else(String::new, |x| short_markdown_summary(&x.as_str())), + desc, parent, parent_idx: None, search_type: get_index_search_type(&item, &self.empty_cache, self.tcx), diff --git a/src/librustdoc/html/markdown.rs b/src/librustdoc/html/markdown.rs index 00a91e07d65e3..bafb522f36338 100644 --- a/src/librustdoc/html/markdown.rs +++ b/src/librustdoc/html/markdown.rs @@ -1051,7 +1051,11 @@ impl MarkdownSummaryLine<'_> { /// /// Returns a tuple of the rendered HTML string and whether the output was shortened /// due to the provided `length_limit`. -fn markdown_summary_with_limit(md: &str, length_limit: usize) -> (String, bool) { +fn markdown_summary_with_limit( + md: &str, + link_names: &[RenderedLink], + length_limit: usize, +) -> (String, bool) { if md.is_empty() { return (String::new(), false); } @@ -1065,7 +1069,20 @@ fn markdown_summary_with_limit(md: &str, length_limit: usize) -> (String, bool) *text_length += text.len(); } - 'outer: for event in Parser::new_ext(md, summary_opts()) { + let mut replacer = |broken_link: BrokenLink<'_>| { + if let Some(link) = + link_names.iter().find(|link| &*link.original_text == broken_link.reference) + { + Some((link.href.as_str().into(), link.new_text.as_str().into())) + } else { + None + } + }; + + let p = Parser::new_with_broken_link_callback(md, opts(), Some(&mut replacer)); + let p = LinkReplacer::new(p, link_names); + + 'outer: for event in p { match &event { Event::Text(text) => { for word in text.split_inclusive(char::is_whitespace) { @@ -1121,8 +1138,8 @@ fn markdown_summary_with_limit(md: &str, length_limit: usize) -> (String, bool) /// Will shorten to 59 or 60 characters, including an ellipsis (…) if it was shortened. /// /// See [`markdown_summary_with_limit`] for details about what is rendered and what is not. -crate fn short_markdown_summary(markdown: &str) -> String { - let (mut s, was_shortened) = markdown_summary_with_limit(markdown, 59); +crate fn short_markdown_summary(markdown: &str, link_names: &[RenderedLink]) -> String { + let (mut s, was_shortened) = markdown_summary_with_limit(markdown, link_names, 59); if was_shortened { s.push('…'); diff --git a/src/librustdoc/html/markdown/tests.rs b/src/librustdoc/html/markdown/tests.rs index ac3ea4c8c5f6f..d10da64ccfaa5 100644 --- a/src/librustdoc/html/markdown/tests.rs +++ b/src/librustdoc/html/markdown/tests.rs @@ -221,7 +221,7 @@ fn test_header_ids_multiple_blocks() { #[test] fn test_short_markdown_summary() { fn t(input: &str, expect: &str) { - let output = short_markdown_summary(input); + let output = short_markdown_summary(input, &[][..]); assert_eq!(output, expect, "original: {}", input); } @@ -232,6 +232,7 @@ fn test_short_markdown_summary() { t("Hard-break \nsummary", "Hard-break summary"); t("hello [Rust] :)\n\n[Rust]: https://www.rust-lang.org", "hello Rust :)"); t("hello [Rust](https://www.rust-lang.org \"Rust\") :)", "hello Rust :)"); + t("dud [link]", "dud [link]"); t("code `let x = i32;` ...", "code let x = i32; …"); t("type `Type<'static>` ...", "type Type<'static> …"); t("# top header", "top header"); @@ -259,6 +260,7 @@ fn test_plain_text_summary() { t("Hard-break \nsummary", "Hard-break summary"); t("hello [Rust] :)\n\n[Rust]: https://www.rust-lang.org", "hello Rust :)"); t("hello [Rust](https://www.rust-lang.org \"Rust\") :)", "hello Rust :)"); + t("dud [link]", "dud [link]"); t("code `let x = i32;` ...", "code `let x = i32;` …"); t("type `Type<'static>` ...", "type `Type<'static>` …"); t("# top header", "top header"); diff --git a/src/librustdoc/html/render/cache.rs b/src/librustdoc/html/render/cache.rs index 3e056c4b67a70..5b3c445013b54 100644 --- a/src/librustdoc/html/render/cache.rs +++ b/src/librustdoc/html/render/cache.rs @@ -34,11 +34,14 @@ crate fn build_index<'tcx>(krate: &clean::Crate, cache: &mut Cache, tcx: TyCtxt< // has since been learned. for &(did, ref item) in &cache.orphan_impl_items { if let Some(&(ref fqp, _)) = cache.paths.get(&did) { + let desc = item + .doc_value() + .map_or_else(String::new, |s| short_markdown_summary(&s, &item.link_names(&cache))); cache.search_index.push(IndexItem { ty: item.type_(), name: item.name.unwrap().to_string(), path: fqp[..fqp.len() - 1].join("::"), - desc: item.doc_value().map_or_else(String::new, |s| short_markdown_summary(&s)), + desc, parent: Some(did.into()), parent_idx: None, search_type: get_index_search_type(&item, cache, tcx), @@ -47,6 +50,11 @@ crate fn build_index<'tcx>(krate: &clean::Crate, cache: &mut Cache, tcx: TyCtxt< } } + let crate_doc = krate + .module + .doc_value() + .map_or_else(String::new, |s| short_markdown_summary(&s, &krate.module.link_names(&cache))); + let Cache { ref mut search_index, ref paths, .. } = *cache; // Aliases added through `#[doc(alias = "...")]`. Since a few items can have the same alias, @@ -100,9 +108,6 @@ crate fn build_index<'tcx>(krate: &clean::Crate, cache: &mut Cache, tcx: TyCtxt< crate_items.push(&*item); } - let crate_doc = - krate.module.doc_value().map_or_else(String::new, |s| short_markdown_summary(&s)); - struct CrateData<'a> { doc: String, items: Vec<&'a IndexItem>, diff --git a/src/librustdoc/html/render/write_shared.rs b/src/librustdoc/html/render/write_shared.rs index 840566731d78d..94a902a2d0522 100644 --- a/src/librustdoc/html/render/write_shared.rs +++ b/src/librustdoc/html/render/write_shared.rs @@ -25,10 +25,16 @@ static FILES_UNVERSIONED: Lazy> = Lazy::new(|| { "FiraSans-Regular.woff" => static_files::fira_sans::REGULAR, "FiraSans-Medium.woff" => static_files::fira_sans::MEDIUM, "FiraSans-LICENSE.txt" => static_files::fira_sans::LICENSE, + "SourceSerif4-Regular.ttf.woff2" => static_files::source_serif_4::REGULAR2, + "SourceSerif4-Bold.ttf.woff2" => static_files::source_serif_4::BOLD2, + "SourceSerif4-It.ttf.woff2" => static_files::source_serif_4::ITALIC2, "SourceSerif4-Regular.ttf.woff" => static_files::source_serif_4::REGULAR, "SourceSerif4-Bold.ttf.woff" => static_files::source_serif_4::BOLD, "SourceSerif4-It.ttf.woff" => static_files::source_serif_4::ITALIC, "SourceSerif4-LICENSE.md" => static_files::source_serif_4::LICENSE, + "SourceCodePro-Regular.ttf.woff2" => static_files::source_code_pro::REGULAR2, + "SourceCodePro-Semibold.ttf.woff2" => static_files::source_code_pro::SEMIBOLD2, + "SourceCodePro-It.ttf.woff2" => static_files::source_code_pro::ITALIC2, "SourceCodePro-Regular.ttf.woff" => static_files::source_code_pro::REGULAR, "SourceCodePro-Semibold.ttf.woff" => static_files::source_code_pro::SEMIBOLD, "SourceCodePro-It.ttf.woff" => static_files::source_code_pro::ITALIC, diff --git a/src/librustdoc/html/static/COPYRIGHT.txt b/src/librustdoc/html/static/COPYRIGHT.txt index 16d79032fcc63..c2629a83f7092 100644 --- a/src/librustdoc/html/static/COPYRIGHT.txt +++ b/src/librustdoc/html/static/COPYRIGHT.txt @@ -2,7 +2,8 @@ These documentation pages include resources by third parties. This copyright file applies only to those resources. The following third party resources are included, and carry their own copyright notices and license terms: -* Fira Sans (FiraSans-Regular.woff, FiraSans-Medium.woff): +* Fira Sans (FiraSans-Regular.woff2, FiraSans-Medium.woff2, + FiraSans-Regular.woff, FiraSans-Medium.woff): Copyright (c) 2014, Mozilla Foundation https://mozilla.org/ with Reserved Font Name Fira Sans. @@ -23,8 +24,10 @@ included, and carry their own copyright notices and license terms: Copyright (c) Nicolas Gallagher and Jonathan Neal. Licensed under the MIT license (see LICENSE-MIT.txt). -* Source Code Pro (SourceCodePro-Regular.ttf.woff, - SourceCodePro-Semibold.ttf.woff, SourceCodePro-It.ttf.woff): +* Source Code Pro (SourceCodePro-Regular.ttf.woff2, + SourceCodePro-Semibold.ttf.woff2, SourceCodePro-It.ttf.woff2, + SourceCodePro-Regular.ttf.woff, SourceCodePro-Semibold.ttf.woff, + SourceCodePro-It.ttf.woff): Copyright 2010, 2012 Adobe Systems Incorporated (http://www.adobe.com/), with Reserved Font Name 'Source'. All Rights Reserved. Source is a trademark @@ -33,8 +36,9 @@ included, and carry their own copyright notices and license terms: Licensed under the SIL Open Font License, Version 1.1. See SourceCodePro-LICENSE.txt. -* Source Serif 4 (SourceSerif4-Regular.ttf.woff, SourceSerif4-Bold.ttf.woff, - SourceSerif4-It.ttf.woff): +* Source Serif 4 (SourceSerif4-Regular.ttf.woff2, SourceSerif4-Bold.ttf.woff2, + SourceSerif4-It.ttf.woff2, SourceSerif4-Regular.ttf.woff, + SourceSerif4-Bold.ttf.woff, SourceSerif4-It.ttf.woff): Copyright 2014-2021 Adobe (http://www.adobe.com/), with Reserved Font Name 'Source'. All Rights Reserved. Source is a trademark of Adobe in the United diff --git a/src/librustdoc/html/static/SourceCodePro-It.ttf.woff2 b/src/librustdoc/html/static/SourceCodePro-It.ttf.woff2 new file mode 100644 index 0000000000000..462c34efcd9d6 Binary files /dev/null and b/src/librustdoc/html/static/SourceCodePro-It.ttf.woff2 differ diff --git a/src/librustdoc/html/static/SourceCodePro-Regular.ttf.woff2 b/src/librustdoc/html/static/SourceCodePro-Regular.ttf.woff2 new file mode 100644 index 0000000000000..10b558e0b69a7 Binary files /dev/null and b/src/librustdoc/html/static/SourceCodePro-Regular.ttf.woff2 differ diff --git a/src/librustdoc/html/static/SourceCodePro-Semibold.ttf.woff2 b/src/librustdoc/html/static/SourceCodePro-Semibold.ttf.woff2 new file mode 100644 index 0000000000000..5ec64eef0ec94 Binary files /dev/null and b/src/librustdoc/html/static/SourceCodePro-Semibold.ttf.woff2 differ diff --git a/src/librustdoc/html/static/SourceSerif4-Bold.ttf.woff2 b/src/librustdoc/html/static/SourceSerif4-Bold.ttf.woff2 new file mode 100644 index 0000000000000..db57d21455c94 Binary files /dev/null and b/src/librustdoc/html/static/SourceSerif4-Bold.ttf.woff2 differ diff --git a/src/librustdoc/html/static/SourceSerif4-It.ttf.woff2 b/src/librustdoc/html/static/SourceSerif4-It.ttf.woff2 new file mode 100644 index 0000000000000..1cbc021a3aa22 Binary files /dev/null and b/src/librustdoc/html/static/SourceSerif4-It.ttf.woff2 differ diff --git a/src/librustdoc/html/static/SourceSerif4-Regular.ttf.woff2 b/src/librustdoc/html/static/SourceSerif4-Regular.ttf.woff2 new file mode 100644 index 0000000000000..2db73fe2b49e8 Binary files /dev/null and b/src/librustdoc/html/static/SourceSerif4-Regular.ttf.woff2 differ diff --git a/src/librustdoc/html/static/rustdoc.css b/src/librustdoc/html/static/rustdoc.css index 89f5d59224164..9e1fcb929c54d 100644 --- a/src/librustdoc/html/static/rustdoc.css +++ b/src/librustdoc/html/static/rustdoc.css @@ -23,21 +23,27 @@ font-family: 'Source Serif 4'; font-style: normal; font-weight: 400; - src: local('Source Serif 4'), url("SourceSerif4-Regular.ttf.woff") format('woff'); + src: local('Source Serif 4'), + url("SourceSerif4-Regular.ttf.woff2") format("woff2"), + url("SourceSerif4-Regular.ttf.woff") format("woff"); font-display: swap; } @font-face { font-family: 'Source Serif 4'; font-style: italic; font-weight: 400; - src: local('Source Serif 4 Italic'), url("SourceSerif4-It.ttf.woff") format('woff'); + src: local('Source Serif 4 Italic'), + url("SourceSerif4-It.ttf.woff2") format("woff2"), + url("SourceSerif4-It.ttf.woff") format("woff"); font-display: swap; } @font-face { font-family: 'Source Serif 4'; font-style: normal; font-weight: 700; - src: local('Source Serif 4 Bold'), url("SourceSerif4-Bold.ttf.woff") format('woff'); + src: local('Source Serif 4 Bold'), + url("SourceSerif4-Bold.ttf.woff2") format("woff2"), + url("SourceSerif4-Bold.ttf.woff") format("woff"); font-display: swap; } @@ -48,21 +54,24 @@ font-weight: 400; /* Avoid using locally installed font because bad versions are in circulation: * see https://github.com/rust-lang/rust/issues/24355 */ - src: url("SourceCodePro-Regular.ttf.woff") format('woff'); + src: url("SourceCodePro-Regular.ttf.woff2") format("woff2"), + url("SourceCodePro-Regular.ttf.woff") format("woff"); font-display: swap; } @font-face { font-family: 'Source Code Pro'; font-style: italic; font-weight: 400; - src: url("SourceCodePro-It.ttf.woff") format('woff'); + src: url("SourceCodePro-It.ttf.woff2") format("woff2"), + url("SourceCodePro-It.ttf.woff") format("woff"); font-display: swap; } @font-face { font-family: 'Source Code Pro'; font-style: normal; font-weight: 600; - src: url("SourceCodePro-Semibold.ttf.woff") format('woff'); + src: url("SourceCodePro-Semibold.ttf.woff2") format("woff2"), + url("SourceCodePro-Semibold.ttf.woff") format("woff"); font-display: swap; } diff --git a/src/librustdoc/html/static_files.rs b/src/librustdoc/html/static_files.rs index 00e13d4ec1aa8..4443c74834d04 100644 --- a/src/librustdoc/html/static_files.rs +++ b/src/librustdoc/html/static_files.rs @@ -102,12 +102,24 @@ crate mod source_serif_4 { /// The file `SourceSerif4-Regular.ttf.woff`, the Regular variant of the Source Serif 4 font. crate static REGULAR: &[u8] = include_bytes!("static/SourceSerif4-Regular.ttf.woff"); + /// The file `SourceSerif4-Regular.ttf.woff2`, the Regular variant of the Source Serif 4 font in + /// woff2. + crate static REGULAR2: &[u8] = include_bytes!("static/SourceSerif4-Regular.ttf.woff2"); + /// The file `SourceSerif4-Bold.ttf.woff`, the Bold variant of the Source Serif 4 font. crate static BOLD: &[u8] = include_bytes!("static/SourceSerif4-Bold.ttf.woff"); + /// The file `SourceSerif4-Bold.ttf.woff2`, the Bold variant of the Source Serif 4 font in + /// woff2. + crate static BOLD2: &[u8] = include_bytes!("static/SourceSerif4-Bold.ttf.woff2"); + /// The file `SourceSerif4-It.ttf.woff`, the Italic variant of the Source Serif 4 font. crate static ITALIC: &[u8] = include_bytes!("static/SourceSerif4-It.ttf.woff"); + /// The file `SourceSerif4-It.ttf.woff2`, the Italic variant of the Source Serif 4 font in + /// woff2. + crate static ITALIC2: &[u8] = include_bytes!("static/SourceSerif4-It.ttf.woff2"); + /// The file `SourceSerif4-LICENSE.txt`, the license text for the Source Serif 4 font. crate static LICENSE: &[u8] = include_bytes!("static/SourceSerif4-LICENSE.md"); } @@ -117,13 +129,25 @@ crate mod source_code_pro { /// The file `SourceCodePro-Regular.ttf.woff`, the Regular variant of the Source Code Pro font. crate static REGULAR: &[u8] = include_bytes!("static/SourceCodePro-Regular.ttf.woff"); + /// The file `SourceCodePro-Regular.ttf.woff2`, the Regular variant of the Source Code Pro font + /// in woff2. + crate static REGULAR2: &[u8] = include_bytes!("static/SourceCodePro-Regular.ttf.woff2"); + /// The file `SourceCodePro-Semibold.ttf.woff`, the Semibold variant of the Source Code Pro /// font. crate static SEMIBOLD: &[u8] = include_bytes!("static/SourceCodePro-Semibold.ttf.woff"); + /// The file `SourceCodePro-Semibold.ttf.woff2`, the Semibold variant of the Source Code Pro + /// font in woff2. + crate static SEMIBOLD2: &[u8] = include_bytes!("static/SourceCodePro-Semibold.ttf.woff2"); + /// The file `SourceCodePro-It.ttf.woff`, the Italic variant of the Source Code Pro font. crate static ITALIC: &[u8] = include_bytes!("static/SourceCodePro-It.ttf.woff"); + /// The file `SourceCodePro-It.ttf.woff2`, the Italic variant of the Source Code Pro font in + /// woff2. + crate static ITALIC2: &[u8] = include_bytes!("static/SourceCodePro-It.ttf.woff2"); + /// The file `SourceCodePro-LICENSE.txt`, the license text of the Source Code Pro font. crate static LICENSE: &[u8] = include_bytes!("static/SourceCodePro-LICENSE.txt"); } diff --git a/src/librustdoc/markdown.rs b/src/librustdoc/markdown.rs index 963f2cf71f389..5da3a75e87631 100644 --- a/src/librustdoc/markdown.rs +++ b/src/librustdoc/markdown.rs @@ -4,6 +4,7 @@ use std::path::Path; use rustc_span::edition::Edition; use rustc_span::source_map::DUMMY_SP; +use rustc_span::Symbol; use crate::config::{Options, RenderOptions}; use crate::doctest::{Collector, TestOptions}; @@ -121,7 +122,7 @@ crate fn test(mut options: Options) -> Result<(), String> { opts.no_crate_inject = true; opts.display_warnings = options.display_warnings; let mut collector = Collector::new( - options.input.display().to_string(), + Symbol::intern(&options.input.display().to_string()), options.clone(), true, opts, diff --git a/src/test/rustdoc-js/summaries.js b/src/test/rustdoc-js/summaries.js index f175e47342df6..dfb11e80414c1 100644 --- a/src/test/rustdoc-js/summaries.js +++ b/src/test/rustdoc-js/summaries.js @@ -5,7 +5,7 @@ const QUERY = ['summaries', 'summaries::Sidebar', 'summaries::Sidebar2']; const EXPECTED = [ { 'others': [ - { 'path': '', 'name': 'summaries', 'desc': 'This summary has a link and code.' }, + { 'path': '', 'name': 'summaries', 'desc': 'This summary has a link, [code], and Sidebar2 intra-doc.' }, ], }, { diff --git a/src/test/rustdoc-js/summaries.rs b/src/test/rustdoc-js/summaries.rs index beb91e286b610..418c9f8d0edd0 100644 --- a/src/test/rustdoc-js/summaries.rs +++ b/src/test/rustdoc-js/summaries.rs @@ -1,9 +1,11 @@ #![crate_type = "lib"] #![crate_name = "summaries"] -//! This *summary* has a [link] and `code`. +//! This *summary* has a [link], [`code`], and [`Sidebar2`] intra-doc. //! -//! This is the second paragraph. +//! This is the second paragraph. It should not be rendered. +//! To test that intra-doc links are resolved properly, [`code`] should render +//! the square brackets, and [`Sidebar2`] should not. //! //! [link]: https://example.com diff --git a/src/test/ui/dyn-keyword/dyn-2015-edition-keyword-ident-lint.fixed b/src/test/ui/dyn-keyword/dyn-2015-edition-keyword-ident-lint.fixed index 003736208ed38..4bbec203c4e64 100644 --- a/src/test/ui/dyn-keyword/dyn-2015-edition-keyword-ident-lint.fixed +++ b/src/test/ui/dyn-keyword/dyn-2015-edition-keyword-ident-lint.fixed @@ -3,7 +3,8 @@ // to detect or fix uses of `dyn` under a macro. Since we are testing // this file via `rustfix`, we want the rustfix output to be // compilable; so the macros here carefully use `dyn` "correctly." - +// +// edition:2015 // run-rustfix #![allow(non_camel_case_types)] diff --git a/src/test/ui/dyn-keyword/dyn-2015-edition-keyword-ident-lint.rs b/src/test/ui/dyn-keyword/dyn-2015-edition-keyword-ident-lint.rs index 0e5c39fc501be..bc1dd4d1d08f7 100644 --- a/src/test/ui/dyn-keyword/dyn-2015-edition-keyword-ident-lint.rs +++ b/src/test/ui/dyn-keyword/dyn-2015-edition-keyword-ident-lint.rs @@ -3,7 +3,8 @@ // to detect or fix uses of `dyn` under a macro. Since we are testing // this file via `rustfix`, we want the rustfix output to be // compilable; so the macros here carefully use `dyn` "correctly." - +// +// edition:2015 // run-rustfix #![allow(non_camel_case_types)] diff --git a/src/test/ui/dyn-keyword/dyn-2015-edition-keyword-ident-lint.stderr b/src/test/ui/dyn-keyword/dyn-2015-edition-keyword-ident-lint.stderr index 32f06b62bb41a..32d690fa56341 100644 --- a/src/test/ui/dyn-keyword/dyn-2015-edition-keyword-ident-lint.stderr +++ b/src/test/ui/dyn-keyword/dyn-2015-edition-keyword-ident-lint.stderr @@ -1,11 +1,11 @@ error: `dyn` is a keyword in the 2018 edition - --> $DIR/dyn-2015-edition-keyword-ident-lint.rs:13:13 + --> $DIR/dyn-2015-edition-keyword-ident-lint.rs:14:13 | LL | pub mod dyn { | ^^^ help: you can use a raw identifier to stay compatible: `r#dyn` | note: the lint level is defined here - --> $DIR/dyn-2015-edition-keyword-ident-lint.rs:10:9 + --> $DIR/dyn-2015-edition-keyword-ident-lint.rs:11:9 | LL | #![deny(keyword_idents)] | ^^^^^^^^^^^^^^ @@ -13,7 +13,7 @@ LL | #![deny(keyword_idents)] = note: for more information, see issue #49716 error: `dyn` is a keyword in the 2018 edition - --> $DIR/dyn-2015-edition-keyword-ident-lint.rs:16:20 + --> $DIR/dyn-2015-edition-keyword-ident-lint.rs:17:20 | LL | pub struct dyn; | ^^^ help: you can use a raw identifier to stay compatible: `r#dyn` @@ -22,7 +22,7 @@ LL | pub struct dyn; = note: for more information, see issue #49716 error: `dyn` is a keyword in the 2018 edition - --> $DIR/dyn-2015-edition-keyword-ident-lint.rs:21:16 + --> $DIR/dyn-2015-edition-keyword-ident-lint.rs:22:16 | LL | use outer_mod::dyn::dyn; | ^^^ help: you can use a raw identifier to stay compatible: `r#dyn` @@ -31,7 +31,7 @@ LL | use outer_mod::dyn::dyn; = note: for more information, see issue #49716 error: `dyn` is a keyword in the 2018 edition - --> $DIR/dyn-2015-edition-keyword-ident-lint.rs:21:21 + --> $DIR/dyn-2015-edition-keyword-ident-lint.rs:22:21 | LL | use outer_mod::dyn::dyn; | ^^^ help: you can use a raw identifier to stay compatible: `r#dyn` @@ -40,7 +40,7 @@ LL | use outer_mod::dyn::dyn; = note: for more information, see issue #49716 error: `dyn` is a keyword in the 2018 edition - --> $DIR/dyn-2015-edition-keyword-ident-lint.rs:28:11 + --> $DIR/dyn-2015-edition-keyword-ident-lint.rs:29:11 | LL | match dyn { dyn => {} } | ^^^ help: you can use a raw identifier to stay compatible: `r#dyn` @@ -49,7 +49,7 @@ LL | match dyn { dyn => {} } = note: for more information, see issue #49716 error: `dyn` is a keyword in the 2018 edition - --> $DIR/dyn-2015-edition-keyword-ident-lint.rs:28:17 + --> $DIR/dyn-2015-edition-keyword-ident-lint.rs:29:17 | LL | match dyn { dyn => {} } | ^^^ help: you can use a raw identifier to stay compatible: `r#dyn` @@ -58,7 +58,7 @@ LL | match dyn { dyn => {} } = note: for more information, see issue #49716 error: `dyn` is a keyword in the 2018 edition - --> $DIR/dyn-2015-edition-keyword-ident-lint.rs:33:17 + --> $DIR/dyn-2015-edition-keyword-ident-lint.rs:34:17 | LL | macro_defn::dyn(); | ^^^ help: you can use a raw identifier to stay compatible: `r#dyn` @@ -67,7 +67,7 @@ LL | macro_defn::dyn(); = note: for more information, see issue #49716 error: `dyn` is a keyword in the 2018 edition - --> $DIR/dyn-2015-edition-keyword-ident-lint.rs:43:18 + --> $DIR/dyn-2015-edition-keyword-ident-lint.rs:44:18 | LL | macro_rules! dyn { | ^^^ help: you can use a raw identifier to stay compatible: `r#dyn` @@ -76,7 +76,7 @@ LL | macro_rules! dyn { = note: for more information, see issue #49716 error: `dyn` is a keyword in the 2018 edition - --> $DIR/dyn-2015-edition-keyword-ident-lint.rs:51:12 + --> $DIR/dyn-2015-edition-keyword-ident-lint.rs:52:12 | LL | pub fn dyn() -> ::outer_mod::dyn::dyn { | ^^^ help: you can use a raw identifier to stay compatible: `r#dyn` @@ -85,7 +85,7 @@ LL | pub fn dyn() -> ::outer_mod::dyn::dyn { = note: for more information, see issue #49716 error: `dyn` is a keyword in the 2018 edition - --> $DIR/dyn-2015-edition-keyword-ident-lint.rs:51:34 + --> $DIR/dyn-2015-edition-keyword-ident-lint.rs:52:34 | LL | pub fn dyn() -> ::outer_mod::dyn::dyn { | ^^^ help: you can use a raw identifier to stay compatible: `r#dyn` @@ -94,7 +94,7 @@ LL | pub fn dyn() -> ::outer_mod::dyn::dyn { = note: for more information, see issue #49716 error: `dyn` is a keyword in the 2018 edition - --> $DIR/dyn-2015-edition-keyword-ident-lint.rs:51:39 + --> $DIR/dyn-2015-edition-keyword-ident-lint.rs:52:39 | LL | pub fn dyn() -> ::outer_mod::dyn::dyn { | ^^^ help: you can use a raw identifier to stay compatible: `r#dyn` @@ -103,7 +103,7 @@ LL | pub fn dyn() -> ::outer_mod::dyn::dyn { = note: for more information, see issue #49716 error: `dyn` is a keyword in the 2018 edition - --> $DIR/dyn-2015-edition-keyword-ident-lint.rs:58:22 + --> $DIR/dyn-2015-edition-keyword-ident-lint.rs:59:22 | LL | ::outer_mod::dyn::dyn | ^^^ help: you can use a raw identifier to stay compatible: `r#dyn` @@ -112,7 +112,7 @@ LL | ::outer_mod::dyn::dyn = note: for more information, see issue #49716 error: `dyn` is a keyword in the 2018 edition - --> $DIR/dyn-2015-edition-keyword-ident-lint.rs:58:27 + --> $DIR/dyn-2015-edition-keyword-ident-lint.rs:59:27 | LL | ::outer_mod::dyn::dyn | ^^^ help: you can use a raw identifier to stay compatible: `r#dyn` @@ -121,7 +121,7 @@ LL | ::outer_mod::dyn::dyn = note: for more information, see issue #49716 error: `dyn` is a keyword in the 2018 edition - --> $DIR/dyn-2015-edition-keyword-ident-lint.rs:67:23 + --> $DIR/dyn-2015-edition-keyword-ident-lint.rs:68:23 | LL | pub fn boxed() -> dyn!( | ^^^ help: you can use a raw identifier to stay compatible: `r#dyn` diff --git a/src/test/ui/dyn-keyword/dyn-2015-idents-in-decl-macros-unlinted.rs b/src/test/ui/dyn-keyword/dyn-2015-idents-in-decl-macros-unlinted.rs index cf14aef7900a7..bda2ed17ecfab 100644 --- a/src/test/ui/dyn-keyword/dyn-2015-idents-in-decl-macros-unlinted.rs +++ b/src/test/ui/dyn-keyword/dyn-2015-idents-in-decl-macros-unlinted.rs @@ -1,11 +1,12 @@ -// build-pass (FIXME(62277): could be check-pass?) - // Under the 2015 edition with the keyword_idents lint, `dyn` is // not entirely acceptable as an identifier. // // We currently do not attempt to detect or fix uses of `dyn` as an // identifier under a macro, including under the declarative `macro` // forms from macros 1.2 and macros 2.0. +// +// check-pass +// edition:2015 #![feature(decl_macro)] #![allow(non_camel_case_types)] diff --git a/src/test/ui/dyn-keyword/dyn-2015-idents-in-macros-unlinted.rs b/src/test/ui/dyn-keyword/dyn-2015-idents-in-macros-unlinted.rs index 0d85b87dee5a1..472f6b5c8e514 100644 --- a/src/test/ui/dyn-keyword/dyn-2015-idents-in-macros-unlinted.rs +++ b/src/test/ui/dyn-keyword/dyn-2015-idents-in-macros-unlinted.rs @@ -1,10 +1,11 @@ -// build-pass (FIXME(62277): could be check-pass?) - // Under the 2015 edition with the keyword_idents lint, `dyn` is // not entirely acceptable as an identifier. // // We currently do not attempt to detect or fix uses of `dyn` as an // identifier under a macro. +// +// check-pass +// edition:2015 #![allow(non_camel_case_types)] #![deny(keyword_idents)] diff --git a/src/test/ui/dyn-keyword/dyn-2015-no-warnings-without-lints.rs b/src/test/ui/dyn-keyword/dyn-2015-no-warnings-without-lints.rs index 2a8b6b24831c0..d6a33c08d199f 100644 --- a/src/test/ui/dyn-keyword/dyn-2015-no-warnings-without-lints.rs +++ b/src/test/ui/dyn-keyword/dyn-2015-no-warnings-without-lints.rs @@ -1,7 +1,8 @@ // Under the 2015 edition without the keyword_idents lint, `dyn` is // entirely acceptable as an identifier. - -// build-pass (FIXME(62277): could be check-pass?) +// +// check-pass +// edition:2015 #![allow(non_camel_case_types)] diff --git a/src/test/ui/dyn-keyword/issue-56327-dyn-trait-in-macro-is-okay.rs b/src/test/ui/dyn-keyword/issue-56327-dyn-trait-in-macro-is-okay.rs index 4cb9bd1975a7f..2b46f57c2e26f 100644 --- a/src/test/ui/dyn-keyword/issue-56327-dyn-trait-in-macro-is-okay.rs +++ b/src/test/ui/dyn-keyword/issue-56327-dyn-trait-in-macro-is-okay.rs @@ -1,5 +1,6 @@ // check-pass - +// edition:2015 +// // rust-lang/rust#56327: Some occurrences of `dyn` within a macro are // not instances of identifiers, and thus should *not* be caught by the // keyword_ident lint. diff --git a/src/test/ui/editions/edition-feature-ok.rs b/src/test/ui/editions/edition-feature-ok.rs index 126421326949b..69242fd715cef 100644 --- a/src/test/ui/editions/edition-feature-ok.rs +++ b/src/test/ui/editions/edition-feature-ok.rs @@ -1,4 +1,4 @@ -// build-pass (FIXME(62277): could be check-pass?) +// check-pass #![feature(rust_2018_preview)] diff --git a/src/test/ui/editions/edition-imports-virtual-2015-ambiguity.rs b/src/test/ui/editions/edition-imports-virtual-2015-ambiguity.rs index 310bff21d1851..3fffb30c612d0 100644 --- a/src/test/ui/editions/edition-imports-virtual-2015-ambiguity.rs +++ b/src/test/ui/editions/edition-imports-virtual-2015-ambiguity.rs @@ -1,4 +1,4 @@ -// build-pass (FIXME(62277): could be check-pass?) +// check-pass // edition:2018 // compile-flags:--extern edition_imports_2015 // aux-build:edition-imports-2015.rs diff --git a/src/test/ui/editions/edition-keywords-2015-2015-expansion.rs b/src/test/ui/editions/edition-keywords-2015-2015-expansion.rs index 9c3beb1ce58c1..b2695bea5c39d 100644 --- a/src/test/ui/editions/edition-keywords-2015-2015-expansion.rs +++ b/src/test/ui/editions/edition-keywords-2015-2015-expansion.rs @@ -1,6 +1,6 @@ // edition:2015 // aux-build:edition-kw-macro-2015.rs -// build-pass (FIXME(62277): could be check-pass?) +// check-pass #![allow(keyword_idents)] diff --git a/src/test/ui/editions/edition-keywords-2018-2015-expansion.rs b/src/test/ui/editions/edition-keywords-2018-2015-expansion.rs index 619e6424db441..707d8e95c1414 100644 --- a/src/test/ui/editions/edition-keywords-2018-2015-expansion.rs +++ b/src/test/ui/editions/edition-keywords-2018-2015-expansion.rs @@ -1,6 +1,6 @@ // edition:2018 // aux-build:edition-kw-macro-2015.rs -// build-pass (FIXME(62277): could be check-pass?) +// check-pass #![allow(keyword_idents)] diff --git a/src/test/ui/iterators/into-iter-on-arrays-2018.rs b/src/test/ui/iterators/into-iter-on-arrays-2018.rs index 5661397b3c17b..9f28e93530125 100644 --- a/src/test/ui/iterators/into-iter-on-arrays-2018.rs +++ b/src/test/ui/iterators/into-iter-on-arrays-2018.rs @@ -12,12 +12,10 @@ fn main() { // Before 2021, the method dispatched to `IntoIterator for &[T; N]`, // which we continue to support for compatibility. let _: Iter<'_, i32> = array.into_iter(); - //~^ WARNING this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` - //~| WARNING this was previously accepted by the compiler but is being phased out + //~^ WARNING this method call resolves to `<&[T; N] as IntoIterator>::into_iter` let _: Iter<'_, i32> = Box::new(array).into_iter(); - //~^ WARNING this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` - //~| WARNING this was previously accepted by the compiler but is being phased out + //~^ WARNING this method call resolves to `<&[T; N] as IntoIterator>::into_iter` // The `array_into_iter` lint doesn't cover other wrappers that deref to an array. let _: Iter<'_, i32> = Rc::new(array).into_iter(); @@ -25,6 +23,9 @@ fn main() { // But you can always use the trait method explicitly as an array. let _: IntoIter = IntoIterator::into_iter(array); + + for _ in [1, 2, 3].into_iter() {} + //~^ WARNING this method call resolves to `<&[T; N] as IntoIterator>::into_iter` } /// User type that dereferences to an array. diff --git a/src/test/ui/iterators/into-iter-on-arrays-2018.stderr b/src/test/ui/iterators/into-iter-on-arrays-2018.stderr index b43338382f20c..c1d0e08d933d1 100644 --- a/src/test/ui/iterators/into-iter-on-arrays-2018.stderr +++ b/src/test/ui/iterators/into-iter-on-arrays-2018.stderr @@ -1,42 +1,48 @@ -warning: this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added. +warning: this method call resolves to `<&[T; N] as IntoIterator>::into_iter` (due to backwards compatibility), but will resolve to <[T; N] as IntoIterator>::into_iter in Rust 2021. --> $DIR/into-iter-on-arrays-2018.rs:14:34 | LL | let _: Iter<'_, i32> = array.into_iter(); - | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` + | ^^^^^^^^^ | = note: `#[warn(array_into_iter)]` on by default - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #66145 +help: use `.iter()` instead of `.into_iter()` to avoid ambiguity + | +LL | let _: Iter<'_, i32> = array.iter(); + | ^^^^ +help: or use `IntoIterator::into_iter(..)` instead of `.into_iter()` to explicitly iterate by value + | +LL | let _: Iter<'_, i32> = IntoIterator::into_iter(array); + | ^^^^^^^^^^^^^^^^^^^^^^^^ ^ -warning: this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added. - --> $DIR/into-iter-on-arrays-2018.rs:18:44 +warning: this method call resolves to `<&[T; N] as IntoIterator>::into_iter` (due to backwards compatibility), but will resolve to <[T; N] as IntoIterator>::into_iter in Rust 2021. + --> $DIR/into-iter-on-arrays-2018.rs:17:44 | LL | let _: Iter<'_, i32> = Box::new(array).into_iter(); - | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` + | ^^^^^^^^^ | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #66145 - -warning: 2 warnings emitted - -Future incompatibility report: Future breakage date: None, diagnostic: -warning: this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added. - --> $DIR/into-iter-on-arrays-2018.rs:14:34 +help: use `.iter()` instead of `.into_iter()` to avoid ambiguity | -LL | let _: Iter<'_, i32> = array.into_iter(); - | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` +LL | let _: Iter<'_, i32> = Box::new(array).iter(); + | ^^^^ +help: or use `IntoIterator::into_iter(..)` instead of `.into_iter()` to explicitly iterate by value | - = note: `#[warn(array_into_iter)]` on by default - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #66145 +LL | let _: Iter<'_, i32> = IntoIterator::into_iter(Box::new(array)); + | ^^^^^^^^^^^^^^^^^^^^^^^^ ^ -Future breakage date: None, diagnostic: -warning: this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added. - --> $DIR/into-iter-on-arrays-2018.rs:18:44 +warning: this method call resolves to `<&[T; N] as IntoIterator>::into_iter` (due to backwards compatibility), but will resolve to <[T; N] as IntoIterator>::into_iter in Rust 2021. + --> $DIR/into-iter-on-arrays-2018.rs:27:24 | -LL | let _: Iter<'_, i32> = Box::new(array).into_iter(); - | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` +LL | for _ in [1, 2, 3].into_iter() {} + | ^^^^^^^^^ + | +help: use `.iter()` instead of `.into_iter()` to avoid ambiguity | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #66145 +LL | for _ in [1, 2, 3].iter() {} + | ^^^^ +help: or remove `.into_iter()` to iterate by value + | +LL | for _ in [1, 2, 3] {} + | -- + +warning: 3 warnings emitted diff --git a/src/test/ui/iterators/into-iter-on-arrays-lint.fixed b/src/test/ui/iterators/into-iter-on-arrays-lint.fixed index 7f511bde3cbfc..d0346bc5efac9 100644 --- a/src/test/ui/iterators/into-iter-on-arrays-lint.fixed +++ b/src/test/ui/iterators/into-iter-on-arrays-lint.fixed @@ -7,43 +7,31 @@ fn main() { // Expressions that should trigger the lint small.iter(); - //~^ WARNING this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` - //~| WARNING this was previously accepted by the compiler but is being phased out + //~^ WARNING this method call resolves to `<&[T; N] as IntoIterator>::into_iter` [1, 2].iter(); - //~^ WARNING this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` - //~| WARNING this was previously accepted by the compiler but is being phased out + //~^ WARNING this method call resolves to `<&[T; N] as IntoIterator>::into_iter` big.iter(); - //~^ WARNING this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` - //~| WARNING this was previously accepted by the compiler but is being phased out + //~^ WARNING this method call resolves to `<&[T; N] as IntoIterator>::into_iter` [0u8; 33].iter(); - //~^ WARNING this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` - //~| WARNING this was previously accepted by the compiler but is being phased out + //~^ WARNING this method call resolves to `<&[T; N] as IntoIterator>::into_iter` Box::new(small).iter(); - //~^ WARNING this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` - //~| WARNING this was previously accepted by the compiler but is being phased out + //~^ WARNING this method call resolves to `<&[T; N] as IntoIterator>::into_iter` Box::new([1, 2]).iter(); - //~^ WARNING this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` - //~| WARNING this was previously accepted by the compiler but is being phased out + //~^ WARNING this method call resolves to `<&[T; N] as IntoIterator>::into_iter` Box::new(big).iter(); - //~^ WARNING this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` - //~| WARNING this was previously accepted by the compiler but is being phased out + //~^ WARNING this method call resolves to `<&[T; N] as IntoIterator>::into_iter` Box::new([0u8; 33]).iter(); - //~^ WARNING this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` - //~| WARNING this was previously accepted by the compiler but is being phased out + //~^ WARNING this method call resolves to `<&[T; N] as IntoIterator>::into_iter` Box::new(Box::new(small)).iter(); - //~^ WARNING this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` - //~| WARNING this was previously accepted by the compiler but is being phased out + //~^ WARNING this method call resolves to `<&[T; N] as IntoIterator>::into_iter` Box::new(Box::new([1, 2])).iter(); - //~^ WARNING this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` - //~| WARNING this was previously accepted by the compiler but is being phased out + //~^ WARNING this method call resolves to `<&[T; N] as IntoIterator>::into_iter` Box::new(Box::new(big)).iter(); - //~^ WARNING this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` - //~| WARNING this was previously accepted by the compiler but is being phased out + //~^ WARNING this method call resolves to `<&[T; N] as IntoIterator>::into_iter` Box::new(Box::new([0u8; 33])).iter(); - //~^ WARNING this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` - //~| WARNING this was previously accepted by the compiler but is being phased out + //~^ WARNING this method call resolves to `<&[T; N] as IntoIterator>::into_iter` // Expressions that should not (&[1, 2]).into_iter(); diff --git a/src/test/ui/iterators/into-iter-on-arrays-lint.rs b/src/test/ui/iterators/into-iter-on-arrays-lint.rs index d5fe83a7834b6..d7b0032abdd74 100644 --- a/src/test/ui/iterators/into-iter-on-arrays-lint.rs +++ b/src/test/ui/iterators/into-iter-on-arrays-lint.rs @@ -7,43 +7,31 @@ fn main() { // Expressions that should trigger the lint small.into_iter(); - //~^ WARNING this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` - //~| WARNING this was previously accepted by the compiler but is being phased out + //~^ WARNING this method call resolves to `<&[T; N] as IntoIterator>::into_iter` [1, 2].into_iter(); - //~^ WARNING this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` - //~| WARNING this was previously accepted by the compiler but is being phased out + //~^ WARNING this method call resolves to `<&[T; N] as IntoIterator>::into_iter` big.into_iter(); - //~^ WARNING this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` - //~| WARNING this was previously accepted by the compiler but is being phased out + //~^ WARNING this method call resolves to `<&[T; N] as IntoIterator>::into_iter` [0u8; 33].into_iter(); - //~^ WARNING this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` - //~| WARNING this was previously accepted by the compiler but is being phased out + //~^ WARNING this method call resolves to `<&[T; N] as IntoIterator>::into_iter` Box::new(small).into_iter(); - //~^ WARNING this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` - //~| WARNING this was previously accepted by the compiler but is being phased out + //~^ WARNING this method call resolves to `<&[T; N] as IntoIterator>::into_iter` Box::new([1, 2]).into_iter(); - //~^ WARNING this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` - //~| WARNING this was previously accepted by the compiler but is being phased out + //~^ WARNING this method call resolves to `<&[T; N] as IntoIterator>::into_iter` Box::new(big).into_iter(); - //~^ WARNING this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` - //~| WARNING this was previously accepted by the compiler but is being phased out + //~^ WARNING this method call resolves to `<&[T; N] as IntoIterator>::into_iter` Box::new([0u8; 33]).into_iter(); - //~^ WARNING this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` - //~| WARNING this was previously accepted by the compiler but is being phased out + //~^ WARNING this method call resolves to `<&[T; N] as IntoIterator>::into_iter` Box::new(Box::new(small)).into_iter(); - //~^ WARNING this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` - //~| WARNING this was previously accepted by the compiler but is being phased out + //~^ WARNING this method call resolves to `<&[T; N] as IntoIterator>::into_iter` Box::new(Box::new([1, 2])).into_iter(); - //~^ WARNING this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` - //~| WARNING this was previously accepted by the compiler but is being phased out + //~^ WARNING this method call resolves to `<&[T; N] as IntoIterator>::into_iter` Box::new(Box::new(big)).into_iter(); - //~^ WARNING this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` - //~| WARNING this was previously accepted by the compiler but is being phased out + //~^ WARNING this method call resolves to `<&[T; N] as IntoIterator>::into_iter` Box::new(Box::new([0u8; 33])).into_iter(); - //~^ WARNING this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` - //~| WARNING this was previously accepted by the compiler but is being phased out + //~^ WARNING this method call resolves to `<&[T; N] as IntoIterator>::into_iter` // Expressions that should not (&[1, 2]).into_iter(); diff --git a/src/test/ui/iterators/into-iter-on-arrays-lint.stderr b/src/test/ui/iterators/into-iter-on-arrays-lint.stderr index 211315c3fcf05..ca21bc508724a 100644 --- a/src/test/ui/iterators/into-iter-on-arrays-lint.stderr +++ b/src/test/ui/iterators/into-iter-on-arrays-lint.stderr @@ -1,247 +1,183 @@ -warning: this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added. +warning: this method call resolves to `<&[T; N] as IntoIterator>::into_iter` (due to backwards compatibility), but will resolve to <[T; N] as IntoIterator>::into_iter in Rust 2021. --> $DIR/into-iter-on-arrays-lint.rs:9:11 | LL | small.into_iter(); - | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` + | ^^^^^^^^^ | = note: `#[warn(array_into_iter)]` on by default - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #66145 - -warning: this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added. - --> $DIR/into-iter-on-arrays-lint.rs:12:12 +help: use `.iter()` instead of `.into_iter()` to avoid ambiguity | -LL | [1, 2].into_iter(); - | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` +LL | small.iter(); + | ^^^^ +help: or use `IntoIterator::into_iter(..)` instead of `.into_iter()` to explicitly iterate by value | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #66145 +LL | IntoIterator::into_iter(small); + | ^^^^^^^^^^^^^^^^^^^^^^^^ ^ -warning: this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added. - --> $DIR/into-iter-on-arrays-lint.rs:15:9 - | -LL | big.into_iter(); - | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` +warning: this method call resolves to `<&[T; N] as IntoIterator>::into_iter` (due to backwards compatibility), but will resolve to <[T; N] as IntoIterator>::into_iter in Rust 2021. + --> $DIR/into-iter-on-arrays-lint.rs:11:12 | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #66145 - -warning: this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added. - --> $DIR/into-iter-on-arrays-lint.rs:18:15 - | -LL | [0u8; 33].into_iter(); - | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` +LL | [1, 2].into_iter(); + | ^^^^^^^^^ | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #66145 - -warning: this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added. - --> $DIR/into-iter-on-arrays-lint.rs:22:21 +help: use `.iter()` instead of `.into_iter()` to avoid ambiguity | -LL | Box::new(small).into_iter(); - | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` +LL | [1, 2].iter(); + | ^^^^ +help: or use `IntoIterator::into_iter(..)` instead of `.into_iter()` to explicitly iterate by value | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #66145 +LL | IntoIterator::into_iter([1, 2]); + | ^^^^^^^^^^^^^^^^^^^^^^^^ ^ -warning: this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added. - --> $DIR/into-iter-on-arrays-lint.rs:25:22 +warning: this method call resolves to `<&[T; N] as IntoIterator>::into_iter` (due to backwards compatibility), but will resolve to <[T; N] as IntoIterator>::into_iter in Rust 2021. + --> $DIR/into-iter-on-arrays-lint.rs:13:9 | -LL | Box::new([1, 2]).into_iter(); - | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` +LL | big.into_iter(); + | ^^^^^^^^^ | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #66145 - -warning: this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added. - --> $DIR/into-iter-on-arrays-lint.rs:28:19 +help: use `.iter()` instead of `.into_iter()` to avoid ambiguity | -LL | Box::new(big).into_iter(); - | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` +LL | big.iter(); + | ^^^^ +help: or use `IntoIterator::into_iter(..)` instead of `.into_iter()` to explicitly iterate by value | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #66145 +LL | IntoIterator::into_iter(big); + | ^^^^^^^^^^^^^^^^^^^^^^^^ ^ -warning: this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added. - --> $DIR/into-iter-on-arrays-lint.rs:31:25 +warning: this method call resolves to `<&[T; N] as IntoIterator>::into_iter` (due to backwards compatibility), but will resolve to <[T; N] as IntoIterator>::into_iter in Rust 2021. + --> $DIR/into-iter-on-arrays-lint.rs:15:15 | -LL | Box::new([0u8; 33]).into_iter(); - | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` +LL | [0u8; 33].into_iter(); + | ^^^^^^^^^ | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #66145 - -warning: this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added. - --> $DIR/into-iter-on-arrays-lint.rs:35:31 +help: use `.iter()` instead of `.into_iter()` to avoid ambiguity | -LL | Box::new(Box::new(small)).into_iter(); - | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` +LL | [0u8; 33].iter(); + | ^^^^ +help: or use `IntoIterator::into_iter(..)` instead of `.into_iter()` to explicitly iterate by value | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #66145 +LL | IntoIterator::into_iter([0u8; 33]); + | ^^^^^^^^^^^^^^^^^^^^^^^^ ^ -warning: this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added. - --> $DIR/into-iter-on-arrays-lint.rs:38:32 +warning: this method call resolves to `<&[T; N] as IntoIterator>::into_iter` (due to backwards compatibility), but will resolve to <[T; N] as IntoIterator>::into_iter in Rust 2021. + --> $DIR/into-iter-on-arrays-lint.rs:18:21 | -LL | Box::new(Box::new([1, 2])).into_iter(); - | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` +LL | Box::new(small).into_iter(); + | ^^^^^^^^^ | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #66145 - -warning: this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added. - --> $DIR/into-iter-on-arrays-lint.rs:41:29 +help: use `.iter()` instead of `.into_iter()` to avoid ambiguity | -LL | Box::new(Box::new(big)).into_iter(); - | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` +LL | Box::new(small).iter(); + | ^^^^ +help: or use `IntoIterator::into_iter(..)` instead of `.into_iter()` to explicitly iterate by value | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #66145 +LL | IntoIterator::into_iter(Box::new(small)); + | ^^^^^^^^^^^^^^^^^^^^^^^^ ^ -warning: this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added. - --> $DIR/into-iter-on-arrays-lint.rs:44:35 +warning: this method call resolves to `<&[T; N] as IntoIterator>::into_iter` (due to backwards compatibility), but will resolve to <[T; N] as IntoIterator>::into_iter in Rust 2021. + --> $DIR/into-iter-on-arrays-lint.rs:20:22 | -LL | Box::new(Box::new([0u8; 33])).into_iter(); - | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` +LL | Box::new([1, 2]).into_iter(); + | ^^^^^^^^^ | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #66145 - -warning: 12 warnings emitted - -Future incompatibility report: Future breakage date: None, diagnostic: -warning: this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added. - --> $DIR/into-iter-on-arrays-lint.rs:9:11 +help: use `.iter()` instead of `.into_iter()` to avoid ambiguity | -LL | small.into_iter(); - | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` +LL | Box::new([1, 2]).iter(); + | ^^^^ +help: or use `IntoIterator::into_iter(..)` instead of `.into_iter()` to explicitly iterate by value | - = note: `#[warn(array_into_iter)]` on by default - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #66145 +LL | IntoIterator::into_iter(Box::new([1, 2])); + | ^^^^^^^^^^^^^^^^^^^^^^^^ ^ -Future breakage date: None, diagnostic: -warning: this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added. - --> $DIR/into-iter-on-arrays-lint.rs:12:12 +warning: this method call resolves to `<&[T; N] as IntoIterator>::into_iter` (due to backwards compatibility), but will resolve to <[T; N] as IntoIterator>::into_iter in Rust 2021. + --> $DIR/into-iter-on-arrays-lint.rs:22:19 | -LL | [1, 2].into_iter(); - | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` +LL | Box::new(big).into_iter(); + | ^^^^^^^^^ | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #66145 - -Future breakage date: None, diagnostic: -warning: this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added. - --> $DIR/into-iter-on-arrays-lint.rs:15:9 +help: use `.iter()` instead of `.into_iter()` to avoid ambiguity | -LL | big.into_iter(); - | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` +LL | Box::new(big).iter(); + | ^^^^ +help: or use `IntoIterator::into_iter(..)` instead of `.into_iter()` to explicitly iterate by value | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #66145 +LL | IntoIterator::into_iter(Box::new(big)); + | ^^^^^^^^^^^^^^^^^^^^^^^^ ^ -Future breakage date: None, diagnostic: -warning: this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added. - --> $DIR/into-iter-on-arrays-lint.rs:18:15 +warning: this method call resolves to `<&[T; N] as IntoIterator>::into_iter` (due to backwards compatibility), but will resolve to <[T; N] as IntoIterator>::into_iter in Rust 2021. + --> $DIR/into-iter-on-arrays-lint.rs:24:25 | -LL | [0u8; 33].into_iter(); - | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` +LL | Box::new([0u8; 33]).into_iter(); + | ^^^^^^^^^ | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #66145 - -Future breakage date: None, diagnostic: -warning: this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added. - --> $DIR/into-iter-on-arrays-lint.rs:22:21 +help: use `.iter()` instead of `.into_iter()` to avoid ambiguity | -LL | Box::new(small).into_iter(); - | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` +LL | Box::new([0u8; 33]).iter(); + | ^^^^ +help: or use `IntoIterator::into_iter(..)` instead of `.into_iter()` to explicitly iterate by value | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #66145 +LL | IntoIterator::into_iter(Box::new([0u8; 33])); + | ^^^^^^^^^^^^^^^^^^^^^^^^ ^ -Future breakage date: None, diagnostic: -warning: this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added. - --> $DIR/into-iter-on-arrays-lint.rs:25:22 +warning: this method call resolves to `<&[T; N] as IntoIterator>::into_iter` (due to backwards compatibility), but will resolve to <[T; N] as IntoIterator>::into_iter in Rust 2021. + --> $DIR/into-iter-on-arrays-lint.rs:27:31 | -LL | Box::new([1, 2]).into_iter(); - | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` +LL | Box::new(Box::new(small)).into_iter(); + | ^^^^^^^^^ | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #66145 - -Future breakage date: None, diagnostic: -warning: this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added. - --> $DIR/into-iter-on-arrays-lint.rs:28:19 +help: use `.iter()` instead of `.into_iter()` to avoid ambiguity | -LL | Box::new(big).into_iter(); - | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` +LL | Box::new(Box::new(small)).iter(); + | ^^^^ +help: or use `IntoIterator::into_iter(..)` instead of `.into_iter()` to explicitly iterate by value | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #66145 +LL | IntoIterator::into_iter(Box::new(Box::new(small))); + | ^^^^^^^^^^^^^^^^^^^^^^^^ ^ -Future breakage date: None, diagnostic: -warning: this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added. - --> $DIR/into-iter-on-arrays-lint.rs:31:25 +warning: this method call resolves to `<&[T; N] as IntoIterator>::into_iter` (due to backwards compatibility), but will resolve to <[T; N] as IntoIterator>::into_iter in Rust 2021. + --> $DIR/into-iter-on-arrays-lint.rs:29:32 | -LL | Box::new([0u8; 33]).into_iter(); - | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` +LL | Box::new(Box::new([1, 2])).into_iter(); + | ^^^^^^^^^ | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #66145 - -Future breakage date: None, diagnostic: -warning: this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added. - --> $DIR/into-iter-on-arrays-lint.rs:35:31 +help: use `.iter()` instead of `.into_iter()` to avoid ambiguity | -LL | Box::new(Box::new(small)).into_iter(); - | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` +LL | Box::new(Box::new([1, 2])).iter(); + | ^^^^ +help: or use `IntoIterator::into_iter(..)` instead of `.into_iter()` to explicitly iterate by value | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #66145 +LL | IntoIterator::into_iter(Box::new(Box::new([1, 2]))); + | ^^^^^^^^^^^^^^^^^^^^^^^^ ^ -Future breakage date: None, diagnostic: -warning: this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added. - --> $DIR/into-iter-on-arrays-lint.rs:38:32 +warning: this method call resolves to `<&[T; N] as IntoIterator>::into_iter` (due to backwards compatibility), but will resolve to <[T; N] as IntoIterator>::into_iter in Rust 2021. + --> $DIR/into-iter-on-arrays-lint.rs:31:29 | -LL | Box::new(Box::new([1, 2])).into_iter(); - | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` +LL | Box::new(Box::new(big)).into_iter(); + | ^^^^^^^^^ | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #66145 - -Future breakage date: None, diagnostic: -warning: this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added. - --> $DIR/into-iter-on-arrays-lint.rs:41:29 +help: use `.iter()` instead of `.into_iter()` to avoid ambiguity | -LL | Box::new(Box::new(big)).into_iter(); - | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` +LL | Box::new(Box::new(big)).iter(); + | ^^^^ +help: or use `IntoIterator::into_iter(..)` instead of `.into_iter()` to explicitly iterate by value | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #66145 +LL | IntoIterator::into_iter(Box::new(Box::new(big))); + | ^^^^^^^^^^^^^^^^^^^^^^^^ ^ -Future breakage date: None, diagnostic: -warning: this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added. - --> $DIR/into-iter-on-arrays-lint.rs:44:35 +warning: this method call resolves to `<&[T; N] as IntoIterator>::into_iter` (due to backwards compatibility), but will resolve to <[T; N] as IntoIterator>::into_iter in Rust 2021. + --> $DIR/into-iter-on-arrays-lint.rs:33:35 | LL | Box::new(Box::new([0u8; 33])).into_iter(); - | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #66145 - -Future breakage date: None, diagnostic: -warning: this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added. - --> $DIR/into-iter-on-arrays-lint.rs:60:12 + | ^^^^^^^^^ | -LL | [0, 1].into_iter(); - | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` +help: use `.iter()` instead of `.into_iter()` to avoid ambiguity | -note: the lint level is defined here - --> $DIR/into-iter-on-arrays-lint.rs:59:13 +LL | Box::new(Box::new([0u8; 33])).iter(); + | ^^^^ +help: or use `IntoIterator::into_iter(..)` instead of `.into_iter()` to explicitly iterate by value | -LL | #[allow(array_into_iter)] - | ^^^^^^^^^^^^^^^ - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #66145 +LL | IntoIterator::into_iter(Box::new(Box::new([0u8; 33]))); + | ^^^^^^^^^^^^^^^^^^^^^^^^ ^ + +warning: 12 warnings emitted diff --git a/src/test/ui/lint/issue-78660-cap-lints-future-compat.rs b/src/test/ui/lint/issue-78660-cap-lints-future-compat.rs deleted file mode 100644 index 4d98f0ad62d4d..0000000000000 --- a/src/test/ui/lint/issue-78660-cap-lints-future-compat.rs +++ /dev/null @@ -1,10 +0,0 @@ -// compile-flags: -D warnings --cap-lints allow -// check-pass - -// Regression test for issue #78660 -// Tests that we don't ICE when a future-incompat-report lint has -// has a command-line source, but is capped to allow - -fn main() { - ["hi"].into_iter(); -} diff --git a/src/test/ui/lint/issue-78660-cap-lints-future-compat.stderr b/src/test/ui/lint/issue-78660-cap-lints-future-compat.stderr deleted file mode 100644 index 79958ba90d409..0000000000000 --- a/src/test/ui/lint/issue-78660-cap-lints-future-compat.stderr +++ /dev/null @@ -1,11 +0,0 @@ -Future incompatibility report: Future breakage date: None, diagnostic: -warning: this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added. - --> $DIR/issue-78660-cap-lints-future-compat.rs:9:12 - | -LL | ["hi"].into_iter(); - | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` - | - = note: `-D array-into-iter` implied by `-D warnings` - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #66145 - diff --git a/src/test/ui/traits/operator-overloading-issue-52025.rs b/src/test/ui/traits/operator-overloading-issue-52025.rs new file mode 100644 index 0000000000000..7ce638832b06b --- /dev/null +++ b/src/test/ui/traits/operator-overloading-issue-52025.rs @@ -0,0 +1,57 @@ +// only-x86_64 +// build-pass + +use std::arch::x86_64::*; +use std::fmt::Debug; +use std::ops::*; + +pub trait Simd { + type Vf32: Copy + Debug + Add + Add; + + unsafe fn set1_ps(a: f32) -> Self::Vf32; + unsafe fn add_ps(a: Self::Vf32, b: Self::Vf32) -> Self::Vf32; +} + +#[derive(Copy, Debug, Clone)] +pub struct F32x4(pub __m128); + +impl Add for F32x4 { + type Output = F32x4; + + fn add(self, rhs: F32x4) -> F32x4 { + F32x4(unsafe { _mm_add_ps(self.0, rhs.0) }) + } +} + +impl Add for F32x4 { + type Output = F32x4; + fn add(self, rhs: f32) -> F32x4 { + F32x4(unsafe { _mm_add_ps(self.0, _mm_set1_ps(rhs)) }) + } +} + +pub struct Sse2; +impl Simd for Sse2 { + type Vf32 = F32x4; + + #[inline(always)] + unsafe fn set1_ps(a: f32) -> Self::Vf32 { + F32x4(_mm_set1_ps(a)) + } + + #[inline(always)] + unsafe fn add_ps(a: Self::Vf32, b: Self::Vf32) -> Self::Vf32 { + F32x4(_mm_add_ps(a.0, b.0)) + } +} + +unsafe fn test() -> S::Vf32 { + let a = S::set1_ps(3.0); + let b = S::set1_ps(2.0); + let result = a + b; + result +} + +fn main() { + println!("{:?}", unsafe { test::() }); +} diff --git a/src/test/ui/unsafe/unsafe-around-compiler-generated-unsafe.mir.stderr b/src/test/ui/unsafe/unsafe-around-compiler-generated-unsafe.mir.stderr index 6810132686124..29bd84cd0db53 100644 --- a/src/test/ui/unsafe/unsafe-around-compiler-generated-unsafe.mir.stderr +++ b/src/test/ui/unsafe/unsafe-around-compiler-generated-unsafe.mir.stderr @@ -1,11 +1,11 @@ error: unnecessary `unsafe` block - --> $DIR/unsafe-around-compiler-generated-unsafe.rs:9:5 + --> $DIR/unsafe-around-compiler-generated-unsafe.rs:9:9 | -LL | unsafe { println!("foo"); } - | ^^^^^^ unnecessary `unsafe` block +LL | unsafe { async {}.await; } + | ^^^^^^ unnecessary `unsafe` block | note: the lint level is defined here - --> $DIR/unsafe-around-compiler-generated-unsafe.rs:6:9 + --> $DIR/unsafe-around-compiler-generated-unsafe.rs:5:9 | LL | #![deny(unused_unsafe)] | ^^^^^^^^^^^^^ diff --git a/src/test/ui/unsafe/unsafe-around-compiler-generated-unsafe.rs b/src/test/ui/unsafe/unsafe-around-compiler-generated-unsafe.rs index 08801f9ef59ff..e9c7efb9e8b80 100644 --- a/src/test/ui/unsafe/unsafe-around-compiler-generated-unsafe.rs +++ b/src/test/ui/unsafe/unsafe-around-compiler-generated-unsafe.rs @@ -1,10 +1,11 @@ -// issue #12418 - +// edition:2018 // revisions: mir thir // [thir]compile-flags: -Z thir-unsafeck #![deny(unused_unsafe)] fn main() { - unsafe { println!("foo"); } //~ ERROR unnecessary `unsafe` + let _ = async { + unsafe { async {}.await; } //~ ERROR unnecessary `unsafe` + }; } diff --git a/src/test/ui/unsafe/unsafe-around-compiler-generated-unsafe.thir.stderr b/src/test/ui/unsafe/unsafe-around-compiler-generated-unsafe.thir.stderr index 6810132686124..29bd84cd0db53 100644 --- a/src/test/ui/unsafe/unsafe-around-compiler-generated-unsafe.thir.stderr +++ b/src/test/ui/unsafe/unsafe-around-compiler-generated-unsafe.thir.stderr @@ -1,11 +1,11 @@ error: unnecessary `unsafe` block - --> $DIR/unsafe-around-compiler-generated-unsafe.rs:9:5 + --> $DIR/unsafe-around-compiler-generated-unsafe.rs:9:9 | -LL | unsafe { println!("foo"); } - | ^^^^^^ unnecessary `unsafe` block +LL | unsafe { async {}.await; } + | ^^^^^^ unnecessary `unsafe` block | note: the lint level is defined here - --> $DIR/unsafe-around-compiler-generated-unsafe.rs:6:9 + --> $DIR/unsafe-around-compiler-generated-unsafe.rs:5:9 | LL | #![deny(unused_unsafe)] | ^^^^^^^^^^^^^