mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-21 22:34:05 +00:00
Auto merge of #133077 - cuviper:beta-next, r=cuviper
[beta] backports - Use completion item indices instead of property matching #132987, rust-lang/rust-analyzer#18503 - Reject raw lifetime followed by `'`, like regular lifetimes do #132341 - Only disable cache if predicate has opaques within it #132625 - rustdoc-search: case-sensitive only when capitals are used #133043 - (ci) Update macOS Xcode to 15 #131570 r? cuviper
This commit is contained in:
commit
4ff8ff0ecd
@ -715,7 +715,17 @@ impl Cursor<'_> {
|
||||
self.bump();
|
||||
self.bump();
|
||||
self.eat_while(is_id_continue);
|
||||
return RawLifetime;
|
||||
match self.first() {
|
||||
'\'' => {
|
||||
// Check if after skipping literal contents we've met a closing
|
||||
// single quote (which means that user attempted to create a
|
||||
// string with single quotes).
|
||||
self.bump();
|
||||
let kind = Char { terminated: true };
|
||||
return Literal { kind, suffix_start: self.pos_within_token() };
|
||||
}
|
||||
_ => return RawLifetime,
|
||||
}
|
||||
}
|
||||
|
||||
// Either a lifetime or a character literal with
|
||||
|
@ -12,26 +12,26 @@ use rustc_data_structures::fx::{FxHashSet, FxIndexMap, FxIndexSet};
|
||||
use rustc_data_structures::stack::ensure_sufficient_stack;
|
||||
use rustc_errors::{Diag, EmissionGuarantee};
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::LangItem;
|
||||
use rustc_hir::def_id::DefId;
|
||||
use rustc_infer::infer::BoundRegionConversionTime::{self, HigherRankedType};
|
||||
use rustc_infer::infer::DefineOpaqueTypes;
|
||||
use rustc_hir::LangItem;
|
||||
use rustc_infer::infer::at::ToTrace;
|
||||
use rustc_infer::infer::relate::TypeRelation;
|
||||
use rustc_infer::infer::BoundRegionConversionTime::{self, HigherRankedType};
|
||||
use rustc_infer::infer::DefineOpaqueTypes;
|
||||
use rustc_infer::traits::TraitObligation;
|
||||
use rustc_middle::bug;
|
||||
use rustc_middle::dep_graph::{DepNodeIndex, dep_kinds};
|
||||
use rustc_middle::dep_graph::{dep_kinds, DepNodeIndex};
|
||||
use rustc_middle::mir::interpret::ErrorHandled;
|
||||
pub use rustc_middle::traits::select::*;
|
||||
use rustc_middle::ty::abstract_const::NotConstEvaluatable;
|
||||
use rustc_middle::ty::error::TypeErrorToStringExt;
|
||||
use rustc_middle::ty::print::{PrintTraitRefExt as _, with_no_trimmed_paths};
|
||||
use rustc_middle::ty::print::{with_no_trimmed_paths, PrintTraitRefExt as _};
|
||||
use rustc_middle::ty::{
|
||||
self, GenericArgsRef, PolyProjectionPredicate, Ty, TyCtxt, TypeFoldable, TypeVisitableExt,
|
||||
Upcast,
|
||||
};
|
||||
use rustc_span::Symbol;
|
||||
use rustc_span::symbol::sym;
|
||||
use rustc_span::Symbol;
|
||||
use tracing::{debug, instrument, trace};
|
||||
|
||||
use self::EvaluationResult::*;
|
||||
@ -40,9 +40,9 @@ use super::coherence::{self, Conflict};
|
||||
use super::project::ProjectionTermObligation;
|
||||
use super::util::closure_trait_ref_and_return_type;
|
||||
use super::{
|
||||
ImplDerivedCause, Normalized, Obligation, ObligationCause, ObligationCauseCode, Overflow,
|
||||
PolyTraitObligation, PredicateObligation, Selection, SelectionError, SelectionResult,
|
||||
TraitQueryMode, const_evaluatable, project, util, wf,
|
||||
const_evaluatable, project, util, wf, ImplDerivedCause, Normalized, Obligation,
|
||||
ObligationCause, ObligationCauseCode, Overflow, PolyTraitObligation, PredicateObligation,
|
||||
Selection, SelectionError, SelectionResult, TraitQueryMode,
|
||||
};
|
||||
use crate::error_reporting::InferCtxtErrorExt;
|
||||
use crate::infer::{InferCtxt, InferOk, TypeFreshener};
|
||||
@ -1306,7 +1306,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||
}
|
||||
|
||||
let tcx = self.tcx();
|
||||
if self.can_use_global_caches(param_env) {
|
||||
if self.can_use_global_caches(param_env, trait_pred) {
|
||||
if let Some(res) = tcx.evaluation_cache.get(&(param_env, trait_pred), tcx) {
|
||||
return Some(res);
|
||||
}
|
||||
@ -1335,7 +1335,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||
return;
|
||||
}
|
||||
|
||||
if self.can_use_global_caches(param_env) && !trait_pred.has_infer() {
|
||||
if self.can_use_global_caches(param_env, trait_pred) && !trait_pred.has_infer() {
|
||||
debug!(?trait_pred, ?result, "insert_evaluation_cache global");
|
||||
// This may overwrite the cache with the same value
|
||||
// FIXME: Due to #50507 this overwrites the different values
|
||||
@ -1479,7 +1479,11 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||
}
|
||||
|
||||
/// Returns `true` if the global caches can be used.
|
||||
fn can_use_global_caches(&self, param_env: ty::ParamEnv<'tcx>) -> bool {
|
||||
fn can_use_global_caches(
|
||||
&self,
|
||||
param_env: ty::ParamEnv<'tcx>,
|
||||
pred: ty::PolyTraitPredicate<'tcx>,
|
||||
) -> bool {
|
||||
// If there are any inference variables in the `ParamEnv`, then we
|
||||
// always use a cache local to this particular scope. Otherwise, we
|
||||
// switch to a global cache.
|
||||
@ -1500,7 +1504,13 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||
|
||||
// Avoid using the global cache when we're defining opaque types
|
||||
// as their hidden type may impact the result of candidate selection.
|
||||
if !self.infcx.defining_opaque_types().is_empty() {
|
||||
//
|
||||
// HACK: This is still theoretically unsound. Goals can indirectly rely
|
||||
// on opaques in the defining scope, and it's easier to do so with TAIT.
|
||||
// However, if we disqualify *all* goals from being cached, perf suffers.
|
||||
// This is likely fixed by better caching in general in the new solver.
|
||||
// See: <https://github.com/rust-lang/rust/issues/132064>.
|
||||
if !self.infcx.defining_opaque_types().is_empty() && pred.has_opaque_types() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -1523,7 +1533,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||
let tcx = self.tcx();
|
||||
let pred = cache_fresh_trait_pred.skip_binder();
|
||||
|
||||
if self.can_use_global_caches(param_env) {
|
||||
if self.can_use_global_caches(param_env, cache_fresh_trait_pred) {
|
||||
if let Some(res) = tcx.selection_cache.get(&(param_env, pred), tcx) {
|
||||
return Some(res);
|
||||
}
|
||||
@ -1580,7 +1590,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||
return;
|
||||
}
|
||||
|
||||
if self.can_use_global_caches(param_env) {
|
||||
if self.can_use_global_caches(param_env, cache_fresh_trait_pred) {
|
||||
if let Err(Overflow(OverflowError::Canonical)) = candidate {
|
||||
// Don't cache overflow globally; we only produce this in certain modes.
|
||||
} else if !pred.has_infer() && !candidate.has_infer() {
|
||||
@ -1787,7 +1797,11 @@ enum DropVictim {
|
||||
|
||||
impl DropVictim {
|
||||
fn drop_if(should_drop: bool) -> DropVictim {
|
||||
if should_drop { DropVictim::Yes } else { DropVictim::No }
|
||||
if should_drop {
|
||||
DropVictim::Yes
|
||||
} else {
|
||||
DropVictim::No
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1891,7 +1905,11 @@ impl<'tcx> SelectionContext<'_, 'tcx> {
|
||||
(ObjectCandidate(_) | ProjectionCandidate(_), ParamCandidate(victim_cand)) => {
|
||||
// Prefer these to a global where-clause bound
|
||||
// (see issue #50825).
|
||||
if is_global(*victim_cand) { DropVictim::Yes } else { DropVictim::No }
|
||||
if is_global(*victim_cand) {
|
||||
DropVictim::Yes
|
||||
} else {
|
||||
DropVictim::No
|
||||
}
|
||||
}
|
||||
(
|
||||
ImplCandidate(_)
|
||||
@ -2450,9 +2468,11 @@ impl<'tcx> SelectionContext<'_, 'tcx> {
|
||||
} else {
|
||||
// If this is an ill-formed auto/built-in trait, then synthesize
|
||||
// new error args for the missing generics.
|
||||
let err_args = ty::GenericArgs::extend_with_error(tcx, trait_def_id, &[
|
||||
normalized_ty.into(),
|
||||
]);
|
||||
let err_args = ty::GenericArgs::extend_with_error(
|
||||
tcx,
|
||||
trait_def_id,
|
||||
&[normalized_ty.into()],
|
||||
);
|
||||
ty::TraitRef::new_from_args(tcx, trait_def_id, err_args)
|
||||
};
|
||||
|
||||
@ -3154,7 +3174,11 @@ impl<'o, 'tcx> TraitObligationStackList<'o, 'tcx> {
|
||||
}
|
||||
|
||||
fn depth(&self) -> usize {
|
||||
if let Some(head) = self.head { head.depth } else { 0 }
|
||||
if let Some(head) = self.head {
|
||||
head.depth
|
||||
} else {
|
||||
0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -46,7 +46,7 @@ envs:
|
||||
RUSTC_RETRY_LINKER_ON_SEGFAULT: 1
|
||||
MACOSX_DEPLOYMENT_TARGET: 10.12
|
||||
MACOSX_STD_DEPLOYMENT_TARGET: 10.12
|
||||
SELECT_XCODE: /Applications/Xcode_14.3.1.app
|
||||
SELECT_XCODE: /Applications/Xcode_15.2.app
|
||||
NO_LLVM_ASSERTIONS: 1
|
||||
NO_DEBUG_ASSERTIONS: 1
|
||||
NO_OVERFLOW_CHECKS: 1
|
||||
@ -282,7 +282,7 @@ auto:
|
||||
RUST_CONFIGURE_ARGS: --enable-full-tools --enable-sanitizers --enable-profiler --set rust.jemalloc --set rust.lto=thin --set rust.codegen-units=1
|
||||
RUSTC_RETRY_LINKER_ON_SEGFAULT: 1
|
||||
MACOSX_DEPLOYMENT_TARGET: 10.12
|
||||
SELECT_XCODE: /Applications/Xcode_14.3.1.app
|
||||
SELECT_XCODE: /Applications/Xcode_15.2.app
|
||||
NO_LLVM_ASSERTIONS: 1
|
||||
NO_DEBUG_ASSERTIONS: 1
|
||||
NO_OVERFLOW_CHECKS: 1
|
||||
@ -298,7 +298,7 @@ auto:
|
||||
RUST_CONFIGURE_ARGS: --enable-sanitizers --enable-profiler --set rust.jemalloc --set target.aarch64-apple-ios-macabi.sanitizers=false --set target.x86_64-apple-ios-macabi.sanitizers=false
|
||||
RUSTC_RETRY_LINKER_ON_SEGFAULT: 1
|
||||
MACOSX_DEPLOYMENT_TARGET: 10.12
|
||||
SELECT_XCODE: /Applications/Xcode_14.3.1.app
|
||||
SELECT_XCODE: /Applications/Xcode_15.2.app
|
||||
NO_LLVM_ASSERTIONS: 1
|
||||
NO_DEBUG_ASSERTIONS: 1
|
||||
NO_OVERFLOW_CHECKS: 1
|
||||
@ -327,7 +327,7 @@ auto:
|
||||
--set llvm.ninja=false
|
||||
--set rust.lto=thin
|
||||
RUSTC_RETRY_LINKER_ON_SEGFAULT: 1
|
||||
SELECT_XCODE: /Applications/Xcode_14.3.1.app
|
||||
SELECT_XCODE: /Applications/Xcode_15.4.app
|
||||
USE_XCODE_CLANG: 1
|
||||
MACOSX_DEPLOYMENT_TARGET: 11.0
|
||||
MACOSX_STD_DEPLOYMENT_TARGET: 11.0
|
||||
@ -347,7 +347,7 @@ auto:
|
||||
--enable-profiler
|
||||
--set rust.jemalloc
|
||||
RUSTC_RETRY_LINKER_ON_SEGFAULT: 1
|
||||
SELECT_XCODE: /Applications/Xcode_14.3.1.app
|
||||
SELECT_XCODE: /Applications/Xcode_15.4.app
|
||||
USE_XCODE_CLANG: 1
|
||||
MACOSX_DEPLOYMENT_TARGET: 11.0
|
||||
MACOSX_STD_DEPLOYMENT_TARGET: 11.0
|
||||
|
@ -2098,6 +2098,7 @@ class DocSearch {
|
||||
const sortResults = async(results, isType, preferredCrate) => {
|
||||
const userQuery = parsedQuery.userQuery;
|
||||
const casedUserQuery = parsedQuery.original;
|
||||
const isMixedCase = casedUserQuery !== userQuery;
|
||||
const result_list = [];
|
||||
for (const result of results.values()) {
|
||||
result.item = this.searchIndex[result.id];
|
||||
@ -2109,10 +2110,12 @@ class DocSearch {
|
||||
let a, b;
|
||||
|
||||
// sort by exact case-sensitive match
|
||||
a = (aaa.item.name !== casedUserQuery);
|
||||
b = (bbb.item.name !== casedUserQuery);
|
||||
if (a !== b) {
|
||||
return a - b;
|
||||
if (isMixedCase) {
|
||||
a = (aaa.item.name !== casedUserQuery);
|
||||
b = (bbb.item.name !== casedUserQuery);
|
||||
if (a !== b) {
|
||||
return a - b;
|
||||
}
|
||||
}
|
||||
|
||||
// sort by exact match with regard to the last word (mismatch goes later)
|
||||
|
@ -1068,7 +1068,7 @@ pub(crate) fn handle_completion_resolve(
|
||||
else {
|
||||
return Ok(original_completion);
|
||||
};
|
||||
let resolved_completions = to_proto::completion_items(
|
||||
let mut resolved_completions = to_proto::completion_items(
|
||||
&snap.config,
|
||||
&forced_resolve_completions_config.fields_to_resolve,
|
||||
&line_index,
|
||||
@ -1077,15 +1077,13 @@ pub(crate) fn handle_completion_resolve(
|
||||
resolve_data.trigger_character,
|
||||
resolved_completions,
|
||||
);
|
||||
let Some(mut resolved_completion) = resolved_completions.into_iter().find(|completion| {
|
||||
completion.label == original_completion.label
|
||||
&& completion.kind == original_completion.kind
|
||||
&& completion.deprecated == original_completion.deprecated
|
||||
&& completion.preselect == original_completion.preselect
|
||||
&& completion.sort_text == original_completion.sort_text
|
||||
}) else {
|
||||
return Ok(original_completion);
|
||||
};
|
||||
|
||||
let mut resolved_completion =
|
||||
if resolved_completions.get(resolve_data.completion_item_index).is_some() {
|
||||
resolved_completions.swap_remove(resolve_data.completion_item_index)
|
||||
} else {
|
||||
return Ok(original_completion);
|
||||
};
|
||||
|
||||
if !resolve_data.imports.is_empty() {
|
||||
let additional_edits = snap
|
||||
|
@ -826,6 +826,7 @@ pub struct CompletionResolveData {
|
||||
pub imports: Vec<CompletionImport>,
|
||||
pub version: Option<i32>,
|
||||
pub trigger_character: Option<char>,
|
||||
pub completion_item_index: usize,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
|
@ -391,18 +391,36 @@ fn completion_item(
|
||||
} else {
|
||||
Vec::new()
|
||||
};
|
||||
if something_to_resolve || !imports.is_empty() {
|
||||
let data = lsp_ext::CompletionResolveData {
|
||||
let (ref_resolve_data, resolve_data) = if something_to_resolve || !imports.is_empty() {
|
||||
let mut item_index = acc.len();
|
||||
let ref_resolve_data = if ref_match.is_some() {
|
||||
let ref_resolve_data = lsp_ext::CompletionResolveData {
|
||||
position: tdpp.clone(),
|
||||
imports: Vec::new(),
|
||||
version,
|
||||
trigger_character: completion_trigger_character,
|
||||
completion_item_index: item_index,
|
||||
};
|
||||
item_index += 1;
|
||||
Some(to_value(ref_resolve_data).unwrap())
|
||||
} else {
|
||||
None
|
||||
};
|
||||
let resolve_data = lsp_ext::CompletionResolveData {
|
||||
position: tdpp.clone(),
|
||||
imports,
|
||||
version,
|
||||
trigger_character: completion_trigger_character,
|
||||
completion_item_index: item_index,
|
||||
};
|
||||
lsp_item.data = Some(to_value(data).unwrap());
|
||||
}
|
||||
(ref_resolve_data, Some(to_value(resolve_data).unwrap()))
|
||||
} else {
|
||||
(None, None)
|
||||
};
|
||||
|
||||
if let Some((label, indel, relevance)) = ref_match {
|
||||
let mut lsp_item_with_ref = lsp_types::CompletionItem { label, ..lsp_item.clone() };
|
||||
let mut lsp_item_with_ref =
|
||||
lsp_types::CompletionItem { label, data: ref_resolve_data, ..lsp_item.clone() };
|
||||
lsp_item_with_ref
|
||||
.additional_text_edits
|
||||
.get_or_insert_with(Default::default)
|
||||
@ -411,6 +429,7 @@ fn completion_item(
|
||||
acc.push(lsp_item_with_ref);
|
||||
};
|
||||
|
||||
lsp_item.data = resolve_data;
|
||||
acc.push(lsp_item);
|
||||
|
||||
fn set_score(
|
||||
|
@ -1,5 +1,5 @@
|
||||
<!---
|
||||
lsp/ext.rs hash: 90cf7718d54fe3c2
|
||||
lsp/ext.rs hash: 96f88b7a5d0080c6
|
||||
|
||||
If you need to change the above hash to make the test pass, please check if you
|
||||
need to adjust this doc as well and ping this issue:
|
||||
|
@ -20,11 +20,11 @@
|
||||
// lldb-command:run
|
||||
|
||||
// lldb-command:print a
|
||||
// lldb-check: = 19
|
||||
// lldb-check: 19
|
||||
// lldb-command:print b
|
||||
// lldb-check: = 20
|
||||
// lldb-check: 20
|
||||
// lldb-command:print c
|
||||
// lldb-check: = 21.5
|
||||
// lldb-check: 21.5
|
||||
|
||||
fn binding(a: i64, b: u64, c: f64) {
|
||||
let x = 0;
|
||||
|
24
tests/rustdoc-js-std/write.js
Normal file
24
tests/rustdoc-js-std/write.js
Normal file
@ -0,0 +1,24 @@
|
||||
const EXPECTED = [
|
||||
{
|
||||
'query': 'write',
|
||||
'others': [
|
||||
{ 'path': 'std::fmt', 'name': 'write' },
|
||||
{ 'path': 'std::fs', 'name': 'write' },
|
||||
{ 'path': 'std::ptr', 'name': 'write' },
|
||||
{ 'path': 'std::fmt', 'name': 'Write' },
|
||||
{ 'path': 'std::io', 'name': 'Write' },
|
||||
{ 'path': 'std::hash::Hasher', 'name': 'write' },
|
||||
],
|
||||
},
|
||||
{
|
||||
'query': 'Write',
|
||||
'others': [
|
||||
{ 'path': 'std::fmt', 'name': 'Write' },
|
||||
{ 'path': 'std::io', 'name': 'Write' },
|
||||
{ 'path': 'std::fmt', 'name': 'write' },
|
||||
{ 'path': 'std::fs', 'name': 'write' },
|
||||
{ 'path': 'std::ptr', 'name': 'write' },
|
||||
{ 'path': 'std::hash::Hasher', 'name': 'write' },
|
||||
],
|
||||
},
|
||||
];
|
17
tests/rustdoc-js/case.js
Normal file
17
tests/rustdoc-js/case.js
Normal file
@ -0,0 +1,17 @@
|
||||
const EXPECTED = [
|
||||
{
|
||||
'query': 'Foo',
|
||||
'others': [
|
||||
{ 'path': 'case', 'name': 'Foo', 'desc': 'Docs for Foo' },
|
||||
{ 'path': 'case', 'name': 'foo', 'desc': 'Docs for foo' },
|
||||
],
|
||||
},
|
||||
{
|
||||
'query': 'foo',
|
||||
'others': [
|
||||
// https://github.com/rust-lang/rust/issues/133017
|
||||
{ 'path': 'case', 'name': 'Foo', 'desc': 'Docs for Foo' },
|
||||
{ 'path': 'case', 'name': 'foo', 'desc': 'Docs for foo' },
|
||||
],
|
||||
},
|
||||
];
|
7
tests/rustdoc-js/case.rs
Normal file
7
tests/rustdoc-js/case.rs
Normal file
@ -0,0 +1,7 @@
|
||||
#![allow(nonstandard_style)]
|
||||
|
||||
/// Docs for Foo
|
||||
pub struct Foo;
|
||||
|
||||
/// Docs for foo
|
||||
pub struct foo;
|
14
tests/ui/lifetimes/raw/immediately-followed-by-lt.rs
Normal file
14
tests/ui/lifetimes/raw/immediately-followed-by-lt.rs
Normal file
@ -0,0 +1,14 @@
|
||||
//@ edition: 2021
|
||||
|
||||
// Make sure we reject the case where a raw lifetime is immediately followed by another
|
||||
// lifetime. This reserves a modest amount of space for changing lexing to, for example,
|
||||
// delay rejection of overlong char literals like `'r#long'id`.
|
||||
|
||||
macro_rules! w {
|
||||
($($tt:tt)*) => {}
|
||||
}
|
||||
|
||||
w!('r#long'id);
|
||||
//~^ ERROR character literal may only contain one codepoint
|
||||
|
||||
fn main() {}
|
13
tests/ui/lifetimes/raw/immediately-followed-by-lt.stderr
Normal file
13
tests/ui/lifetimes/raw/immediately-followed-by-lt.stderr
Normal file
@ -0,0 +1,13 @@
|
||||
error: character literal may only contain one codepoint
|
||||
--> $DIR/immediately-followed-by-lt.rs:11:4
|
||||
|
|
||||
LL | w!('r#long'id);
|
||||
| ^^^^^^^^
|
||||
|
|
||||
help: if you meant to write a string literal, use double quotes
|
||||
|
|
||||
LL | w!("r#long"id);
|
||||
| ~ ~
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
Loading…
Reference in New Issue
Block a user