Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 8 pull requests #90026

Closed
wants to merge 23 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
15c876d
Deduplicate macro_rules! from module_exports when documenting them
Urgau Oct 13, 2021
e252274
Add regression test for #89852
Urgau Oct 14, 2021
7d6cfb7
Oops, inverted condition, fix that
Urgau Oct 14, 2021
55fad29
Apply documentation suggestions from code review
Urgau Oct 15, 2021
e259cc4
Add equivalent test in src/test/rustdoc
Urgau Oct 15, 2021
db5b64a
Rework the equivalent test to work with sidebar-items.js
Urgau Oct 15, 2021
7f34ced
HermitCore's kernel itself doesn't support TLS
stlankes Oct 16, 2021
2f4cbf0
remove compiler warnings
stlankes Oct 16, 2021
d4cc877
Suggest a case insensitive match name regardless of levenshtein distance
JohnTitor Oct 16, 2021
72ca6cd
:arrow_up: rust-analyzer
lnicola Oct 18, 2021
f8b2f91
add test for issue 84957
cameron1024 Oct 18, 2021
e3c3f4a
RustWrapper: adapt for an LLVM API change
krasimirgg Oct 11, 2021
e2453dc
Revert "Rollup merge of #86011 - tlyu:correct-sized-bound-spans, r=es…
JohnTitor Oct 18, 2021
101a81b
Add a regression test for #89935
JohnTitor Oct 18, 2021
02e4d0b
Make all proc-macro back-compat lints deny-by-default
Aaron1011 Aug 15, 2021
bfa3945
Rollup merge of #88041 - Aaron1011:deny-proc-macro-hack, r=wesleywiser
matthiaskrgr Oct 18, 2021
e830c7f
Rollup merge of #89766 - krasimirgg:llvm-14-targetregistrty, r=nagisa
matthiaskrgr Oct 18, 2021
d3a84d4
Rollup merge of #89867 - Urgau:fix-double-definition, r=GuillaumeGomez
matthiaskrgr Oct 18, 2021
3f14625
Rollup merge of #89941 - hermitcore:kernel, r=joshtriplett
matthiaskrgr Oct 18, 2021
a284d74
Rollup merge of #89956 - JohnTitor:suggest-case-insensitive-match-nam…
matthiaskrgr Oct 18, 2021
b434eb6
Rollup merge of #89997 - cameron1024:const-str-as-bytes-ice, r=JohnTitor
matthiaskrgr Oct 18, 2021
bcb5127
Rollup merge of #90002 - lnicola:rust-analyzer-2021-10-18, r=lnicola
matthiaskrgr Oct 18, 2021
eccaca0
Rollup merge of #90025 - JohnTitor:revert-86011, r=estebank
matthiaskrgr Oct 18, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions compiler/rustc_lint_defs/src/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1957,7 +1957,7 @@ declare_lint! {
/// [issue #50504]: https://github.com/rust-lang/rust/issues/50504
/// [future-incompatible]: ../index.md#future-incompatible-lints
pub PROC_MACRO_DERIVE_RESOLUTION_FALLBACK,
Warn,
Deny,
"detects proc macro derives using inaccessible names from parent modules",
@future_incompatible = FutureIncompatibleInfo {
reference: "issue #83583 <https://github.com/rust-lang/rust/issues/83583>",
Expand Down Expand Up @@ -3253,7 +3253,7 @@ declare_lint! {
/// [issue #83125]: https://github.com/rust-lang/rust/issues/83125
/// [future-incompatible]: ../index.md#future-incompatible-lints
pub PROC_MACRO_BACK_COMPAT,
Warn,
Deny,
"detects usage of old versions of certain proc-macro crates",
@future_incompatible = FutureIncompatibleInfo {
reference: "issue #83125 <https://github.com/rust-lang/rust/issues/83125>",
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_llvm/llvm-wrapper/LLVMWrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
#include "llvm/Support/Host.h"
#include "llvm/Support/Memory.h"
#include "llvm/Support/SourceMgr.h"
#include "llvm/Support/TargetRegistry.h"
#include "llvm/Support/TargetSelect.h"
#include "llvm/Support/Timer.h"
#include "llvm/Support/raw_ostream.h"
Expand Down
5 changes: 5 additions & 0 deletions compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@
#include "llvm/Support/CBindingWrapping.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/Host.h"
#if LLVM_VERSION_LT(14, 0)
#include "llvm/Support/TargetRegistry.h"
#else
#include "llvm/MC/TargetRegistry.h"
#endif
#include "llvm/Target/TargetMachine.h"
#include "llvm/Transforms/IPO/PassManagerBuilder.h"
#include "llvm/Transforms/IPO/AlwaysInliner.h"
Expand Down
36 changes: 15 additions & 21 deletions compiler/rustc_span/src/lev_distance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,34 +58,28 @@ pub fn find_best_match_for_name(
let lookup = &lookup.as_str();
let max_dist = dist.unwrap_or_else(|| cmp::max(lookup.len(), 3) / 3);

let (case_insensitive_match, levenshtein_match) = name_vec
// Priority of matches:
// 1. Exact case insensitive match
// 2. Levenshtein distance match
// 3. Sorted word match
if let Some(case_insensitive_match) =
name_vec.iter().find(|candidate| candidate.as_str().to_uppercase() == lookup.to_uppercase())
{
return Some(*case_insensitive_match);
}
let levenshtein_match = name_vec
.iter()
.filter_map(|&name| {
let dist = lev_distance(lookup, &name.as_str());
if dist <= max_dist { Some((name, dist)) } else { None }
})
// Here we are collecting the next structure:
// (case_insensitive_match, (levenshtein_match, levenshtein_distance))
.fold((None, None), |result, (candidate, dist)| {
(
if candidate.as_str().to_uppercase() == lookup.to_uppercase() {
Some(candidate)
} else {
result.0
},
match result.1 {
None => Some((candidate, dist)),
Some((c, d)) => Some(if dist < d { (candidate, dist) } else { (c, d) }),
},
)
// (levenshtein_match, levenshtein_distance)
.fold(None, |result, (candidate, dist)| match result {
None => Some((candidate, dist)),
Some((c, d)) => Some(if dist < d { (candidate, dist) } else { (c, d) }),
});
// Priority of matches:
// 1. Exact case insensitive match
// 2. Levenshtein distance match
// 3. Sorted word match
if let Some(candidate) = case_insensitive_match {
Some(candidate)
} else if levenshtein_match.is_some() {
if levenshtein_match.is_some() {
levenshtein_match.map(|(candidate, _)| candidate)
} else {
find_match_by_sorted_words(name_vec, lookup)
Expand Down
10 changes: 3 additions & 7 deletions compiler/rustc_span/src/lev_distance/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,12 @@ fn test_find_best_match_for_name() {

assert_eq!(find_best_match_for_name(&input, Symbol::intern("1111111111"), None), None);

let input = vec![Symbol::intern("aAAA")];
let input = vec![Symbol::intern("AAAA")];
assert_eq!(
find_best_match_for_name(&input, Symbol::intern("AAAA"), None),
Some(Symbol::intern("aAAA"))
find_best_match_for_name(&input, Symbol::intern("aaaa"), None),
Some(Symbol::intern("AAAA"))
);

let input = vec![Symbol::intern("AAAA")];
// Returns None because `lev_distance > max_dist / 3`
assert_eq!(find_best_match_for_name(&input, Symbol::intern("aaaa"), None), None);

let input = vec![Symbol::intern("AAAA")];
assert_eq!(
find_best_match_for_name(&input, Symbol::intern("aaaa"), Some(4)),
Expand Down
4 changes: 1 addition & 3 deletions compiler/rustc_target/src/spec/hermit_kernel_base.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::spec::{LinkArgs, LinkerFlavor, LldFlavor, PanicStrategy, TargetOptions, TlsModel};
use crate::spec::{LinkArgs, LinkerFlavor, LldFlavor, PanicStrategy, TargetOptions};

pub fn opts() -> TargetOptions {
let mut pre_link_args = LinkArgs::new();
Expand All @@ -13,12 +13,10 @@ pub fn opts() -> TargetOptions {
disable_redzone: true,
linker: Some("rust-lld".to_owned()),
executables: true,
has_elf_tls: true,
pre_link_args,
panic_strategy: PanicStrategy::Abort,
position_independent_executables: true,
static_position_independent_executables: true,
tls_model: TlsModel::InitialExec,
..Default::default()
}
}
9 changes: 4 additions & 5 deletions compiler/rustc_typeck/src/bounds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,16 @@ impl<'tcx> Bounds<'tcx> {
})
});

self.region_bounds
.iter()
.map(|&(region_bound, span)| {
sized_predicate
.into_iter()
.chain(self.region_bounds.iter().map(|&(region_bound, span)| {
(
region_bound
.map_bound(|region_bound| ty::OutlivesPredicate(param_ty, region_bound))
.to_predicate(tcx),
span,
)
})
}))
.chain(self.trait_bounds.iter().map(|&(bound_trait_ref, span, constness)| {
let predicate = bound_trait_ref.with_constness(constness).to_predicate(tcx);
(predicate, span)
Expand All @@ -83,7 +83,6 @@ impl<'tcx> Bounds<'tcx> {
.iter()
.map(|&(projection, span)| (projection.to_predicate(tcx), span)),
)
.chain(sized_predicate.into_iter())
.collect()
}
}
2 changes: 1 addition & 1 deletion library/std/src/sys/hermit/net.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ impl TcpStream {
Ok(self.clone())
}

pub fn set_linger(&self, linger: Option<Duration>) -> io::Result<()> {
pub fn set_linger(&self, _linger: Option<Duration>) -> io::Result<()> {
unsupported()
}

Expand Down
14 changes: 11 additions & 3 deletions src/librustdoc/visit_ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,21 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
// the rexport defines the path that a user will actually see. Accordingly,
// we add the rexport as an item here, and then skip over the original
// definition in `visit_item()` below.
//
// We also skip `#[macro_export] macro_rules!` that have already been inserted,
// it can happen if within the same module a `#[macro_export] macro_rules!`
// is declared but also a reexport of itself producing two exports of the same
// macro in the same module.
let mut inserted = FxHashSet::default();
for export in self.cx.tcx.module_exports(CRATE_DEF_ID).unwrap_or(&[]) {
if let Res::Def(DefKind::Macro(_), def_id) = export.res {
if let Some(local_def_id) = def_id.as_local() {
if self.cx.tcx.has_attr(def_id, sym::macro_export) {
let hir_id = self.cx.tcx.hir().local_def_id_to_hir_id(local_def_id);
let item = self.cx.tcx.hir().expect_item(hir_id);
top_level_module.items.push((item, None));
if inserted.insert(def_id) {
let hir_id = self.cx.tcx.hir().local_def_id_to_hir_id(local_def_id);
let item = self.cx.tcx.hir().expect_item(hir_id);
top_level_module.items.push((item, None));
}
}
}
}
Expand Down
17 changes: 17 additions & 0 deletions src/test/rustdoc-json/reexport/macro.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// edition:2018

#![no_core]
#![feature(no_core)]

// @count macro.json "$.index[*][?(@.name=='macro')].inner.items[*]" 2

// @set repro_id = macro.json "$.index[*][?(@.name=='repro')].id"
// @has - "$.index[*][?(@.name=='macro')].inner.items[*]" $repro_id
#[macro_export]
macro_rules! repro {
() => {};
}

// @set repro2_id = macro.json "$.index[*][?(@.inner.name=='repro2')].id"
// @has - "$.index[*][?(@.name=='macro')].inner.items[*]" $repro2_id
pub use crate::repro as repro2;
14 changes: 14 additions & 0 deletions src/test/rustdoc/issue-89852.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// edition:2018

#![no_core]
#![feature(no_core)]

// @matches 'issue_89852/sidebar-items.js' '"repro"'
// @!matches 'issue_89852/sidebar-items.js' '"repro".*"repro"'

#[macro_export]
macro_rules! repro {
() => {};
}

pub use crate::repro as repro2;
28 changes: 28 additions & 0 deletions src/test/ui/consts/const-eval/issue-84957-const-str-as-bytes.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// build-pass

trait Foo {}

struct Bar {
bytes: &'static [u8],
func: fn(&Box<dyn Foo>),
}
fn example(_: &Box<dyn Foo>) {}

const BARS: &[Bar] = &[
Bar {
bytes: "0".as_bytes(),
func: example,
},
Bar {
bytes: "0".as_bytes(),
func: example,
},
];

fn main() {
let x = todo!();

for bar in BARS {
(bar.func)(&x);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ note: required by a bound in `std::hash::Hash::hash`
--> $SRC_DIR/core/src/hash/mod.rs:LL:COL
|
LL | fn hash<H: Hasher>(&self, state: &mut H);
| ^^^^^^ required by this bound in `std::hash::Hash::hash`
| ^ required by this bound in `std::hash::Hash::hash`
= note: this error originates in the derive macro `Hash` (in Nightly builds, run with -Z macro-backtrace for more info)

error: aborting due to previous error
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/derives/derives-span-Hash-enum.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ note: required by a bound in `std::hash::Hash::hash`
--> $SRC_DIR/core/src/hash/mod.rs:LL:COL
|
LL | fn hash<H: Hasher>(&self, state: &mut H);
| ^^^^^^ required by this bound in `std::hash::Hash::hash`
| ^ required by this bound in `std::hash::Hash::hash`
= note: this error originates in the derive macro `Hash` (in Nightly builds, run with -Z macro-backtrace for more info)

error: aborting due to previous error
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/derives/derives-span-Hash-struct.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ note: required by a bound in `std::hash::Hash::hash`
--> $SRC_DIR/core/src/hash/mod.rs:LL:COL
|
LL | fn hash<H: Hasher>(&self, state: &mut H);
| ^^^^^^ required by this bound in `std::hash::Hash::hash`
| ^ required by this bound in `std::hash::Hash::hash`
= note: this error originates in the derive macro `Hash` (in Nightly builds, run with -Z macro-backtrace for more info)

error: aborting due to previous error
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/derives/derives-span-Hash-tuple-struct.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ note: required by a bound in `std::hash::Hash::hash`
--> $SRC_DIR/core/src/hash/mod.rs:LL:COL
|
LL | fn hash<H: Hasher>(&self, state: &mut H);
| ^^^^^^ required by this bound in `std::hash::Hash::hash`
| ^ required by this bound in `std::hash::Hash::hash`
= note: this error originates in the derive macro `Hash` (in Nightly builds, run with -Z macro-backtrace for more info)

error: aborting due to previous error
Expand Down
24 changes: 12 additions & 12 deletions src/test/ui/generic-associated-types/issue-74816.stderr
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
error[E0277]: the size for values of type `Self` cannot be known at compilation time
error[E0277]: the trait bound `Self: Trait1` is not satisfied
--> $DIR/issue-74816.rs:9:5
|
LL | type Associated: Trait1 = Self;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Trait1` is not implemented for `Self`
|
note: required by a bound in `Trait2::Associated`
--> $DIR/issue-74816.rs:9:5
--> $DIR/issue-74816.rs:9:22
|
LL | type Associated: Trait1 = Self;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `Trait2::Associated`
| ^^^^^^ required by this bound in `Trait2::Associated`
help: consider further restricting `Self`
|
LL | trait Trait2: Sized {
| +++++++
LL | trait Trait2: Trait1 {
| ++++++++

error[E0277]: the trait bound `Self: Trait1` is not satisfied
error[E0277]: the size for values of type `Self` cannot be known at compilation time
--> $DIR/issue-74816.rs:9:5
|
LL | type Associated: Trait1 = Self;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Trait1` is not implemented for `Self`
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
|
note: required by a bound in `Trait2::Associated`
--> $DIR/issue-74816.rs:9:22
--> $DIR/issue-74816.rs:9:5
|
LL | type Associated: Trait1 = Self;
| ^^^^^^ required by this bound in `Trait2::Associated`
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `Trait2::Associated`
help: consider further restricting `Self`
|
LL | trait Trait2: Trait1 {
| ++++++++
LL | trait Trait2: Sized {
| +++++++

error: aborting due to 2 previous errors

Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/generic-associated-types/issue-86483.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ LL | for<'a> T: 'a,
| ^^

error[E0311]: the parameter type `T` may not live long enough
--> $DIR/issue-86483.rs:9:19
--> $DIR/issue-86483.rs:9:5
|
LL | pub trait IceIce<T>
| - help: consider adding an explicit lifetime bound...: `T: 'a`
...
LL | type Ice<'v>: IntoIterator<Item = &'v T>;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds...
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds...
|
note: ...that is required by this bound
--> $DIR/issue-86483.rs:7:16
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ LL | impl Tsized for () {}
|
= help: the trait `Sized` is not implemented for `[()]`
note: required by a bound in `Tsized`
--> $DIR/issue-61631-default-type-param-can-reference-self-in-trait.rs:17:17
--> $DIR/issue-61631-default-type-param-can-reference-self-in-trait.rs:17:14
|
LL | trait Tsized<P: Sized = [Self]> {}
| ^^^^^ required by this bound in `Tsized`
| ^ required by this bound in `Tsized`

error: aborting due to previous error

Expand Down
Loading