mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-27 18:57:42 +03:00
Auto merge of #147913 - matthiaskrgr:rollup-lmm3dsh, r=matthiaskrgr
Rollup of 4 pull requests Successful merges: - rust-lang/rust#147577 (Improve error message for ambiguous numeric types in closure parameters) - rust-lang/rust#147785 (fix incorrect line number when building trimmed multi-line suggestions) - rust-lang/rust#147814 (btree: some cleanup with less unsafe) - rust-lang/rust#147843 (Change the tidy license checker) r? `@ghost` `@rustbot` modify labels: rollup
This commit is contained in:
@@ -2154,11 +2154,11 @@ fn emit_suggestion_default(
|
||||
|
||||
assert!(!file_lines.lines.is_empty() || parts[0].span.is_dummy());
|
||||
|
||||
let line_start = sm.lookup_char_pos(parts[0].span.lo()).line;
|
||||
let line_start = sm.lookup_char_pos(parts[0].original_span.lo()).line;
|
||||
let mut lines = complete.lines();
|
||||
if lines.clone().next().is_none() {
|
||||
// Account for a suggestion to completely remove a line(s) with whitespace (#94192).
|
||||
let line_end = sm.lookup_char_pos(parts[0].span.hi()).line;
|
||||
let line_end = sm.lookup_char_pos(parts[0].original_span.hi()).line;
|
||||
for line in line_start..=line_end {
|
||||
self.draw_line_num(
|
||||
&mut buffer,
|
||||
|
||||
@@ -224,6 +224,13 @@ pub struct SubstitutionPart {
|
||||
pub snippet: String,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Hash, Encodable, Decodable)]
|
||||
pub struct TrimmedSubstitutionPart {
|
||||
pub original_span: Span,
|
||||
pub span: Span,
|
||||
pub snippet: String,
|
||||
}
|
||||
|
||||
/// Used to translate between `Span`s and byte positions within a single output line in highlighted
|
||||
/// code of structured suggestions.
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
@@ -233,6 +240,35 @@ pub(crate) struct SubstitutionHighlight {
|
||||
}
|
||||
|
||||
impl SubstitutionPart {
|
||||
/// Try to turn a replacement into an addition when the span that is being
|
||||
/// overwritten matches either the prefix or suffix of the replacement.
|
||||
fn trim_trivial_replacements(self, sm: &SourceMap) -> TrimmedSubstitutionPart {
|
||||
let mut trimmed_part = TrimmedSubstitutionPart {
|
||||
original_span: self.span,
|
||||
span: self.span,
|
||||
snippet: self.snippet,
|
||||
};
|
||||
if trimmed_part.snippet.is_empty() {
|
||||
return trimmed_part;
|
||||
}
|
||||
let Ok(snippet) = sm.span_to_snippet(trimmed_part.span) else {
|
||||
return trimmed_part;
|
||||
};
|
||||
|
||||
if let Some((prefix, substr, suffix)) = as_substr(&snippet, &trimmed_part.snippet) {
|
||||
trimmed_part.span = Span::new(
|
||||
trimmed_part.span.lo() + BytePos(prefix as u32),
|
||||
trimmed_part.span.hi() - BytePos(suffix as u32),
|
||||
trimmed_part.span.ctxt(),
|
||||
trimmed_part.span.parent(),
|
||||
);
|
||||
trimmed_part.snippet = substr.to_string();
|
||||
}
|
||||
trimmed_part
|
||||
}
|
||||
}
|
||||
|
||||
impl TrimmedSubstitutionPart {
|
||||
pub fn is_addition(&self, sm: &SourceMap) -> bool {
|
||||
!self.snippet.is_empty() && !self.replaces_meaningful_content(sm)
|
||||
}
|
||||
@@ -260,27 +296,6 @@ fn replaces_meaningful_content(&self, sm: &SourceMap) -> bool {
|
||||
sm.span_to_snippet(self.span)
|
||||
.map_or(!self.span.is_empty(), |snippet| !snippet.trim().is_empty())
|
||||
}
|
||||
|
||||
/// Try to turn a replacement into an addition when the span that is being
|
||||
/// overwritten matches either the prefix or suffix of the replacement.
|
||||
fn trim_trivial_replacements(&mut self, sm: &SourceMap) {
|
||||
if self.snippet.is_empty() {
|
||||
return;
|
||||
}
|
||||
let Ok(snippet) = sm.span_to_snippet(self.span) else {
|
||||
return;
|
||||
};
|
||||
|
||||
if let Some((prefix, substr, suffix)) = as_substr(&snippet, &self.snippet) {
|
||||
self.span = Span::new(
|
||||
self.span.lo() + BytePos(prefix as u32),
|
||||
self.span.hi() - BytePos(suffix as u32),
|
||||
self.span.ctxt(),
|
||||
self.span.parent(),
|
||||
);
|
||||
self.snippet = substr.to_string();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Given an original string like `AACC`, and a suggestion like `AABBCC`, try to detect
|
||||
@@ -310,7 +325,8 @@ impl CodeSuggestion {
|
||||
pub(crate) fn splice_lines(
|
||||
&self,
|
||||
sm: &SourceMap,
|
||||
) -> Vec<(String, Vec<SubstitutionPart>, Vec<Vec<SubstitutionHighlight>>, ConfusionType)> {
|
||||
) -> Vec<(String, Vec<TrimmedSubstitutionPart>, Vec<Vec<SubstitutionHighlight>>, ConfusionType)>
|
||||
{
|
||||
// For the `Vec<Vec<SubstitutionHighlight>>` value, the first level of the vector
|
||||
// corresponds to the output snippet's lines, while the second level corresponds to the
|
||||
// substrings within that line that should be highlighted.
|
||||
@@ -428,12 +444,17 @@ fn push_trailing(
|
||||
// or deleted code in order to point at the correct column *after* substitution.
|
||||
let mut acc = 0;
|
||||
let mut confusion_type = ConfusionType::None;
|
||||
for part in &mut substitution.parts {
|
||||
|
||||
let trimmed_parts = substitution
|
||||
.parts
|
||||
.into_iter()
|
||||
// If this is a replacement of, e.g. `"a"` into `"ab"`, adjust the
|
||||
// suggestion and snippet to look as if we just suggested to add
|
||||
// `"b"`, which is typically much easier for the user to understand.
|
||||
part.trim_trivial_replacements(sm);
|
||||
.map(|part| part.trim_trivial_replacements(sm))
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
for part in &trimmed_parts {
|
||||
let part_confusion = detect_confusion_type(sm, &part.snippet, part.span);
|
||||
confusion_type = confusion_type.combine(part_confusion);
|
||||
let cur_lo = sm.lookup_char_pos(part.span.lo());
|
||||
@@ -521,7 +542,7 @@ fn push_trailing(
|
||||
if highlights.iter().all(|parts| parts.is_empty()) {
|
||||
None
|
||||
} else {
|
||||
Some((buf, substitution.parts, highlights, confusion_type))
|
||||
Some((buf, trimmed_parts, highlights, confusion_type))
|
||||
}
|
||||
})
|
||||
.collect()
|
||||
|
||||
@@ -2547,6 +2547,8 @@ fn report_failed_method_call_on_numerical_infer_var(
|
||||
"you must specify a type for this binding, like `{concrete_type}`",
|
||||
);
|
||||
|
||||
// FIXME: Maybe FileName::Anon should also be handled,
|
||||
// otherwise there would be no suggestion if the source is STDIN for example.
|
||||
match (filename, parent_node) {
|
||||
(
|
||||
FileName::Real(_),
|
||||
@@ -2568,6 +2570,44 @@ fn report_failed_method_call_on_numerical_infer_var(
|
||||
Applicability::MaybeIncorrect,
|
||||
);
|
||||
}
|
||||
// For closure parameters with reference patterns (e.g., |&v|), suggest the type annotation
|
||||
// on the pattern itself, e.g., |&v: &i32|
|
||||
(FileName::Real(_), Node::Pat(pat))
|
||||
if let Node::Pat(binding_pat) = self.tcx.hir_node(hir_id)
|
||||
&& let hir::PatKind::Binding(..) = binding_pat.kind
|
||||
&& let Node::Pat(parent_pat) = parent_node
|
||||
&& matches!(parent_pat.kind, hir::PatKind::Ref(..)) =>
|
||||
{
|
||||
err.span_label(span, "you must specify a type for this binding");
|
||||
|
||||
let mut ref_muts = Vec::new();
|
||||
let mut current_node = parent_node;
|
||||
|
||||
while let Node::Pat(parent_pat) = current_node {
|
||||
if let hir::PatKind::Ref(_, mutability) = parent_pat.kind {
|
||||
ref_muts.push(mutability);
|
||||
current_node = self.tcx.parent_hir_node(parent_pat.hir_id);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
let mut type_annotation = String::new();
|
||||
for mutability in ref_muts.iter().rev() {
|
||||
match mutability {
|
||||
hir::Mutability::Mut => type_annotation.push_str("&mut "),
|
||||
hir::Mutability::Not => type_annotation.push('&'),
|
||||
}
|
||||
}
|
||||
type_annotation.push_str(&concrete_type);
|
||||
|
||||
err.span_suggestion_verbose(
|
||||
pat.span.shrink_to_hi(),
|
||||
"specify the type in the closure argument list",
|
||||
format!(": {type_annotation}"),
|
||||
Applicability::MaybeIncorrect,
|
||||
);
|
||||
}
|
||||
_ => {
|
||||
err.span_label(span, msg);
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
|
||||
use core::marker::PhantomData;
|
||||
use core::mem::{self, MaybeUninit};
|
||||
use core::num::NonZero;
|
||||
use core::ptr::{self, NonNull};
|
||||
use core::slice::SliceIndex;
|
||||
|
||||
@@ -143,7 +144,7 @@ unsafe fn new<A: Allocator + Clone>(alloc: A) -> Box<Self, A> {
|
||||
///
|
||||
/// A reference to a node.
|
||||
///
|
||||
/// This type has a number of parameters that controls how it acts:
|
||||
/// This type has a number of parameters that control how it acts:
|
||||
/// - `BorrowType`: A dummy type that describes the kind of borrow and carries a lifetime.
|
||||
/// - When this is `Immut<'a>`, the `NodeRef` acts roughly like `&'a Node`.
|
||||
/// - When this is `ValMut<'a>`, the `NodeRef` acts roughly like `&'a Node`
|
||||
@@ -226,33 +227,27 @@ pub(super) fn new_leaf<A: Allocator + Clone>(alloc: A) -> Self {
|
||||
|
||||
fn from_new_leaf<A: Allocator + Clone>(leaf: Box<LeafNode<K, V>, A>) -> Self {
|
||||
// The allocator must be dropped, not leaked. See also `BTreeMap::alloc`.
|
||||
let (leaf, _alloc) = Box::into_raw_with_allocator(leaf);
|
||||
// SAFETY: the node was just allocated.
|
||||
let node = unsafe { NonNull::new_unchecked(leaf) };
|
||||
let (node, _alloc) = Box::into_non_null_with_allocator(leaf);
|
||||
NodeRef { height: 0, node, _marker: PhantomData }
|
||||
}
|
||||
}
|
||||
|
||||
impl<K, V> NodeRef<marker::Owned, K, V, marker::Internal> {
|
||||
/// Creates a new internal (height > 0) `NodeRef`
|
||||
fn new_internal<A: Allocator + Clone>(child: Root<K, V>, alloc: A) -> Self {
|
||||
let mut new_node = unsafe { InternalNode::new(alloc) };
|
||||
new_node.edges[0].write(child.node);
|
||||
unsafe { NodeRef::from_new_internal(new_node, child.height + 1) }
|
||||
NodeRef::from_new_internal(new_node, NonZero::new(child.height + 1).unwrap())
|
||||
}
|
||||
|
||||
/// # Safety
|
||||
/// `height` must not be zero.
|
||||
unsafe fn from_new_internal<A: Allocator + Clone>(
|
||||
/// Creates a new internal (height > 0) `NodeRef` from an existing internal node
|
||||
fn from_new_internal<A: Allocator + Clone>(
|
||||
internal: Box<InternalNode<K, V>, A>,
|
||||
height: usize,
|
||||
height: NonZero<usize>,
|
||||
) -> Self {
|
||||
debug_assert!(height > 0);
|
||||
// The allocator must be dropped, not leaked. See also `BTreeMap::alloc`.
|
||||
let (internal, _alloc) = Box::into_raw_with_allocator(internal);
|
||||
// SAFETY: the node was just allocated.
|
||||
let internal = unsafe { NonNull::new_unchecked(internal) };
|
||||
let node = internal.cast();
|
||||
let mut this = NodeRef { height, node, _marker: PhantomData };
|
||||
let (node, _alloc) = Box::into_non_null_with_allocator(internal);
|
||||
let mut this = NodeRef { height: height.into(), node: node.cast(), _marker: PhantomData };
|
||||
this.borrow_mut().correct_all_childrens_parent_links();
|
||||
this
|
||||
}
|
||||
@@ -625,9 +620,8 @@ pub(super) fn pop_internal_level<A: Allocator + Clone>(&mut self, alloc: A) {
|
||||
let top = self.node;
|
||||
|
||||
// SAFETY: we asserted to be internal.
|
||||
let internal_self = unsafe { self.borrow_mut().cast_to_internal_unchecked() };
|
||||
// SAFETY: we borrowed `self` exclusively and its borrow type is exclusive.
|
||||
let internal_node = unsafe { &mut *NodeRef::as_internal_ptr(&internal_self) };
|
||||
let mut internal_self = unsafe { self.borrow_mut().cast_to_internal_unchecked() };
|
||||
let internal_node = internal_self.as_internal_mut();
|
||||
// SAFETY: the first edge is always initialized.
|
||||
self.node = unsafe { internal_node.edges[0].assume_init_read() };
|
||||
self.height -= 1;
|
||||
@@ -1305,7 +1299,8 @@ pub(super) fn split<A: Allocator + Clone>(
|
||||
&mut new_node.edges[..new_len + 1],
|
||||
);
|
||||
|
||||
let height = self.node.height;
|
||||
// SAFETY: self is `marker::Internal`, so `self.node.height` is positive
|
||||
let height = NonZero::new_unchecked(self.node.height);
|
||||
let right = NodeRef::from_new_internal(new_node, height);
|
||||
|
||||
SplitResult { left: self.node, kv, right }
|
||||
|
||||
+45
-98
@@ -19,32 +19,52 @@
|
||||
#[rustfmt::skip]
|
||||
const LICENSES: &[&str] = &[
|
||||
// tidy-alphabetical-start
|
||||
"(MIT OR Apache-2.0) AND Unicode-3.0", // unicode_ident (1.0.14)
|
||||
"(MIT OR Apache-2.0) AND Unicode-DFS-2016", // unicode_ident (1.0.12)
|
||||
"0BSD OR MIT OR Apache-2.0", // adler2 license
|
||||
"0BSD",
|
||||
"Apache-2.0 / MIT",
|
||||
"Apache-2.0 OR ISC OR MIT",
|
||||
"Apache-2.0 OR MIT",
|
||||
"Apache-2.0 WITH LLVM-exception OR Apache-2.0 OR MIT", // wasi license
|
||||
"Apache-2.0",
|
||||
"Apache-2.0/MIT",
|
||||
"BSD-2-Clause OR Apache-2.0 OR MIT", // zerocopy
|
||||
"BSD-2-Clause OR MIT OR Apache-2.0",
|
||||
"BSD-3-Clause/MIT",
|
||||
"CC0-1.0 OR MIT-0 OR Apache-2.0",
|
||||
"ISC",
|
||||
"MIT / Apache-2.0",
|
||||
"MIT AND (MIT OR Apache-2.0)",
|
||||
"MIT AND Apache-2.0 WITH LLVM-exception AND (MIT OR Apache-2.0)", // compiler-builtins
|
||||
"MIT OR Apache-2.0 OR LGPL-2.1-or-later", // r-efi, r-efi-alloc
|
||||
"MIT OR Apache-2.0 OR BSD-1-Clause",
|
||||
"MIT OR Apache-2.0 OR LGPL-2.1-or-later", // r-efi, r-efi-alloc; LGPL is not acceptable, but we use it under MIT OR Apache-2.0
|
||||
"MIT OR Apache-2.0 OR Zlib", // tinyvec_macros
|
||||
"MIT OR Apache-2.0",
|
||||
"MIT OR Zlib OR Apache-2.0", // miniz_oxide
|
||||
"MIT",
|
||||
"MIT/Apache-2.0",
|
||||
"Unicode-3.0", // icu4x
|
||||
"Unicode-DFS-2016", // tinystr
|
||||
"Unlicense OR MIT",
|
||||
"Unlicense/MIT",
|
||||
// tidy-alphabetical-end
|
||||
];
|
||||
|
||||
/// These are licenses that are allowed for rustc, tools, etc. But not for the runtime!
|
||||
#[rustfmt::skip]
|
||||
const LICENSES_TOOLS: &[&str] = &[
|
||||
// tidy-alphabetical-start
|
||||
"(Apache-2.0 OR MIT) AND BSD-3-Clause",
|
||||
"(MIT OR Apache-2.0) AND Unicode-3.0", // unicode_ident (1.0.14)
|
||||
"(MIT OR Apache-2.0) AND Unicode-DFS-2016", // unicode_ident (1.0.12)
|
||||
"0BSD",
|
||||
"Apache-2.0 AND ISC",
|
||||
"Apache-2.0 OR BSL-1.0", // BSL is not acceptable, but we use it under Apache-2.0
|
||||
"Apache-2.0 WITH LLVM-exception",
|
||||
"Apache-2.0",
|
||||
"BSD-2-Clause",
|
||||
"BSD-3-Clause",
|
||||
"CC0-1.0 OR Apache-2.0 OR Apache-2.0 WITH LLVM-exception",
|
||||
"CC0-1.0",
|
||||
"Unicode-3.0", // icu4x
|
||||
"Unicode-DFS-2016", // tinystr
|
||||
"Zlib OR Apache-2.0 OR MIT", // tinyvec
|
||||
"Zlib",
|
||||
// tidy-alphabetical-end
|
||||
];
|
||||
|
||||
@@ -89,17 +109,15 @@ pub(crate) struct WorkspaceInfo<'a> {
|
||||
)),
|
||||
submodules: &[],
|
||||
},
|
||||
{
|
||||
WorkspaceInfo {
|
||||
path: "compiler/rustc_codegen_cranelift",
|
||||
exceptions: EXCEPTIONS_CRANELIFT,
|
||||
crates_and_deps: Some((
|
||||
&["rustc_codegen_cranelift"],
|
||||
PERMITTED_CRANELIFT_DEPENDENCIES,
|
||||
PERMITTED_CRANELIFT_DEPS_LOCATION,
|
||||
)),
|
||||
submodules: &[],
|
||||
}
|
||||
WorkspaceInfo {
|
||||
path: "compiler/rustc_codegen_cranelift",
|
||||
exceptions: EXCEPTIONS_CRANELIFT,
|
||||
crates_and_deps: Some((
|
||||
&["rustc_codegen_cranelift"],
|
||||
PERMITTED_CRANELIFT_DEPENDENCIES,
|
||||
PERMITTED_CRANELIFT_DEPS_LOCATION,
|
||||
)),
|
||||
submodules: &[],
|
||||
},
|
||||
WorkspaceInfo {
|
||||
path: "compiler/rustc_codegen_gcc",
|
||||
@@ -169,19 +187,8 @@ pub(crate) struct WorkspaceInfo<'a> {
|
||||
#[rustfmt::skip]
|
||||
const EXCEPTIONS: ExceptionList = &[
|
||||
// tidy-alphabetical-start
|
||||
("ar_archive_writer", "Apache-2.0 WITH LLVM-exception"), // rustc
|
||||
("arrayref", "BSD-2-Clause"), // rustc
|
||||
("blake3", "CC0-1.0 OR Apache-2.0 OR Apache-2.0 WITH LLVM-exception"), // rustc
|
||||
("colored", "MPL-2.0"), // rustfmt
|
||||
("constant_time_eq", "CC0-1.0 OR MIT-0 OR Apache-2.0"), // rustc
|
||||
("dissimilar", "Apache-2.0"), // rustdoc, rustc_lexer (few tests) via expect-test, (dev deps)
|
||||
("fluent-langneg", "Apache-2.0"), // rustc (fluent translations)
|
||||
("foldhash", "Zlib"), // rustc
|
||||
("option-ext", "MPL-2.0"), // cargo-miri (via `directories`)
|
||||
("rustc_apfloat", "Apache-2.0 WITH LLVM-exception"), // rustc (license is the same as LLVM uses)
|
||||
("ryu", "Apache-2.0 OR BSL-1.0"), // BSL is not acceptble, but we use it under Apache-2.0 // cargo/... (because of serde)
|
||||
("self_cell", "Apache-2.0"), // rustc (fluent translations)
|
||||
("wasi-preview1-component-adapter-provider", "Apache-2.0 WITH LLVM-exception"), // rustc
|
||||
// tidy-alphabetical-end
|
||||
];
|
||||
|
||||
@@ -198,57 +205,22 @@ pub(crate) struct WorkspaceInfo<'a> {
|
||||
|
||||
const EXCEPTIONS_CARGO: ExceptionList = &[
|
||||
// tidy-alphabetical-start
|
||||
("arrayref", "BSD-2-Clause"),
|
||||
("bitmaps", "MPL-2.0+"),
|
||||
("blake3", "CC0-1.0 OR Apache-2.0 OR Apache-2.0 WITH LLVM-exception"),
|
||||
("ciborium", "Apache-2.0"),
|
||||
("ciborium-io", "Apache-2.0"),
|
||||
("ciborium-ll", "Apache-2.0"),
|
||||
("constant_time_eq", "CC0-1.0 OR MIT-0 OR Apache-2.0"),
|
||||
("dunce", "CC0-1.0 OR MIT-0 OR Apache-2.0"),
|
||||
("encoding_rs", "(Apache-2.0 OR MIT) AND BSD-3-Clause"),
|
||||
("fiat-crypto", "MIT OR Apache-2.0 OR BSD-1-Clause"),
|
||||
("foldhash", "Zlib"),
|
||||
("im-rc", "MPL-2.0+"),
|
||||
("libz-rs-sys", "Zlib"),
|
||||
("normalize-line-endings", "Apache-2.0"),
|
||||
("openssl", "Apache-2.0"),
|
||||
("ring", "Apache-2.0 AND ISC"),
|
||||
("ryu", "Apache-2.0 OR BSL-1.0"), // BSL is not acceptble, but we use it under Apache-2.0
|
||||
("similar", "Apache-2.0"),
|
||||
("sized-chunks", "MPL-2.0+"),
|
||||
("subtle", "BSD-3-Clause"),
|
||||
("supports-hyperlinks", "Apache-2.0"),
|
||||
("unicode-bom", "Apache-2.0"),
|
||||
("zlib-rs", "Zlib"),
|
||||
// tidy-alphabetical-end
|
||||
];
|
||||
|
||||
const EXCEPTIONS_RUST_ANALYZER: ExceptionList = &[
|
||||
// tidy-alphabetical-start
|
||||
("dissimilar", "Apache-2.0"),
|
||||
("foldhash", "Zlib"),
|
||||
("notify", "CC0-1.0"),
|
||||
("option-ext", "MPL-2.0"),
|
||||
("pulldown-cmark-to-cmark", "Apache-2.0"),
|
||||
("rustc_apfloat", "Apache-2.0 WITH LLVM-exception"),
|
||||
("ryu", "Apache-2.0 OR BSL-1.0"), // BSL is not acceptble, but we use it under Apache-2.0
|
||||
("scip", "Apache-2.0"),
|
||||
// tidy-alphabetical-end
|
||||
];
|
||||
|
||||
const EXCEPTIONS_RUSTC_PERF: ExceptionList = &[
|
||||
// tidy-alphabetical-start
|
||||
("alloc-no-stdlib", "BSD-3-Clause"),
|
||||
("alloc-stdlib", "BSD-3-Clause"),
|
||||
("brotli", "BSD-3-Clause/MIT"),
|
||||
("brotli-decompressor", "BSD-3-Clause/MIT"),
|
||||
("encoding_rs", "(Apache-2.0 OR MIT) AND BSD-3-Clause"),
|
||||
("inferno", "CDDL-1.0"),
|
||||
("option-ext", "MPL-2.0"),
|
||||
("ryu", "Apache-2.0 OR BSL-1.0"),
|
||||
("snap", "BSD-3-Clause"),
|
||||
("subtle", "BSD-3-Clause"),
|
||||
// tidy-alphabetical-end
|
||||
];
|
||||
|
||||
@@ -258,36 +230,10 @@ pub(crate) struct WorkspaceInfo<'a> {
|
||||
("cssparser-macros", "MPL-2.0"),
|
||||
("dtoa-short", "MPL-2.0"),
|
||||
("mdbook", "MPL-2.0"),
|
||||
("ryu", "Apache-2.0 OR BSL-1.0"),
|
||||
// tidy-alphabetical-end
|
||||
];
|
||||
|
||||
const EXCEPTIONS_CRANELIFT: ExceptionList = &[
|
||||
// tidy-alphabetical-start
|
||||
("cranelift-assembler-x64", "Apache-2.0 WITH LLVM-exception"),
|
||||
("cranelift-assembler-x64-meta", "Apache-2.0 WITH LLVM-exception"),
|
||||
("cranelift-bforest", "Apache-2.0 WITH LLVM-exception"),
|
||||
("cranelift-bitset", "Apache-2.0 WITH LLVM-exception"),
|
||||
("cranelift-codegen", "Apache-2.0 WITH LLVM-exception"),
|
||||
("cranelift-codegen-meta", "Apache-2.0 WITH LLVM-exception"),
|
||||
("cranelift-codegen-shared", "Apache-2.0 WITH LLVM-exception"),
|
||||
("cranelift-control", "Apache-2.0 WITH LLVM-exception"),
|
||||
("cranelift-entity", "Apache-2.0 WITH LLVM-exception"),
|
||||
("cranelift-frontend", "Apache-2.0 WITH LLVM-exception"),
|
||||
("cranelift-isle", "Apache-2.0 WITH LLVM-exception"),
|
||||
("cranelift-jit", "Apache-2.0 WITH LLVM-exception"),
|
||||
("cranelift-module", "Apache-2.0 WITH LLVM-exception"),
|
||||
("cranelift-native", "Apache-2.0 WITH LLVM-exception"),
|
||||
("cranelift-object", "Apache-2.0 WITH LLVM-exception"),
|
||||
("cranelift-srcgen", "Apache-2.0 WITH LLVM-exception"),
|
||||
("foldhash", "Zlib"),
|
||||
("mach2", "BSD-2-Clause OR MIT OR Apache-2.0"),
|
||||
("regalloc2", "Apache-2.0 WITH LLVM-exception"),
|
||||
("target-lexicon", "Apache-2.0 WITH LLVM-exception"),
|
||||
("wasmtime-jit-icache-coherence", "Apache-2.0 WITH LLVM-exception"),
|
||||
("wasmtime-math", "Apache-2.0 WITH LLVM-exception"),
|
||||
// tidy-alphabetical-end
|
||||
];
|
||||
const EXCEPTIONS_CRANELIFT: ExceptionList = &[];
|
||||
|
||||
const EXCEPTIONS_GCC: ExceptionList = &[
|
||||
// tidy-alphabetical-start
|
||||
@@ -296,13 +242,9 @@ pub(crate) struct WorkspaceInfo<'a> {
|
||||
// tidy-alphabetical-end
|
||||
];
|
||||
|
||||
const EXCEPTIONS_BOOTSTRAP: ExceptionList = &[
|
||||
("ryu", "Apache-2.0 OR BSL-1.0"), // through serde. BSL is not acceptble, but we use it under Apache-2.0
|
||||
];
|
||||
const EXCEPTIONS_BOOTSTRAP: ExceptionList = &[];
|
||||
|
||||
const EXCEPTIONS_UEFI_QEMU_TEST: ExceptionList = &[
|
||||
("r-efi", "MIT OR Apache-2.0 OR LGPL-2.1-or-later"), // LGPL is not acceptable, but we use it under MIT OR Apache-2.0
|
||||
];
|
||||
const EXCEPTIONS_UEFI_QEMU_TEST: ExceptionList = &[];
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
struct ListLocation {
|
||||
@@ -867,6 +809,11 @@ fn check_license_exceptions(
|
||||
}
|
||||
}
|
||||
}
|
||||
if LICENSES.contains(license) || LICENSES_TOOLS.contains(license) {
|
||||
check.error(format!(
|
||||
"dependency exception `{name}` is not necessary. `{license}` is an allowed license"
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
let exception_names: Vec<_> = exceptions.iter().map(|(name, _license)| *name).collect();
|
||||
@@ -890,7 +837,7 @@ fn check_license_exceptions(
|
||||
continue;
|
||||
}
|
||||
};
|
||||
if !LICENSES.contains(&license.as_str()) {
|
||||
if !LICENSES.contains(&license.as_str()) && !LICENSES_TOOLS.contains(&license.as_str()) {
|
||||
check.error(format!(
|
||||
"invalid license `{}` for package `{}` in workspace `{workspace}`",
|
||||
license, pkg.id
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
//@ compile-flags: -Z ui-testing=no
|
||||
fn function_with_lots_of_arguments(a: i32, b: char, c: i32, d: i32, e: i32, f: i32) {}
|
||||
|
||||
fn main() {
|
||||
let variable_name = 42;
|
||||
function_with_lots_of_arguments(
|
||||
variable_name,
|
||||
variable_name,
|
||||
variable_name,
|
||||
variable_name,
|
||||
variable_name,
|
||||
);
|
||||
//~^^^^^^^ ERROR this function takes 6 arguments but 5 arguments were supplied [E0061]
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
error[E0061]: this function takes 6 arguments but 5 arguments were supplied
|
||||
--> $DIR/trimmed_multiline_suggestion.rs:6:5
|
||||
|
|
||||
6 | function_with_lots_of_arguments(
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
7 | variable_name,
|
||||
8 | variable_name,
|
||||
| ------------- argument #2 of type `char` is missing
|
||||
|
|
||||
note: function defined here
|
||||
--> $DIR/trimmed_multiline_suggestion.rs:2:4
|
||||
|
|
||||
2 | fn function_with_lots_of_arguments(a: i32, b: char, c: i32, d: i32, e: i32, f: i32) {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -------
|
||||
help: provide the argument
|
||||
|
|
||||
6 | function_with_lots_of_arguments(
|
||||
7 | variable_name,
|
||||
8 ~ /* char */,
|
||||
9 ~ variable_name,
|
||||
|
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0061`.
|
||||
@@ -0,0 +1,14 @@
|
||||
// Test for better error message when numeric type is ambiguous in closure parameter with reference
|
||||
|
||||
//@ run-rustfix
|
||||
|
||||
fn main() {
|
||||
let _ = (0..10).filter(|&v: &i32| v.pow(2) > 0);
|
||||
//~^ ERROR can't call method `pow` on ambiguous numeric type `{integer}`
|
||||
//~| SUGGESTION &i32
|
||||
|
||||
let v = vec![0, 1, 2];
|
||||
let _ = v.iter().filter(|&&v: &&i32| v.pow(2) > 0);
|
||||
//~^ ERROR can't call method `pow` on ambiguous numeric type `{integer}`
|
||||
//~| SUGGESTION &&i32
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
// Test for better error message when numeric type is ambiguous in closure parameter with reference
|
||||
|
||||
//@ run-rustfix
|
||||
|
||||
fn main() {
|
||||
let _ = (0..10).filter(|&v| v.pow(2) > 0);
|
||||
//~^ ERROR can't call method `pow` on ambiguous numeric type `{integer}`
|
||||
//~| SUGGESTION &i32
|
||||
|
||||
let v = vec![0, 1, 2];
|
||||
let _ = v.iter().filter(|&&v| v.pow(2) > 0);
|
||||
//~^ ERROR can't call method `pow` on ambiguous numeric type `{integer}`
|
||||
//~| SUGGESTION &&i32
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
error[E0689]: can't call method `pow` on ambiguous numeric type `{integer}`
|
||||
--> $DIR/ambiguous-numeric-in-closure-ref.rs:6:35
|
||||
|
|
||||
LL | let _ = (0..10).filter(|&v| v.pow(2) > 0);
|
||||
| - ^^^
|
||||
| |
|
||||
| you must specify a type for this binding
|
||||
|
|
||||
help: specify the type in the closure argument list
|
||||
|
|
||||
LL | let _ = (0..10).filter(|&v: &i32| v.pow(2) > 0);
|
||||
| ++++++
|
||||
|
||||
error[E0689]: can't call method `pow` on ambiguous numeric type `{integer}`
|
||||
--> $DIR/ambiguous-numeric-in-closure-ref.rs:11:37
|
||||
|
|
||||
LL | let _ = v.iter().filter(|&&v| v.pow(2) > 0);
|
||||
| - ^^^
|
||||
| |
|
||||
| you must specify a type for this binding
|
||||
|
|
||||
help: specify the type in the closure argument list
|
||||
|
|
||||
LL | let _ = v.iter().filter(|&&v: &&i32| v.pow(2) > 0);
|
||||
| +++++++
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0689`.
|
||||
Reference in New Issue
Block a user